Nginx installation of Alibaba cloud server Centos7.0

Keywords: Nginx iptables zlib OpenSSL

Alibaba cloud server, operating system CentOS 7.0, installs nginx.

1. First, set alicloud's security group settings and open the 80 port limit:

Open Alibaba cloud official website > console > ECS > Security Group > security group rules:

Select any rule column, click "clone", select "HTTP(80)" for "protocol type" on the pop-up page, enter "priority" 60, and click finish

2. Set the limit of opening port 80 in the firewall of linux

The firewall of CentOS 7.0 is firewalld, and most people are used to iptables. Turn off firewalld here to install iptables

#Stop firewalld service
systemctl stop firewalld

#After stopping, execute the following command to disable
systemctl disable firewalld

#Install iptables
yum install -y iptables-services
#Start iptables
systemctl start iptables

#New restrictions on opening 80 ports 
vi /etc/sysconfig/iptables
#Add the following sentence to COMMIT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
#Save exit refresh iptables configuration
iptables-save > /etc/sysconfig/iptables
#View the rules of iptables
iptables -L
#See accept TCP -- anywhere Anywhere state new TCP DPT: http indicates success

#Set iptables startup
systemctl enable iptables.service
3. Install nginx

1.install PCRE library

$ cd /usr/local/
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
$ tar -zxvf pcre-8.36.tar.gz
$ cd pcre-8.36
$ ./configure
$ make
$ make install
2.install zlib library

$ cd /usr/local/ 
$ wget http://zlib.net/zlib-1.2.8.tar.gz
$ tar -zxvf zlib-1.2.8.tar.gz
$ cd zlib-1.2.8
$ ./configure
$ make
$ make install
3.install ssl

$ cd /usr/local/
$ wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
$ tar -zxvf openssl-1.0.1j.tar.gz
$ ./config
$ make
$ make install
4.install nginx

$ cd /usr/local/
$ wget http://nginx.org/download/nginx-1.8.0.tar.gz
$ tar -zxvf nginx-1.8.0.tar.gz
$ cd nginx-1.8.0  
#Note that the file path must be the path where pcre and zlib are installed
$ ./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.36 --with-zlib=/usr/local/zlib-1.2.8
$ make
$ make install

#start nginx 
$ /usr/local/nginx/sbin/nginx
#Restart:
$ /usr/local/nginx/sbin/nginx –s reload
#stop it:
$ /usr/local/nginx/sbin/nginx –s stop

#Test whether the configuration file is normal:
$ /usr/local/nginx/sbin/nginx –t
#The configuration file for nginx is located at
/usr/local/nginx/conf/nginx.conf

#Enter the public IP to access
#If the access error is reported, the nginx log is in the
/usr/local/nginx/logs/


Reference: https://www.jianshu.com/p/d5114a2a2052



Posted by mike760534211 on Mon, 04 May 2020 17:06:24 -0700