1、安装Nginx所需的pcre包和openssl-devel包
yum install pcre pcre-devel -y yum install openssl openssl-devel -y 或者 wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz tar zxf pcre-8.30.tar.gz cd pcre-8.30 ./configure make make install
安装完检查结果
rpm -qa pcre pcre-devel rpm -qa openssl openssl-devel
2、开始安装Nginx
cd /home/chenct/tools wget useradd nginx -s /sbin/nologin -M tar zxf nginx-1.2.9.tar.gz cd nginx-1.2.9 ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.2.9 --with-http_stub_status_module --with-http_ssl_module make && make install ln -s /application/nginx-1.2.9 /application/nginx ll /application/nginx
3、启动Nginx
启动前检查配置文件语法
/application/nginx/sbin/nginx -t
启动Nginx服务
/application/nginx/sbin/nginx
4、检查是否启动成功
查看Nginx对应服务端口是否启动成功
[root@chonter ~]# lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 1893 root 6u IPv4 12136 0t0 TCP *:http (LISTEN) nginx 1894 nginx 6u IPv4 12136 0t0 TCP *:http (LISTEN) You have new mail in /var/spool/mail/root
[root@chonter ~]# netstat -lnt|grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
浏览器输入ip地址
LINUX下可通过wget 192.168.10.109命令检测是否启动成功
[root@chonter ~]# wget 192.168.10.109 --2017-04-27 13:58:57-- http://192.168.10.109/ 正在连接 192.168.10.109:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:612 [text/html] 正在保存至: “index.html.2” 100%[================================================================>] 612 --.-K/s in 0s 2017-04-27 13:58:57 (66.5 MB/s) - 已保存 “index.html.2” [612/612])
用curl命令检测
[root@chonter ~]# curl 192.168.10.109 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
本文参考书籍:跟老男孩学Linux运维-WEB集群实战