Configure PHP and virtual machines for Apache that comes with Mac

Source: Internet
Author: User
: This article describes how to configure PHP and virtual machines for Apache that comes with Mac. For more information about PHP tutorials, see. Operating system: OS x 10.11.2

1. start apache

Open the terminal and enter the command sudo apachectl-k start;

Enter http: // localhost in the address bar of the browser. if the following information is displayed, apache is started normally.

Apache commands: start: sudo apachectl start stop: sudo apachectl stop restart: sudo apachectl restart View version: sudo apachectl-v

2. add the PHP module

Enter the command sudo vi/etc/apache2/httpd. conf in the terminal to open httpd. conf.

Remove the comment '#' in front of the PHP module, restart apache, and add php successfully.

3. configure the 'myusers' virtual machine

1. enter the command mkdir/Users/your user name/Sites on the terminal and add this folder as the physical storage location of the 'myusers' virtual machine.

2. open httpd. config and remove"# Include/private/etc/apache2/extra/httpd-vhosts.conf "in front '#'.

3. select DocumentRoot "/Library/WebServer/Documents" ... And copy the content to the bottom of it. modify the yellow area to "/Users/your username/Sites", save and exit.

Enter the command in the terminal: sudo vi/etc/apache2/extra/httpd-vhosts.conf to open the httpd-vhosts.conf.

Comment out two default virtual machines, and add '#' before each line '#'

Next, add the following code, save and exit, and restart apache.

# 'Localhost' virtual machine
 
  
DocumentRoot "/Library/WebServer/Documents" ServerName localhost ErrorLog "/private/var/log/apache2/localhost-error_log" CustomLog "/private/var/log/apache2/localhost-access_log" common
 # 'Myusers' virtual machine
 
  
DocumentRoot "/Users/your username/Sites" ServerName mysites ErrorLog "/private/var/log/apache2/mysites-error_log" CustomLog "/private/var/log/apache2/mysites-access_log" common
 

Run the following command on the terminal: sudo vi/etc/hosts, add "127.0.0.1 mysites", save and exit

Enter the command in the terminal: sudo vi/Users/your username/Sites/info. php, and add" ", Save and exit

Enter http: // mysites/info. php in the browser

This is the end. thank you for reading!

Written in 2016.1.12

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

The above describes how to configure PHP and virtual machines for Apache that comes with Mac, including some content, and hope to help friends who are interested in PHP tutorials.

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.