19
2019
06

linux下安装nginx

安装nginx 

nginx-1.13.9

下载地址:http://nginx.org/download/nginx-1.13.9.tar.gz

[root@localhost ~]# wget http://nginx.org/download/nginx-1.13.9.tar.gz

解压

[root@localhost ~]# tar -zxvf nginx-1.13.9.tar.gz

进入目录

[root@localhost ~]# cd  nginx-1.13.9

编译

[root@localhost nginx-1.13.9]# ./configure

注意:这时候报错了

checking for OS + Linux 3.10.0-693.el7.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

这时候我们就要百度一下了,百度得知我们少一个gcc编译器 可以这么去安装 yum -y install gcc-c++

[root@localhost nginx-1.13.9]# yum -y install gcc-c++

一大堆的提示......

再次编译

./configure

提示错误,我们需要一些安装库

[root@localhost nginx-1.13.9]# yum install -y pcre pcre-devel
[root@localhost nginx-1.13.9]# yum install -y zlib zlib-devel
[root@localhost nginx-1.13.9]# yum install -y openssl openssl-devel

再次编译

./configure

安装

[root@localhost nginx-1.13.9]# make && make install

 

设置开机自启动

[root@localhost nginx-1.13.9]# vi /etc/rc.local

添加一句

/usr/local/nginx/sbin/nginx

授权保存

[root@localhost nginx-1.13.9]# chmod 755  /etc/rc.local

进入启目录

[root@localhost nginx-1.13.9]# cd  /usr/local/nginx/sbin/
[root@localhost sbin]# ./nginx

启动

浏览器访问192.168.2.80(服务器外网ip),ok

补充:如果安装失败有异常 到官网下载版本 有稍微改动 比如警告异常

安装完成后 如果没有效果 或者 kill不掉 重载下配置


/usr/local/nginx/sbin/nginx -c /usr/localnginx/conf/nginx.conf
./nginx -s reload



参考:http://www.cnblogs.com/songfahzun/p/8490729.html


« 上一篇 下一篇 »