Apache
具体的步骤如下:
点击其它选项菜单----->选择站点域名管理。如下图
初始的时候,站点可能为空。然后你可以在网站域名里填上域名,网站根目录为你项目的根目录,有需要的话,也可以设置第二域名,网站端口可以自己设置,通常为80。设置完毕后,点击添加,左侧就会出现所添加的域名。然后点击保存设置并生成默认文件。
作为例子,我添加的内容为:
-
网站域名:www.beyong.com
-
根目录:D:\phpStudy\WWW\test (注意,网站域名不是一定要和项目名一样,但在最好一样。test就是项目文件夹)
-
第二域名:www.test.com
-
网站端口:80
保存设置之后,phpstudy会自动重启。
这时,还得修改hosts文件,同样点击其它选项菜单---->打开hosts
或者:C:\Windows\System32\drivers\etc 下也可以找到hosts文件
你会看到这样的内容,我截了一部分图
这时,你只需要在末尾添加一行,内容为 127.0.0.1 设置的域名,,,注意前面的#号代表注释,所以不要加#
如我根据我的设置,添加如下内容,结果如图
然后保存,这时成功了
Nginx
找到nginx安装目录
phpstudy的nginx目录:phpStudy\PHPTutorial\nginx\conf下面打开nginx.conf这个配置文件
新建 server 配置选项
server {
listen 80;
server_name www.beyong.com;
#charset koi8-r;
#access_log logs/host.access.log main;
root "D:/phpStudy/PHPTutorial/WWW/test";
location / {
index index.html index.htm index.php l.php;
autoindex off;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
server {
listen 80;
server_name www.test.com;
#charset koi8-r;
#access_log logs/host.access.log main;
root "D:/phpStudy/PHPTutorial/WWW/test";
location / {
index index.html index.htm index.php l.php;
autoindex off;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}