CentOS installation of two ways Nginx

First, install yum (recommended)

centos7 system repository is no default nginx rpm package, so our own need to update rpm dependent libraries

(1) mounting with yum Nginx nginx need to include libraries, libraries mounting Nginx

#rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

(2) using the following command to install nginx

#yum install nginx

(3) start Nginx

#service nginx start

or

#systemctl start nginx.service

Profiles /etc/nginx/conf.d/ 

 

Second, the manual installation

First, install ready

First, as nginx some modules dependent on a number of lib library, so before you install nginx, you must first install the lib libraries, those dependencies are mainly g ++, gcc, openssl-devel, pcre-devel and zlib-devel so execute the following command to install

$ yum install gcc-c++ 
$ yum install pcre pcre-devel 
$ yum install zlib zlib-devel 
$ yum install openssl openssl--devel

Second, install Nginx

Before installation, it is best to check whether there are already installed nginx

$ find -name nginx

If the system is already installed nginx, then uninstall

$ yum remove nginx

First, enter / usr / local directory

$ cd /usr/local

Download the latest version from the official website of nginx

$ wget http://nginx.org/download/nginx-1.7.4.tar.gz

Nginx extracting archive

$ tar -zxvf nginx-1.7.4.tar.gz

Will produce a nginx-1.7.4 directory, then enter nginx-1.7.4 directory

$ cd nginx-1.7.4

Next, install, use --prefix parameter specifies the directory nginx installation, make, make install installation

$ ./Configure $ installed by default in / usr / local / nginx 
$ the make 
$ the make install


If there is no error, after successful completion, it is best to look at the installation directory nginx

$ whereis nginx


After installation, enter the installation directory (/ usr / local / nginx) will be able to start or stop it.

Start / usr / local / nginx / sbin / nginx

重启 /usr/local/nginx/sbin/nginx –s reload

停止 /usr/local/nginx/sbin/nginx –s stop

Test whether the normal configuration file / usr / local / nginx / sbin / nginx -t

Forced to close pkill nginx

nginx configuration file /usr/local/nginx/conf/nginx.conf

Guess you like

Origin www.cnblogs.com/forthelichking/p/11818253.html