1.安装Nginx,搭建环境
Selilnux , iptables 关掉
yum -y groupinstall "开发工具" yum -y install gcc gcc-c++ pcre pcre-devel openssl openssl-devel
tar -zxf nginx-1.8.0.tar.gz cd nginx-1.8.0useradd -s /sbin/nologin nginx./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_modulemake && make install
ls /usr/local/nginx/
conf配置文件存放目录
html 网页目录 (/var/www//html)
logs 日志文件存放目录
sbin 存放启动nginx进程的命令
2.启动nginx进程(默认监听80端口)
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf [root@squid nginx]# netstat -anptu |grep :80tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
/usr/local/nginx/sbin/nginx -v 查看nginx版本
/usr/local/nginx/sbin/nginx -V 查看编译参数
/usr/local/nginx/sbin/nginx -t 测试默认配置文件
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx1.conf 备份nginx的配置文件
/usr/local/nginx/sbin/nginx -s stop
终止nginx进程 的方法
kill -9 pid号
pkill -9 nginx
TERM,INT 快速关闭
QUIT 从容关闭,关闭主进程及子进程
HUP 重载配置文件
USR1 重新打开日志文件
USR2 平滑升级可执行程序
kill -HUP `cat /usr/local/nginx/logs/nginx.pid ` (重载配置文件)
/usr/local/nginx/sbin/nginx (开启nginx)
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (开启nginx)
/usr/local/nginx/sbin/nginx -t /usr/local/nginx/conf/nginx.conf (测试nginx)
kill `cat /usr/local/nginx/logs/nginx.pid` (关闭nginx,杀死nginx进程)
/usr/local/nginx/sbin/nginx -s stop (关闭nginx)
3.平滑升级nginx软件的版本(可以在比关闭nginx服务的情况下进行平滑升级)
tar -zxf nginx-1.9.2.tar.gzcd nginx-1.9.2 /usr/local/nginx/sbin/nginx -V./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_modulemakemv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/oldnginxcp objs/nginx /usr/local/nginx/sbin/ /usr/local/nginx/sbin/nginx -vmake upgrade/usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfulkill -USR2 `cat /usr/local/nginx/logs/nginx.pid`sleep 1test -f /usr/local/nginx/logs/nginx.pid.oldbinkill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin` /user/local/nginx/sbin/nginx -t/usr/local/nginx/sbin/nginx -v
测试:
客户端查看 指定端口8080
elinks --dump http://nginx服务器的ip:8080/test.html