Sometimes, we need to share some files in the intranet workgroup or the background interface is not given in time, you want to simulate the real data, directly in the project to create plist can also do this need, but inevitably make the project redundant and look relatively low. This time to see the importance of configuring the local server, do not have to wait for the background interface update, just according to the interface documents themselves simulation of real data, that is convenient and appear tall on.
The Mac comes with an Apache environment, and all we have to do is configure it a little bit.
Environment: Mac OS X 10.11.
Launch Apache
In terminal input: sudo apachectl start, so that the Mac comes with Apache launched, in the browser input "http://localhost", will display "It works!", indicating that the server has been started successfully. The default root directory for Apache is under "/library/webserver/documents/".
Configure the server
Create a "Sites" folder in the Finder and create it directly under the/users/wan (current user name) directory.
1, switch the working directory: cd/etc/apache2
2, backup files, only need to execute once: sudo cp httpd.conf Httpd.conf.bak
3, if the operation error! You can use the command to restore the backed up httpd.conf file: sudo cp httpd.conf.bak httpd.conf
4. Use Vim to edit httpd.conf file, httpd.conf file when Apache configuration file: sudo vim httpd.conf
At this point you need to enter a password to obtain permissions, the following interface appears:
Enter into the following interface:
5, hold down the SHIFT key, and enter the ":" Number into the VIM command mode, search/documentroot, find the corresponding position in the map to change the circle path to the Sites folder previously created path.
6, then find the options followsymlinks: Modify the Options Indexes followsymlinks, add a Indexes word between the two words.
7, next find php,:/php, locate the position in the diagram:
8. Remove the # from the front of the code. Last: Wq Save and exit.
9. Switch working directory: CD/ETC
10. Copy php.ini file: sudo cp php.ini.default php.ini
Restarting the Apache server
In terminal input: sudo apachectl-k restart
This time if you enter "HTTP://127.0.0.1/" in the browser address, the directory in the Sites folder will be listed. Computers in the same workgroup can access the files on this computer through the IP address of the computer.
Configuring Apach services under Mac