Linux下安装nginx

环境:Linux CentOs版本,nginx版本:nginx-1.17.3

说明:若要安装nginx首先得确保Linux下拥有make  c编译器

1、安装make(也就是C编译器,若有则直接跳过)

1 yum -y install gcc automake autoconf libtool make
2 yum install gcc gcc-c++ 

2、安装pcre

1 cd /usr/local/src
2 wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz
3 tar -zxvf pcre-8.39.tar.gz 4 cd pcre-8.39 5 ./configure 6 make && make install

3、安装zlib

1 cd /usr/local/src
2 wget http://zlib.net/zlib-1.2.11.tar.gz
3 tar -zxvf zlib-1.2.11.tar.gz
4 cd zlib-1.2.11
5 ./configure
6 make && make install

4.安装openssl

1 cd /usr/local/src
2 wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
3 tar -zxvf openssl-1.0.1t.tar.gz

5、安装nginx(可以使用yum install命令进行安装,这里推荐yum 命令安装)

1 cd /usr/local/src
2 wget http://nginx.org/download/nginx-1.1.10.tar.gz
3 tar -zxvf nginx-1.1.10.tar.gz
4 cd nginx-1.1.10
5 ./configure
6 make && make install

6、启用nginx

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

注意:若没有任何提示表明启用成功,若启用失败,以下提供解决方案:

开放80端口firewall-cmd --zone=public --add-port=80/tcp --permanent

停止防火墙systemctl stop firewalld.service

启动防火墙systemctl start firewalld.service

  

原文地址:https://www.cnblogs.com/ByteBeat/p/12365480.html