Configure PHP and virtual machines for your Mac's own Apache

Source: Internet
Author: User

Reference Address:

Http://www.codesec.net/view/244646.html

Apache Related commands:
Start: sudo apachectl start
Stop: sudo apachectl stop
Restart: sudo apachectl restart
View version number: sudo apachectl-v

2. Add PHP Module

Enter command in terminal: sudo vi/etc/apache2/httpd.conf, open httpd.conf

Remove the comment ' # ' from the front of the PHP module and restart apache,php add success

3. Configure ' Mysites ' virtual machine

1. In the terminal input command: mkdir/users/your user name/sites, add this folder as the physical storage location for the ' mysites ' virtual machine.

2. Open the httpd.conf and remove the ' # ' in front of ' # include/private/etc/apache2/extra/httpd-vhosts.conf '.

3. Select DocumentRoot "/library/webserver/documents" <directory "/library/webserver/documents" > ... </Directory > Copy the contents to the bottom of it, modify the yellow area to "/users/your username/sites" and save the exit.

In the terminal input command: sudo vi/etc/apache2/extra/httpd-vhosts.conf, open httpd-vhosts.conf.

Note Two default virtual machines with ' # ' in front of each line

Next, add the following code, save the exit, restart Apache

# ' localhost ' virtual machine
<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>
# ' mysites ' virtual machine
<virtualhost *:80>
DocumentRoot "/users/Your user name/sites"
ServerName mysites
Errorlog "/private/var/log/apache2/mysites-error_log"
Customlog "/private/var/log/apache2/mysites-access_log" common
</VirtualHost>

In Terminal input command: sudo vi/etc/hosts, add "127.0.0.1 mysites", Save exit

In the terminal input command: sudo vi/users/your username/sites/info.php, add "<?php echo phpinfo ();?>", Save exit

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

Configure PHP and virtual machines for your Mac's own Apache

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.