Linux安装nginx操作

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/liqingwei168/article/details/87805703

说明:本文章只做具体安装操作,必要的时候会做简单的说明。

操作前准备:

      1.确认是否安装nginx依赖的数据库。下面是存在的。

如果不存在(个人建议使用a方法安装依赖库),Nginx的安装包:下载地址为:http://nginx.org/en/download.html

          a.可以  执行安装命令  yum -y install gcc pcre-devel zlib-devel openssl openssl-devel

          b.同时也可以去到网站去下载:

               SSL功能需要openssl库,下载地址:http://www.openssl.org/

     gzip模块需要zlib库,下载地址:http://www.zlib.net/

     rewrite模块需要pcre库,下载地址:http://www.pcre.org/

             三个依赖库安装都一样,以openssl库为例子:

              tar -zxvf  soft/openssl-SNAP-20160104

    cd openssl-SNAP-20160104/

    ./config

    make

    make install

     2.如果前期人都准备完成,那么开始了     本次安装的是nginx-1.13.8.tar.gz

## 解压
tar -zxvf nginx-1.13.8.tar.gz

##进入nginx目录
cd nginx-1.13.8
## 配置
./configure --prefix=/usr/local/nginx

# make
make
make install

执行make、make install命令

测试是否安装成功

# 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 700 logs

正常情况的信息输出:

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

-------------------下面的问题我没有遇到,是看别人的博客,也总结在里面了,希望对你有所帮助-------------------

在浏览器中输入服务器的ip地址,如:192.168.1.12

很不幸,打不开链接。下面进行原因排查:

    

    

说明服务器的80端口是打不开的。

因为我使用的linux系统版本是CentOS7,所以可以在服务器中执行如下命令来验证》》

firewall-cmd --query-port=80/tcp

    

显然80端口没有开启。

下面我们开启80端口:

firewall-cmd --add-port=80/tcp --permanent
#重启防火墙
systemctl restart firewalld

 --permanent   #永久生效,没有此参数重启后失效

   

刷新浏览器

    

到此,关于nginx的简单安装已经完成。。。。。。。。。。。。。。。。

每天总结一点点。。。。。。。

猜你喜欢

转载自blog.csdn.net/liqingwei168/article/details/87805703