1. 程式人生 > >web站點放在nginx其他目錄下

web站點放在nginx其他目錄下

web站點放在nginx其他目錄下

1、檢視主配置檔案

[[email protected] mysql]# cat /etc/nginx/nginx.conf
user root root;
worker_processes  1;
events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" 
' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; server { listen 80; server_name www.test.com; charset utf-8; location / { root /var/www/www.test.com; index index.php index.html index.htm; } location
~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/www.test.com$fastcgi_script_name; include fastcgi_params; } } include /etc/nginx/conf.d/*.conf; } 2、建立其他目錄放入靜態檔案 注意:靜態檔案必須是index.html 其他的不行 [
[email protected]
~]# mkdir /website/ [[email protected] ~]# cd /website/ [[email protected] website]# echo hello >> index.html [[email protected] website]# ls index.html [[email protected] website]# cat index.html hello 3、配置子配置檔案 [[email protected] ~]# cat /etc/nginx/conf.d/test1.conf server { listen 8083; server_name www.test1.com; charset utf-8; location / { root /website; index index.php index.html index.htm; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /website$fastcgi_script_name; include fastcgi_params; } } 4、重新載入nginx [[email protected] conf.d]# nginx -s reload 5、訪問測試 [[email protected] conf.d]# curl
http://127.0.0.1:8083 hello