nginx 配置

vim /etc/ld.so.conf針對pcre.os.01 錯誤,重新包含LIB庫文件

/usr/local/lib

ldconfig  重載LIB庫

lsof -i :80 根據端口反查服務軟件

wget 127.0.0.1

egrep -v "#|^$" nginx.conf > nginx.conf.tmp去掉註釋和空行
cat -n nginx.conf

vim nginx.conf

user nginx nginx

worker_processes  8;
events {
    use epoll
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhosti www.wyj.org;
        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

mkdir /data0/www/{www,bbs,blog} -p 批量創建目錄

for n in www blog bbs; do echo "$n" >/data0/www/$n/index.html;done 批量創建index.html

chown -R nginx.nginx /data0/www

mkdir /app/log/ -p

../sbin/nginx -t  檢查配置文件是否有錯誤。

nginx: the configuration file /application/nginx-1.4.5/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.4.5/conf/nginx.conf test is successful

../sbin/nginx -s reload  平滑重啓

操作完後,要檢查。

%system%\system32\drivers\etc\hosts 修改指向文件

user nginx nginx;

worker_processes  8;
events {
    use epoll;
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

#   access_log  logs/access.log  main;

    server {
        listen       80;
        server_name  localhosti www.wyj.org;
        location / {
            root   /data0/www/www;
            index  index.html index.htm;
            access_log /app/log/www_access.log main;
    }
}
########

    server {
        listen       80;
        server_name  blog.wyj.org;
        location / {
            root   /data0/www/blog;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
}

}

}

include extra/nginx_vhost.conf; 採用虛擬主機包含的方式,更加靈活的配置網站

2.1
增加新的實例

1,複製一份新的配置文件並改名
cp -a conf cmsconf
2.配置新的虛擬主機(注意不要和其它實例的衝突)

../../sbin/nginx -c /application/nginx/cmsconf/nginx.conf -t 檢查語法

會有衝突,改變端口

    server {
        listen       880;
        server_name  www.cms.org;
        location / {
            root   /data0/www/cms;
            index  index.html index.htm;
            access_log /app/log/cms_access.log main;
    }
不想改變端口的情況 下,增加IP
ifconfig eth0:247 192.168.0.247 up
listen 192.168.0.247:80

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章