Purpose of configuration: have a dedicated test server
We need to do the following things:
1. Create a new directory to store the Web page
2. Modify the Apache configuration file httpd.conf
-Modify two paths
-Add a property
-Support PHP Script
3. Copy the php.ini file
First, create a new directory, store the Web page
Note: Do not place directories in personal folders such as desktops or documents
It is generally placed in the following directory:
/users/xxxx/sites
where xxxx is replaced with the current user name of the computer, for example, my is Janlor
The directory already exists by default in the 10.10.3 system (that is, "site") and you do not need to create a new sites folder
Second, modify the Apache configuration file httpd.conf
1. Open terminal to enter the httpd.conf file directory
Cd/etc/apache2 Enter
2. View current working directory
PWD Enter
LS Enter
Then you can see the extra and http.conf two files (I have backed up the httpd.conf file here, so many httpd.conf.bak files)
3. Back up the httpd.conf file
Because there is no way to undo the use of terminal operations, it is best to back up the relevant files before operation, especially for the novice error-prone
To back up the httpd.conf file, simply enter the following command:
sudo cp httpd.conf Httpd.conf.bak
sudo means to use system administrator to modify, have maximum operation permission
CP indicates copy file
Note that there are spaces in the middle of the:1> Terminal command
2> This command only needs to be executed once!!
3> If an error occurs during configuration, you can recover it with the following command:
sudo cp Httpd.conf.bak httpd.conf
4. Edit the httpd.conf file
First close Chinese Input method (prevent error)
1. Open the httpd.conf file with the VIM editor
Enter the following command:
sudo vim httpd.conf
sudo here cannot be lost, otherwise the open file is read-only and cannot be edited
2. Find DocumentRoot
1> Input:
/documentroot
Then move the cursor to the two directories:
Input:
I
Enter edit mode (you can see a--insert--below)
Next, replace the two directories in the quotation marks with the following:
/users/xxxx/sites
That is, just start the new directory to store the Web page, XXXX changed to the computer's user name
2> continue down, find Options followsymlinks multiviews this sentence
Adding indexes to the options FollowSymLinks becomes:
Options Indexes followsymlinks MultiViews
3> Find PHP
Press the ESC key in the upper left corner of the keyboard to enter command mode
Input:
/php
Move the cursor to the beginning of the line, press "I" to enter edit mode, delete the "#" at the beginning of the line
4> Save exit
In command mode, enter:
: Wq
Third, copy php.ini file
Input:
sudo cp/etc/php.ini.default/etc/php.ini
Iv. test whether the configuration is successful
Start Apache server: sudo apachectl-k start
Stop Apache server: sudo apachectl-k stop
Restart Apache server: sudo apachectl-k restart
Note: There is usually a hint:
This is common because there is no local DNS server, this hint can be ignored
If it is another hint, it indicates a problem with the configuration just now
Test is configured successfully, just enter 127.0.0.1 in the browser
The presence indicates a successful configuration:
Five, the installation process may appear problems and solutions
1. In Vim, if you feel that you have made an inappropriate change, do not save the exit, you should use: q! command does not save the exit
2. When sudo is entered, a password is required, which is the computer's power-on password, and no password can be set in "System Preferences"-"users and Groups"-"Change Password"
3. After the configuration is complete, if the prompt does not have permission to access, the majority is because the directory is incorrectly written
4. Click "PHP", if the "download" or display PHP source content, the PHP is not configured successfully
-No Comments on PHP line open in http.conf
-No copy php.ini
If both of these steps have been completed, it is not possible to stop Apache and then start the command above.
5. In order to ensure the user's security, every time the computer restarts Apache will not automatically start, need to enter the terminal manual start
That
sudo apachectl-k start
[IOS] Hyper-detailed Apache server configuration (10.10 system)