系统环境
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.10 (Final)
[root@localhost ~]# uname -r
2.6.32-642.el6.x86_64
1.安装pcre源
[root@localhost ~]# yum -y install pcre pcre-devel
[root@localhost ~]# rpm -qa pcre pcre-devel
pcre-devel-7.8-7.el6.x86_64
pcre-7.8-7.el6.x86_64
2.检查nginx基础依赖包 pcre-devel,openssl-devel
[root@localhost ~]# rpm -qa pcre pcre-devel
pcre-devel-7.8-7.el6.x86_64
pcre-7.8-7.el6.x86_64
[root@localhost ~]# rpm -qa openssl openssl-devel
openssl-devel-1.0.1e-57.el6.x86_64
openssl-1.0.1e-57.el6.x86_64
缺少哪个包可以用yum安装
3.安装nginx
1)下载nginx-1.6.3
[root@localhost tools]# cd /tools/ #进入程序专用目录
[root@localhost tools]# wget -q http://nginx.org/download/nginx-1.6.3.tar.gz #下载1.6.3版本,如果链接不存在可能是版本已经更新,可以去官方地址nginx.org下载
[root@localhost tools]# ll
total 788
-rw-r--r--. 1 root root 805253 Apr 7 2015 nginx-1.6.3.tar.gz
2)创建nginx用户
[root@localhost tools]# useradd nginx -s /sbin/nologin -M
3)解压并编译安装
[root@localhost tools]# tar -zxf nginx-1.6.3.tar.gz
[root@localhost tools]# cd nginx-1.6.3
[root@web02 nginx-1.6.3]# ./configure \
> --prefix=/application/nginx-1.6.3 \
> --user=nginx \
> --group=nginx \
> --with-http_stub_status_module \ ##激活状态信息
> --with-http_ssl_module ##激活ssl
[root@localhost nginx-1.6.3]# make &&make install
4)创建软连接
[root@localhost nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx
4.启动并检查安装结果
[root@localhost nginx-1.6.3]# cd
[root@localhost ~]# /application/nginx/sbin/nginx -t #检查配置文件
nginx: the configuration file /application/nginx-1.6.3/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3/conf/nginx.conf test is successful
[root@localhost ~]# /application/nginx/sbin/nginx #启动nginx
[root@localhost ~]# lsof -i:80 #检查nginx默认端口80是否成功开启
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 67082 root 6u IPv4 210442 0t0 TCP *:http (LISTEN)
nginx 67083 nginx 6u IPv4 210442 0t0 TCP *:http (LISTEN)
[root@localhost ~]# wget 127.0.0.1
[root@localhost ~]# curl 127.0.0.1 #用linux命令检查是否启动成功
5.