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.
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, Press and hold (shift +:) search/documentroot, find the corresponding position in the map to change the circle path to the Sites folder you created Earlier.
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.
How to configure the Apache server under Mac OS x