源码安装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