天天看點

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 {

    }

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;

    use epoll;

    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;

            root   /data0/www/www;

            access_log /app/log/www_access.log main;

########

        server_name  blog.wyj.org;

            root   /data0/www/blog;

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

2.1

增加新的執行個體

1,複制一份新的配置檔案并改名

cp -a conf cmsconf

2.配置新的虛拟主機(注意不要和其它執行個體的沖突)

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

會有沖突,改變端口

        listen       880;

        server_name  www.cms.org;

            root   /data0/www/cms;

            access_log /app/log/cms_access.log main;

不想改變端口的情況 下,增加IP

ifconfig eth0:247 192.168.0.247 up

listen 192.168.0.247:80

繼續閱讀