First, start the original server
First Open "terminal (terminal)", enter the sudo apachectl-v, (may need to enter the machine secret). The Apache version is shown as follows:
You can enter a startup command to start: sudo apachectl start
Open the browser input http://localhost, you can see it work! Content, this page is actually located in the/library (Resource library)/webserver/documents/, is the Apache default root directory.
Second, the local Apache server
1, first in their own computer nickname folder under the new Sites folder:
Put some files in it, such as Json,image, as false data.
2, find the original configuration file, to the original file backup.
The next step is to operate under the terminal and enter the following instruction (the code behind it can be copied directly)
Switch working directory
$CD/etc/apache2
View File directory
$ls-L
Backup files, safekeeping, just need to be executed once.
$sudo CP httpd.conf Httpd.conf.bak
Hint: The following line of code do not hit, if the subsequent operation error! To restore the backed-up httpd.conf file using the following command (Dong Platinum Blog Park)
$sudo CP Httpd.conf.bak httpd.conf
3. Start modifying the configuration file
Edit httpd.conf with Vim
$sudo Vim httpd.conf
You can see that there are two paths to change them to the path of the Sites folder you just built.
Note: Sometimes you can not modify the httpd.conf, please find her in the Finder, and right-click, display Introduction, modify the file read and write permissions. If the following VIM command appears as follows, press E directly to enter the editing mode:
In command mode, look for DocumentRoot, enter the left slash at the bottom, find the field, and then press I to enter edit mode
/documentroot
Then find the next PHP
/php
Navigate to this line and move the cursor to the left. Press X to delete "#" to open the directory
( If there is a 10.10 system, there is a step: find the options input/options can also visually find the location in the diagram, add a word between Options and follow)
After the change, press the ESC key to exit edit mode, and then enter: Wq Save and exit if you don't want to save the wrong way: q!
4. Finishing work and confirming success
Copy configuration file
$sudo CP Php.ini.default PHP.ini
After restarting the Apache server, it's normal to say that.
$sudo apachectl-k Restart
After that, it's normal to say that, don't worry.
Confirm the success of the end of the No, go to the browser to enter localhost if you can come to the following interface is right
5. Precautions
Note the previous backup. Do not back up multiple times.
Note that all English symbols and letters are used in the Vim editor.
The command for the server switch is
$sudo apachectl-k Start
$sudo apachectl-k Stop
Every time you turn off the computer and then want to use the server will be re-tapping the open command
Reference: https://www.linuxidc.com/Linux/2015-02/113577.htm
Restart Apache:sudo/usr/sbin/apachectl restart
Close Apache:sudo/usr/sbin/apachectl Stop
Open Apache:sudo/usr/sbin/apachectl Start
MAC Apache Server Setup