Two methods of installing Nginx in Centos6 and 7

Install using the yum command1It is important to verify the operating system version because we will rely on this to create the yum source file (HTTPS://img2018.cnblogs.com/blog/940167/201811/940167-20181123141947437-996389736.png)

2, create nginx. Repo1Vi/etc/yum. Repos. D/nginx. Repo file content is as follows (if it is centos7 correspond to the Numbers6to7) :1
2
3
4
5
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1


3, clear the cache and create a new cache1
2
3
yum clean all
 
yum makecache
4# yum install nginx # yum install nginx # yum install nginx5Run the service nginx start command to start nginx1
service nginx start


6Check whether the Nginx process exists by downloading the source packagehttps://blog.csdn.net/darkdragonking/article/details/79034654

 https://www.cnblogs.com/yaoximing/p/6068622.html1. Install dependencies1.GCC install nginx install nginx install nginx install nginx install nginx install nginx install nginx install nginx install nginx install nginx1
yum install gcc-c++
2.PCRE Pcre-devel Installation PCRE(Perl Compatible Regular Expressions) is a Perl library that includes perl-compatible Regular expression libraries. The HTTP module of Nginx uses PCRE to parse regular expressions, so you need to install the PCRE library on Linux. Pcre-devel is a secondary development library developed using PCRE. Nginx also needs this library. Command:1
yum install -y pcre pcre-devel
3.Zlib provides a variety of compression and decompression methods. Nginx uses zlib to gzip HTTP packages, so you need to install zlib on Centos1
yum install -y zlib zlib-devel
4.OpenSSL installation OpenSSL is a powerful Secure Socket layer password library that includes key algorithms, common key and certificate encapsulation management functions, and SSL protocols. It also provides rich applications for testing and other purposes. Nginx supports both HTTP and HTTPS, so you need to install the OpenSSL library on Centos1Yum install -y openssl openssl-devel1
wget -c https:/ / nginx.org/download/nginx-1.14.2.tar.gzThree, decompress, compile1
2
3
4
tar -zxvf nginx-1.142..tar.gz
cd nginx-1.142././configure make && make install1
2
3
4
5/nginx./nginx -s stop./nginx -s quit./nginx -s reload1Vim /etc/rc.local Add a line1/ usr/local/nginx/sbin/nginx set execute permissions:1
chmod 755Rc. Six, with systemctl management to create a local source to install nginx configuration file in/etc/systemd/system/multi - user. Target. Wants/directory is not nginx. The service of this file, so new1
[root@localhost nginx-1.14. 0] # vim/usr/lib/systemd/system/nginx. Service written content (copy all in, and then modify)1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
 
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/Kill -s TERM $MAINPID [Install] WantedBy=multi-user.target Modify the content of [Service]1
2
3
4Will: ExecStart =/usr/Sbin/nginx -c /etc/nginx/nginx.conf, ExecStart=/usr/Local/nginx/sbin/nginx - c/usr/local/nginx/conf/nginx. Conf set upon boot1
[root@localhost nginx-1.14. 0]# systemctl enable nginx.service Disable the previously started nginx service1
[root@localhost nginx-1.14. 0]# pkill -9Nginx reloads all configuration files that have been modified1
[root@localhost nginx-1.14. 0]#systemctl daemon-reload restart the nginx service1
[root@localhost nginx-1.14. 0]#systemctl start nginx
Copy the code

From the Internet:www.cnblogs.com/luxiaojun/p…, if there is infringement, please contact to delete