1. Start
sudo apachectl -k start
2. Restart
sudo apachectl -k restart
3. Close
sudo apachectl -k stop
(Remember to clear the browser cache after closing, otherwise go to localhost The URL will also show it works)
//---------------------------------------- -----------------------------
apache supports PHP
1??Go to the folder /etc/apache2
2??Copy the httpd.conf file to the desktop (system files cannot be modified, enter the user password)
3??Use text editing to open httpd.conf
4??Find #LoadModule php5_module ... Delete the # in front and save
5?? Copy the modified httpd.conf file on the desktop to /etc/apache2 Select Override (enter user password)
6??Start apache
Encountered an error when starting apache: httpd:
Could not reliably determine the server's fully qualified domain name
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
1??Go to file Folder /etc/apache2
2??Copy the httpd.conf file to the desktop (system files cannot be modified, enter the user password)
3??Use text editing to open httpd.conf
4 ??turn up
#ServerName www.example.com:80 is modified to ServerName localhost:80
5?? Copy the modified httpd.conf file from the desktop to /etc/apache2 and select overwrite (enter user Password)
6??Restart apache
//-------------------------------- ----------------------------------
Friends who are accustomed to using the command line can use the command line
Enter the directory where the Apache configuration file is located
cd /etc/apache2/
Modify the Apache configuration file
sudo vim httpd.conf
vim中有两种模式 命令模式,用于输入命令(注意输入法要在英文状态) shift+V 可以选中一行 y 复制一行 p 在当前行下方粘贴复制的内容 d$ 删除到行尾 x 删除一个字符 :wq 保存退出 :q! 不保存退出 i 进入编辑模式 编辑模式:用于编辑按ESC可以切换回命令模式
<span><span>sudo cp file1 file2 将file1复制到file2</span></span>
command The specific operations will not be described in detail. Friends who like to use the command line can try it themselves
The above introduces how to start and shut down the apache server in Mac OS