one, Apache server
1. The most widely used WEB server
2. mac comes with, only need to modify a few configuration can, simple, fast
3. some special server functions, Apache can be very good support
Purpose: to have a test environment of your own
Ii. Preparatory work
1. Set User password
2.MAC 10.10 and above
three , configure the server (this process will use the VIM command, it is recommended to understand first)
1. Common commands
sudo apachectl-v //In general the Mac system comes with an Apache environment, and this command is useful for viewing the Apache version of the current system
This process will require the user to enter a password, the input is hidden, the user input to complete the direct return.
sudo apachectl-k start //Start Apache
After this step, you can see if Apche is already started, enter "http://localhost" or "127.0.0.1" in the Safari address bar, if the page appears "itwork! "Indicates that it has been started.
sudo apachectl-k stop //Stop Apache
sudo apachectl-k restart Restart Apache
2. Configuring the server's work
1> Create a "Sites" folder in the Finder and create it directly under the/users/apple (current user name) directory
2> Modify the "Two paths" in the configuration file, point to the folder you just created (Follow the process command step for 4.)
3> Copy a file (follow the 4. Process command Step)
3. Configuring Server Considerations
1> closing Chinese Input method
A "space" is required between the 2> command and the argument
3> Modifying system files Be sure to remember "sudo", otherwise there will be no permissions
4> directory to/users/*** (current user name): Drag and drop the folder you created sites directly into the terminal to view the Apache server folder path you created
4. Configure the server process (the following command terminal executes)
//Switch working directory
cd/etc/apache2//* * * backup file, safekeeping, only need to execute once (you can use the LS command to see if a new Httpd.conf.bak file is added)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 (This step does not need to be performed)sudo cp httpd.conf.bak httpd.conf//use Vim to edit httpd.conf (vim can only use the keyboard, can not use the mouse)sudo vim httpd.conf//Find DocumentRoot (the interface will appear after the search is finished)/DocumentRoot
"Keyboard Direction key control, move the cursor to the first line"
"modify the path in quotation marks"
//Modify two Lib/webser/docume to our own server folder path (/users/*** user name ***/sites)
"Press I into edit mode" (the terminal appears at the bottom of the character indicates that it has entered edit mode)
//exit Edit mode, enter command modeESC
"move the cursor to the first line")
0 This is zero, not the letter O
"Save and exit": Wq
"Continue into Edit"
sudo vim httpd.conf
"At this point, if you want to see if the change is successful, you can continue with the/documentroot above to see if the two paths have changed."
"Find"
/options
"Press DOWN ARROW to go down"
//Find
Options FollowSymLinks MultiViews
"Enter edit mode Press i"
//Add a word
Options Indexes followsymlinks multiviews
//Find PHP
/PHP
"move the cursor to the first line"
0
Delete line comment # (such as position, press I to enter edit mode, delete and press ESC to exit edit mode)
//Save and exit: Wq
//do not save exit!!!!!!!!! (This step does not need to execute, if you write the wrong input wrong, it is executed): q!
//Switch working directoryCD/etc
//copy php.ini filesudo cp php.ini.defaultphp.ini
//restarting the Apache serversudo apachectl-k Restart (after which the warning indicated is normal) Test the Apache server to enter 127.0 in the browser address bar . 0.1, that's when you find out if you're still daddy's it work!
So, please clear your safari-->. "Clear History and site data"
Try typing "127.0.0.1" again.
If you want more content in your Apache, try the steps below.
Simply create a folder with a. JSON suffix name or whatever, put a JSON text inside it, and put it in the Sites folder.
Then enter 127.0.0.1/demo.json and try it.
Apache is a server, in order to ensure user security, every time you restart the computer Apache will not automatically start
Need to enter terminal, manually start once
Finally, finish the call.
Mac under Apache server configuration Tutorial