Configuring Apache in Mac

Source: Internet
Author: User

The Mac version used is 10.10.1,MAC's own Apache environment

is divided into two parts:

1. Start Apache

2. Setting up a virtual host

Launch Apache

Open the terminal,

>>sudo Apachectl-v, if there is a machine password will need to enter the password.

>>sudo apachectl start, which starts Apache

Verify that Apache is turned on and enter "http://localhost" in the browser, such as "It works" on the page, which is the success. It is located under/library/webserver/documents.

The Apache installation directory is hidden by default in/etc/apache2,etc and can be viewed at the terminal input open/etc.

Set up a virtual host

>>sudo vi/etc/apache2/httpd.conf, open Apache configuration file

>> find "#include/private/etc/apache2/extra/httpd-vhosts.conf", remove "#", Save exit.

>>sudo apachectl Restart, restart Apache service, turn on virtual host configuration function

>>sudo vi/etc/apache2/extra/httpd-vhosts.conf, to open the configuration of the virtual host file httpd-vhosts.conf, it is important to note that the file has been opened by default two as an example of a virtual host

In fact, these two virtual hosts are nonexistent and may cause access to localhost when no other virtual host is configured: Forbidden,you don ' t has permission to access/index.php on this Server

The simplest way is to comment them out.

Add the following configuration:

<VirtualHost*:80>

     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 *:80>      DocumentRoot "/Users/erao/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 allRequire All granted        </ Directory > </ VirtualHost >

Note that the documentroot, need to write the hostname of the machine, but also to create a good work folder in advance.

Require all granted, otherwise no matter how access is 403.

Keep exiting and restart Apache service

>>sudo vi/etc/hosts, open the hosts configuration file, add "127.0.0.1 mysites", so you can configure sites virtual host, access to "http://mysites" can.

The error log is placed in the/private/var/log/apache2/sites-error_log.

Reference to: http://www.cnblogs.com/snandy/archive/2012/11/13/2765381.html#;

http://ylw6006.blog.51cto.com/470441/965119

Configuring Apache in 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.