Linux系统下安装nginx

linux下安装nginx【https://www.cnblogs.com/xxoome/p/5866475.html】

Linux的版本【CentOS7 64位】

1、在安装nginx前首先要确认系统中安装了gcc、pcre-devel、zlib-devel、openssl-devel

Linux下检查是否安装过某软件包:http://www.cnblogs.com/xxoome/p/5866553.html

安装命令:

yum -y install gcc pcre-devel zlib-devel openssl openssl-devel

2、下载nginx安装包

wget http://nginx.org/download/nginx-1.12.2.tar.gz

3、解压安装包

tar -zxvf nginx-1.12.2.tar.gz

4、进入nginx目录

cd nginx-1.12.2

5、执行配置

/configure --prefix=/usr/local/nginx

6、编译安装(默认安装在/usr/local/nginx)

make&&makeinstall

7、测试是否安装成功

# cd到刚才配置的安装目录/usr/loca/nginx/

执行 ./sbin/nginx -t

错误信息

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文件夹

解决方法

mkdir logs

chmod 700logs

正常情况的信息输出:

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

启动nginx 

cd /usr/local/nginx/sbin

./nginx//启动nginx

你可能感兴趣的:(Linux系统下安装nginx)