Install and configure the Apache server on Mac OS X

Source: Internet
Author: User

Install and configure the Apache server on Mac OS X

Note: When the Mac system is installed, it has its own Apache server. Next, it is configured and started to run. The next thing to do is:

1. Configure the apache configuration file
2. Set Virtual Hosts
Start and view apache

Open the terminal and enter the following command:

$ Sudo apachectl start
$ Sudo apachectl-v
Configure the apache main configuration file

The main configuration file of apache is in the path/etc/apache2 /.

Back up the original file first
$ Sudo cp/etc/apache2/httpd. conf/etc/apache2/httpd. conf. backup
Modify the main configuration file
$ Vi/etc/apache2/httpd. conf
To facilitate reference to the default configuration, I will comment out the modified items as follows:

...
<Directory/>
# AllowOverride none
# Require all denied
Require all granted
AllowOverride all
</Directory>
...

# Virtual hosts
# Include/private/etc/apache2/extra/httpd-vhosts.conf
Include/private/etc/apache2/extra/httpd-vhosts.conf
...

Ps: in some old versions of configuration, allow can find many tutorials on the Internet, so I will not explain them here.
Set VM

The default apache root directory is under/Library/WebServer/. After the virtual host is configured, you can ignore the default website root directory, create different website directories in the appropriate places as needed.

Modify the httpd-vhosts.conf file at/etc/apache2/extra.

Back up original files
$ Sudo cp/etc/apache2/extra/httpd-vhosts.conf/etc/apache2/extra/httpd-vhosts.conf.backup

$ Sudo vi/etc/apache2/extra/httpd-vhosts.conf
Set the virtual host (the local access domain name of this site is mysite. local, and the root directory is/var/wwwroot/abc)
...
<VirtualHost *: 80>
ServerAdmin webmaster@mysite.local
DocumentRoot "/var/wwwroot/abc"
ServerName mysite. local
ErrorLog "/private/var/log/apache2/mysite. local-error_log"
CustomLog "/private/var/log/apache2/mysite. local-access_log" common
</VirtualHost>
...
Modify the hosts file at/etc/

$ Sudo vi/etc/hosts
Bind a custom domain name to 127.0.0.1
...
127.0.0.1 localhost mysite. local
...
Restart the Apache server

Sudo apachectl restart

This article permanently updates the link address:

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.