Nginx-1.6.3源码安装、虚拟主机

源码安装nginx

cat /etc/redhat-release
uname -rm
yum install pcre-devel openssl-devel -y
rpm -qa pcre pcre-devel openssl openssl-devel
groupadd -g 888 nginx
useradd nginx -u 888 -g nginx -s /sbin/nologin -M
mkdir -p /server/tools
cd /server/tools
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3 --with-http_stub_status_module --with-http_ssl_module
make
make install
ln -s /application/nginx-1.6.3 /application/nginx
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx
ps -ef | grep nginx
lsof -i :80 
curl 10.0.0.41

虚拟主机配置

cd /application/nginx-1.6.3/conf/
egrep -v "^$|#" nginx.conf.default > nginx.conf
mkdir extra
mkdir ../html/{www,blog,bbs}
chown -R nginx.nginx ../html
vim nginx.conf

worker_processes  1;
error_log logs/error.log error;
events {
    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"';
    include extra/www.conf;
    include extra/blog.conf;
    include extra/bbs.conf;
    include extra/status.conf;
}

vim extra/www.conf

server {
        listen       80;
        server_name  www.peterwang.com;
        root html/www;
        index index.html index.htm;
        error_page   500 502 503 504  /50x.html;
        access_log logs/access_www.log main;
        location / {
        
        }
    }

vim extra/blog.conf

server {
        listen       80;
        server_name  blog.peterwang.com;
        root html/blog;
        index index.html index.htm;
        error_page   500 502 503 504  /50x.html;
        access_log logs/access_blog.log main;        
        location / {
        
        }
    }

vim extra/bbs.conf

server {
        listen       80;
        server_name  bbs.peterwang.com;
        root html/bbs;
        index index.html index.htm;
        error_page   500 502 503 504  /50x.html;
        access_log logs/access_bbs.log main;
        location / {
        
        }
    }

vim extra/status.conf

server {
        listen       80;
        server_name  status.peterwang.com;
        location / {
        stub_status on;
        access_log off;
        allow 10.0.0.0/24;
        deny all;
        }
    }

../sbin/nginx -s reload

 

转载于:https://www.cnblogs.com/Peter2014/p/7512449.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值