Configuring Apach services under Mac

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.