以下配置的(de)路(lu)徑以阿(a)里云提供的(de)標(biao)準環境路(lu)徑為準,如果您另行安裝(zhuang),請根據實際(ji)安(an)裝路徑去(qu)找(zhao)到您的配置文件進行配置。
假如我們需(xu)要在我們的(de)網站和一個test.com的(de)域名,請進行(xing)如下(xia)類似的(de)操作:
1.cd /alidata/server/nginx/conf/vhosts/ 找到您的網站配(pei)置文件,一般是(shi)您的域(yu)(yu)名.conf,例如域(yu)(yu)名是(shi):,那就應該是。
2.vim 修改這個配(pei)置文(wen)件,您應(ying)該(gai)會看到(dao)如下類似的配(pei)置內容(rong):
server {
listen 80;
server_name www.test.com;
root /www/web/www_test_com/public_html;
index index.php;
error_page 400 /errpage/400.html;
error_page 403 /errpage/403.html;
error_page 404 /errpage/404.html;
location ~ \.php$ {
proxy_pass //127.0.0.1:88;
include naproxy.conf;
}
location / {
try_files $uri @apache;
}
location @apache {
proxy_pass //127.0.0.1:88;
include naproxy.conf;
}
access_log /www/web_logs/www.test.com_access.log wwwlogs;
error_log /www/web_logs/www.test.com_error.log;
}
3.點擊(ji)字母(mu)“i”開始編輯文件(jian),輸入內容:
server {
listen 80;
server_name www.test.com test.com m.test.com;
root /www/web/www_test_com/public_html;
index index.php;
error_page 400 /errpage/400.html;
error_page 403 /errpage/403.html;
error_page 404 /errpage/404.html;
location ~ \.php$ {
proxy_pass //127.0.0.1:88;
include naproxy.conf;
}
location / {
try_files $uri @apache;
}
location @apache {
proxy_pass //127.0.0.1:88;
include naproxy.conf;
}
access_log /www/web_logs/www.test.com_access.log wwwlogs;
error_log /www/web_logs/www.test.com_error.log;
}
其中:
ServerName www.test.com test.com m.test.com;綁定(ding)的網(wang)站域(yu)名(您(nin)如(ru)果(guo)有(you)多個域(yu)名添加在這里)
index index.php; 設置(zhi)默認首頁
root /www/web/www_test_com/public_html; 是指定網站的(de)目(mu)錄。
按“esc”退出編輯模式,輸入“:wq”保存退出。
4.輸入命令:nginx –s reload 重啟(qi)nginx測試。
5.測試網站。請在(zai)瀏覽器中輸入域名(ming),測試設置。
會員評論