天天看点

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

继续阅读