phpstudy配置虚拟目录

1. nginx配置访问:

    A. 打开D:\phpstudy\nginx\conf\nginx.conf , 

server {
        listen       80;   //监听端口
        server_name  www.aaa.com;    //访问URL
 
        root    "D:/phpstudy/PHPTutorial/WWW/AAAA/";  //项目目录, 注意一定要用'/', 也要用'/'结尾
        location / {
            index  index.html index.htm index.php l.php;
           autoindex  off;
        }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}


server {
        listen       8081;
        server_name  www.bbb.com;
 
        root    "D:/phpstudy/PHPTutorial/WWW/BBB/";
        location / {
            index  index.html index.htm index.php l.php;
           autoindex  off;
        }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

   B. 打开C:\Windows\System32\drivers\etc\hosts, 写入url

0.0.0.0 account.jetbrains.com
0.0.0.0 www.jetbrains.com

# localhost name resolution is handled within DNS itself.


127.0.0.1 localhost
::1 localhost

127.0.0.1    www.aaa.com
127.0.0.1    www.bbb.com

   C. 访问,80是默认端口, 不需要写, 其他需要加上:

        http://www.aaa.com

        http://www.bbb.com:8081/index.php/admin/adduser

 

2. apache配置

     A. 打开D:\phpStudy\Apache\conf\httpd.conf ,

216行  ServerName localhost  注释掉
470行  Include conf/extra/httpd-vhosts.conf 去掉注释

     B. 打开D:\phpStudy\Apache\conf\extra\httpd-vhosts.conf,


DocumentRoot "/Apache24/htdocs"
#ServerName www.example.com:80


//可以访问localhost

DocumentRoot "D:\phpStudy\WWW"
ServerName   localhost


//可以访问127.0.0.1

DocumentRoot "D:\phpStudy\WWW"
ServerName   127.0.0.1




 DocumentRoot "D:\phpStudy\WWW\tpshop5.0"
 ServerName www.tpshop5.com

   C. 打开对应版本php.ini,

937行 date.timezone 改为
date.timezone = PRC

   D. 打开C:\Windows\System32\drivers\etc\hosts,

0.0.0.0 account.jetbrains.com

127.0.0.1       localhost
127.0.0.1       www.tpshop5.com

   E. 浏览器访问www.tpshop5.com即可

* 也可以直接在PHPstudy中站点域名管理中添加, 更方便

你可能感兴趣的:(phpstudy配置虚拟目录)