Under Windows configuration
1. Locate the Apache configuration file, Httpd.conf2. Find LoadModule rewrite_module modules/mod_rewrite.so Remove the front of the #. Find the Include conf/extra/ Httpd-vhosts.conf Remove the front of the # #. Find conf/extra/httpd-vhosts.conf this file 5. Add Namevirtualhost *:80<virtualhost *:80> ServerAdmin[email protected]#管理邮箱 documentroot "d:/phpstudy/www" #工作目录, i.e. code location ServerName www.excel.com #虚拟域名 Error Error log Customlog "Logs/dummy-host2.example.com-access.log" in Log "Logs/dummy-host2.example.com-error.log"//apache Common</virtualhost>6. Find <directory "d:/phpstudy/www" >----working directory in httpd.conf Options +indexes +followsymlinks +execcgi
AllowOverride All
Order Allow,deny
Allow from all---------access rights
Require all granted</directory>7. In the hosts (Windows directory C:\Windows\System32\drivers\etc) plus 127.0.0.1 www.excel.com #指向虚拟域名8. Restart Apache to access the files under the WWW directory to see the effect of MAC Nginx configuration virtual Host 1. Open/usr/local/etc/nginx/nginx.conf Note permission, open with sudo vi nginx.conf 2. Add the include vhosts/*.conf to HTTP and, if so, ignore it, and you can do the third step of 3. In the/usr/local/etc/nginx/vhosts directory, create a new file, end with. com.conf, say baidu.com.conf, it's best to name yourself here, because we can configure many virtual hosts in this directory, A file is a virtual host 4.sudo VI xx.com.conf 5. Watch out for the red spots, upstream.Baidu (same as file name )) {Server127.0.0.1:80; #自己的ip及端口}
server {Listen 80; CharSet Utf-8; server_name www.baidu.com; #虚拟主机名#access_log Logs/apicloud-access.log; #error_log Logs/apicloud-error.log; Root/users/www; #代码存放目录if ($http _cookie ~* "(. *) $")
{
Set $meilishuo _cookie $;
}
Location/{
Index index.php;
if (!-e $request _filename) {
Rewrite ^ (. *) $/index.php last;
}
}
Try_files $uri/index.php $args;
#location/index.php {
Location ~* \.php$ {
Fastcgi_pass Apicloud;
Fastcgi_next_upstream error timeout Invalid_header http_500;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include fastcgi.conf;
}} 6. With the hosts, open/etc/hosts, with the command sudo vi/etc/hosts7. Plus DNS resolution 127.0.0.1 WWW.BAIDU.COM8. Restart Nginx (sudo pkill-9/usr/local/opt/nginx/bin restart command sudo nginx/usr/local/opt/ng Inx/bin)then access the corresponding directory/users/www PHP file can be
Configure virtual hosts separately under Windows and Mac