首页 > 其他 > 详细

nginx 配置

时间:2014-03-07 00:12:43      阅读:514      评论:0      收藏:0      [点我收藏+]

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

nginx 配置,布布扣,bubuko.com

nginx 配置

原文:http://wyj0605.blog.51cto.com/651120/1369397

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!