Install the nginx server in CentOS6

Source: Internet
Author: User
Tags openssl library automake

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;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.