1、首先执行:
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
2、下载安装nginx:
nginx下载地址:https://nginx.org/download/
下载完成后解压文件(最好新建一个文件夹,把下载的压缩包放置到这个文件夹再解压)
我这里是在/usr下新建的了个myngnix文件夹
tar -zxvf nginx-1.9.9.tar.gz
3、进入安装好的nginx目录:
cd nginx-1.9.9
4、配置
./configure --prefix=/usr/local/nginx
5、执行make 命令
6、make 完成后 再执行make install
7、cd到刚刚配置的目录
cd /usr/loca/nginx/
./sbin/nginx -t
9、如果成功则会输出:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
10、启动ngnix
cd /usr/local/nginx/sbin
./nginx
中途可能会出现的异常:
错误信息:
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2016/09/13 19:08:56 [emerg] 6996#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)
原因分析:nginx/目录下没有logs文件夹 去nginx/目录下执行下面的命令就OK了
解决方法:
mkdir logs
chmod 700 logs