Linux server centos7 and above version source code deployment Nginx

Deploy Nginx from the source code of centos7 and above in Linux

This chapter uses Nginx-1.8.1 version

The document will be posted to compile and install configure instructions

#Nginx Baidu Netdisk link source package download address:
https://pan.baidu.com/s/1tBcM1QCER6G1QY-d4meK8w
Extraction code: y7pr

Windows:
#Nginx Source address: http://www.nginx.org/download/

Linux command line:
#Nginx Source address: wget http://nginx.org/download/nginx-1.8.1.tar.gz

1. Server environment solution: #Close the
security mechanism
setenforce 0


#Close the firewall systemctl stop firewalld


#Turn on and turn off the firewall systemctl disable firewalld

Insert picture description here

2. Install nginx dependency package
#Nginx depends on pcre, zlib, openssl#pcre is for rewrite rewrite, zlib is for gzip compression, and some vps are
executed without ssl by default :
yum -y install gcc gcc-c++ automake autoconf libtool make wget pcre-devel zlib zlib-devel openssl-devel glibc pcre openssl cmake

3. Create nginx running user
# For the sake of security, the created nginx user is
useradd nginx -M -s /sbin/nologin that does not require login permissions

4. To determine the version of nginx
# According to the environment, select the download directory
mkdir /data/software/nginx;cd /data/software/nginx/
wget http://nginx.org/download/nginx-1.8.1.tar.gz #Unzip the
Insert picture description here
nginx source package;
tar zxvf nginx-1.8.1.tar.gz
cd /data/software/nginx/nginx-1.8.1

#源码包预配置与编译安装
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-pcre --with-http_flv_module perl-ExtUtils-Embed net-tools
make && make install

5. Make sure that port 80 of the system is not occupied by other programs:
netstat -lntp |grep 80 #Sometimes port 80 is occupied
by nginx, apache or the system's own service, just close it
Insert picture description here

6. Start the nginx command (depending on the /sbin/nginx binary program in the nginx directory):
/usr/local/nginx/sbin/nginx -t //Check the configuration file
/usr/local/nginx/sbin/nginx //Start nginx
Insert picture description here
7. Check whether the nginx service is started:
ps -ef |grep nginx
Insert picture description here

8. Open the browser and visit the virtual machine http://localhost:80. If the browser appears as follows, it means that Nginx has been installed and successfully run.
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44793172/article/details/107144791