1.Install gcc
Nginx source code compilation depends on the gcc environment
1 |
yum install gcc-c++ |
2.Install PCRE pcre-devel
PCRE (Perl Compatible Regular Expressions) is a Perl library that includes a perl-compatible regular expression library. Nginx’s http module uses pcre to parse regular expressions, so you need to install the pcre library on Centos ,Pcre-devel is a secondary development library developed with pcre which is also required by nginx.
1 |
yum install -y pcre pcre-devel |
3.Install zlib
The zlib library provides a variety of ways to compress and decompress. nginx uses zlib to gzip the contents of the http package, so you need to install the zlib library on Centos.
1 |
yum install -y zlib zlib-devel |
4.Install OpenSSL
OpenSSL is a powerful Secure Sockets Layer cryptographic library that includes major cryptographic algorithms, common key and certificate encapsulation management functions, and SSL protocols, and provides a rich set of applications for testing or other purposes. Nginx not only supports the http protocol, but also supports https (that is, transmits http on the ssl protocol), so you need to install the OpenSSL library in Centos.
1 |
yum install -y openssl openssl-devel |
5.Nginx download and install
Download Nginx from official website
https://nginx.org/en/download.html
download the Stable version .tar.gz installation package
1 2 3 4 5 6 7 8 9 10 11 12 |
#download wget https://nginx.org/download/nginx-1.14.0.tar.gz #decompression tar -zxvf nginx-1.14.0.tar.gz # cd nginx-1.14.0 #configuration ./configure #compile and install make && make install #find the installation path whereis nginx |
Start and stop nginx
1 2 3 4 5 |
cd /usr/local/nginx/sbin/ ./nginx ./nginx -s stop #stop ./nginx -s quit #quit ./nginx -s reload #reload |
The nginx process
1 |
ps aux|grep nginx |
Start Nginx automatically when booting
1 |
vi /etc/rc.local |
Add one line
1 |
/usr/local/nginx/sbin/nginx |
and set execution permissions
1 |
chmod 755 rc.loca |
At this point, centos nginx installation is complete.
This article was first published by V on 2018-10-10 and can be reprinted with permission, but please be sure to indicate the original link address of the article :http://www.nginxer.com/records/nginx-installationcentos7/