Configure a domain name-based virtual host in xampp on mac OS
Source: Internet
Author: User
1. Run "sudo VI/XAMPP/etc/httpd. conf" on the terminal to open the configuration file of Apche.
2. Find "# include/XAMPP/etc/extra/httpd-vhosts.conf" in httpd. conf, remove the previous "#", save and exit.
3. After the apache service is restarted, its VM configuration function is enabled.
4. Run "sudo VI/XAMPP/etc/extra/httpd-vhosts.conf", and then open the file httpd-vhost.conf for configuring the VM and configure the VM you need. Note that two virtual hosts are enabled for this file by default:
<Virtualhost *: 80>
Serveradmin webmaster@dummy-host.example.com
DocumentRoot "/usr/docs/dummy-host.example.com"
Servername dummy-host.example.com
Errorlog "/private/var/log/apache2/dummy-host.example.com-error_log"
Customlog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</Virtualhost>
<Virtualhost *: 80>
Serveradmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/docs/dummy-host2.example.com"
Servername dummy-host2.example.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
In fact, these two virtual hosts do not exist. when no other virtual hosts are configured, the following prompt may appear when accessing localhost:
Forbidden
You don't have permission to access/index. php on this server
The simplest way is to add # in front of each line and comment it out, so that it can be referenced without causing other problems.
Add the following configuration
<VirtualHost *: 80>
ServerAdmin your@website.com
DocumentRoot "/Applications/XAMPP/htdocs/"
<Directory "/Applications/XAMPP/htdocs/a">
Options FollowSymLinks
AllowOverride all
Order allow, deny
Allow from all
</Directory>
ServerName your.website.com
ServerAlias your.website.com
ErrorLog "/Applications/XAMPP/htdocs/a/test_error_log"
CustomLog "/Applications/XAMPP/htdocs/a/test_access_log" common
</VirtualHost>
Note: you must add <Directory>, set options to FollowSymLinks, save and exit, and restart Apache.
5. run "sudo vi/etc/hosts", open the hosts configuration file, and add "127.0.0.1 your.website.com" to complete the sites VM configuration, in this way, you can access it with the http://your.website.com, its content is exactly the same as "http: // localhost. 6. But there is another problem, that is, the original localhost has been directed to another directory. You also need to direct the localhost directory back: <VirtualHost *: 80>
DocumentRoot "/Applications/xampp/htdocs /"
ServerName localhost
</VirtualHost>
This is all done!
Here I find a graphic tutorial, very good: http://www.cnblogs.com/heiniuhaha/archive/2011/10/14/2212478.html
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.