Detailed introduction to the Mac OS Apache configuration method

Source: Internet
Author: User

The version of Mac OS X I'm using is 10.8.2,mac comes with an Apache environment.
Launch Apache
Set up a virtual host

launch Apache
Open terminal (terminal), enter sudo apachectl-v, (you may need to enter the machine secret). The Apache version is shown below

Then enter sudo apachectl start so that Apache starts up. Open Safari Browser address bar Enter "http://localhost", you can see the content "It works!" The page. It is located under/library (Resource Library)/webserver/documents/, which is the default root directory for Apache.
The installation directory for Apache is:/etc/apache2/,etc is hidden by default. There are three ways of viewing:
1.dock Right-click Finder, select "Go to Folder", enter "/etc"
2. In the Finder-----Go to the folder and enter/etc
3. You can enter "OPEN/ETC" in terminal

set up a virtual host
1. Run "sudo vi/etc/apache2/httpd.conf" on the terminal to open the Apche configuration file
2. Find "#Include/private/etc/apache2/extra/httpd-vhosts.conf" in httpd.conf, remove the "#" from the front and save and exit.
3. Run "sudo apachectl restart" to restart Apache and turn on the virtual host Configuration feature.
4. Run "sudo vi/etc/apache2/extra/httpd-vhosts.conf", open the configuration virtual host file httpd-vhost.conf, configure the virtual host. It is important to note that the file is enabled by default for two virtual hosts as an example:

5. Add the following configuration

<virtualhost *: the>DocumentRoot"/library/webserver/documents"ServerName localhost errorlog"/private/var/log/apache2/localhost-error_log"Customlog"/private/var/log/apache2/localhost-access_log"Common</VirtualHost> <virtualhost *: the>DocumentRoot"/users/snandy/work"ServerName mysites errorlog"/private/var/log/apache2/sites-error_log"Customlog"/private/var/log/apache2/sites-access_log"Common<directory/>Options Indexes followsymlinks multiviews allowoverride None Order deny,allow allow from All</Directory> </VirtualHost>

Save the exit and restart Apache.
6. Run "sudo vi/etc/hosts", open the Hosts configuration file, add "127.0.0.1 mysites", so you can configure the completion sites virtual host, can access "http://mysites", before 10.8 mac OS The x version has exactly the same content as the "http://localhost/~[user name".
7. Note that the log "errorlog"/private/var/log/apache2/sites-error_log "" can also be deleted, but logging is actually a good habit, in the event of a problem can help us to judge. If you keep these log code, a certain log file path is present, if you arbitrarily modify a non-existent, will cause Apache can not service without error prompts, this is more disgusting.

Detailed introduction to the Mac OS Apache configuration method

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.