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;
#}
}