Configure Apache server One, purpose
- Can have a test server, not all of the special network services can be found free!
Second, why should we use "Apache"?
- Apache is currently the most widely used Web server
- Mac comes with, only need to modify a few configuration can be, simple, fast
- Some special server functions, Apache can be very good support (for example: HTTP put/delete operation, knowledge supplement involves the HTTPS service)
Iii. preparatory work
Iv. Configuring the server
- Configuring the server's work
- Create a "Sites" folder in the Finder and create it directly under the/users/apple (current user name) directory
- Modify "Two Paths" in the configuration file to point to the folder you just created
- Copy a file
- Configuring Server Considerations
- Close Chinese Input Method
- A "space" is required between the command and the argument
- Modify system files Be sure to remember "sudo", otherwise there will be no permissions
- Directory to be in/users/apple (current user name)
- Configure the server
- Tips: OpenHeadof the,can beinCuffShellfish,butis aNoto beCuffShellfish
Specific procedures
Switch working directory
$cd /etc/apache2
backup Files , safekeeping, just need to be executed once.
$sudo cp httpd.conf httpd.conf.bak
Tip: If there is an error in subsequent actions! You can use the following command to recover a backed up httpd.conf file:
$ sudo cp httpd.conf.bak httpd.conf
Edit httpd.conf with Vim
$sudo vim httpd.conf
Vim can only use the keyboard, can not use the mouse
- Find DocumentRoot
* /DocumentRoot
- "Move cursor to First line" into edit mode
* i
- "Modify the path in quotation marks" (Enter command mode)
* ESC
- Find DocumentRoot
* n
- Enter edit mode
* i
- "Modify the path in parentheses"
- Modify the path values in document and directory to:
/Users/chenyong/Sites
- Note: In Mac10.10, those two commands are in the same place, the Mac10.10 previous version in two places
- Enter Command mode
* ESC
- Find PHP
* /php
- Delete Line Comment #
* x
- Save and exit
* :wq
- Do not save exit!!!!!!!!!
* :q!
- Switch working directory
$cd /etc
- Copy php.ini file
$sudo cp php.ini.default php.ini
- Restarting the Apache server
$sudo apachectl -k restart
Attention:
- The following error is normal if prompted:
Httpd:could not reliably determine the server ' s fully qualified domain name, using teacher.local for ServerName httpd not Running, trying to start
Problems
If you click the info.php file, the download appears, or you just display a small paragraph of text
Workaround:
* Enter the following two commands in the terminal: *
$sudo apachectl -k stop
Close Apache Server
$sudo apachectl -k start
Re-launch Apache again
Every time you start your computer, the Apache server will not start automatically by default!
After you can start the computer, open the terminal and enter the following command:
$sudo apachectl -k start
Launch Apache
The most common problem
The swap file already exists, press the letter D directly, you can delete the swap file!
The Apache configuration for Mac 10.10 is slightly different!
See "Server Configuration Video \02-mac10.10 Apache configuration. mp4"
Found in httpd.conf
"Options FollowSymLinks Multiviews"
Add a word Indexes, the result of the modification is as follows:
"Options Indexes FollowSymLinks Multiviews"
Tip: Don't take a minute to learn vim at the moment.
Configuring the Apache Server