Install the nginx server in CentOS6
-- Prepare the environment
1. Ensure that the operating system is installed with the GCC compiler. You must also install the Autoconf and Automake tools.
Yum-y install gcc-c ++ autoconf automake
2. Module dependency: Some Nginx modules require support from other third-party libraries. For example, the gzip module requires the zlib library, the rewrite module requires the pcre Library, and the ssl function requires the openssl library.
Yum-y install zlib-devel openssl-devel pcre-devel
3. Download an rpm package on the nginx official website, which is: http://nginx.org/en/download.html or wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
Install this rpm package
Rpm-ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
The following error occurs during installation:
Warning: nginx-release-centos-6-0.el6.ngx.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
If you don't know what to do, just ignore it.
-- Install nginx
1. Start nginx Installation
Yum install nginx
A large amount of information will be displayed, asking if you are OK or not: Is this OK [y/N]:
Enter y. After the screen is rolled for a while, the installation is Complete. The prompt "Complete!" is displayed !" The installation is complete.
2. Several default nginx Directories
Whereis nginx
Nginx:/usr/sbin/nginx/etc/nginx/usr/share/nginx
1) configuration Directory:/etc/nginx/
2) PID Directory:/var/run/nginx. pid
3) error log:/var/log/nginx/error. log
4) access log:/var/log/nginx/access. log
5) default Site Directory:/usr/share/nginx/html
3 Common commands
1) Start: nginx
2) stop: nginx-s stop
3) restart: killall-HUP nginx
4) test configuration: nginx-t
5) display version: nginx-v
------------------ Configure ----------------
1. Modify the default access port
In the "/etc/nginx/conf. d/default. conf" file, find "listen 80", change 80 to the desired port, and save and restart the port.
2. Modify the default access path
In the "/etc/nginx/conf. d/default. conf" file, find the root/root under location/{} and change it to the desired path.
For example: location /{
Root/home/images;
}