Installation and configuration of Nginx under Linux (RHEL7 and CentOS7) __linux

Source: Internet
Author: User
Tags curl
First, the environment

Operating system version: CentOS Linux release 7.4.1708 (Core) Minimize installation version two, installation process

1, the installation of compiling tools and related libraries.

[Root@geeklp-nginx ~]# yum-y install gcc-c++ zlib-devel openssl-devel Libtool

2, download Nginx and Pcre.

[Root@geeklp-nginx ~]# Curl-c-----O http://mirrors.sohu.com/nginx/nginx-1.13.7.tar.gz
[root@geeklp-nginx ~]# Curl- C-O https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz

3. Compile and install Pcre.

[Root@geeklp-nginx ~]# tar-xvzf pcre-8.41.tar.gz
[root@geeklp-nginx pcre-8.41]# cd pcre-8.41
[ Root@geeklp-nginx pcre-8.41]# mkdir/usr/local/share/applications/pcre-8.41
[Root@geeklp-nginx pcre-8.41]#./ Configure--prefix=/usr/local/share/applications/pcre-8.41/
[Root@geeklp-nginx pcre-8.41]# make && make Install

4. Compile and install Nginx.

[Root@geeklp-nginx ~]# tar-xvzf nginx-1.13.7.tar.gz
[root@geeklp-nginx nginx-1.13.7]# cd nginx-1.13.7
[ Root@geeklp-nginx nginx-1.13.7]#./configure--prefix=/usr/local/share/applications/nginx-1.13.7/--with-http_ssl_ Module
[Root@geeklp-nginx nginx-1.13.7]# make && make install

5, start Nginx.

[Root@geeklp-nginx nginx-1.13.7]#/usr/local/share/applications/nginx-1.13.7/sbin/nginx

6, configure the firewall.

[Root@geeklp-nginx nginx-1.13.7]# firewall-cmd--permanent--add-port=80/tcp
[Root@geeklp-nginx nginx-1.13.7]# Firewall-cmd--reload

7, verification.
Enter the server address in the browser: 10.1.1.21. The following illustration shows that the Nginx installation was successful.
Third, the configuration Nginx

1, view Nginx version:

[Root@geeklp-nginx nginx-1.13.7]#/usr/local/share/applications/nginx-1.13.7/sbin/nginx-v
Nginx Version:nginx /1.13.7

2, modify the configuration file, remove the following lines of comments, this step is mainly used to test the correct configuration file modification.

3, check the configuration is correct.

[Root@geeklp-nginx conf]#. /sbin/nginx-t
nginx:the Configuration file/usr/local/share/applications/nginx-1.13.7//conf/nginx.conf syntax is OK
nginx:configuration file/usr/local/share/applications/nginx-1.13.7//conf/nginx.conf test is successful

4, overload the configuration file, configure the firewall.

[Root@geeklp-nginx conf]#. /sbin/nginx-s Reload

[Root@geeklp-nginx conf]# firewall-cmd--permanent--add-port=443/tcp
[ Root@geeklp-nginx conf]# Firewall-cmd--reload

5, verification. Enter https://10.1.1.21/in the browser

Indicates that the HTTPS configuration is in effect, but is not working properly, and requires further configuration for normal use. This is not discussed here.
6, stop Nginx.

[Root@geeklp-nginx conf]#. /sbin/nginx-s stop

7, start Nginx and restart Nginx again.

[Root@geeklp-nginx conf]#. /sbin/nginx
[Root@geeklp-nginx conf]#. /sbin/nginx-s Reopen

8, view the Help.

[Root@geeklp-nginx conf]#. /sbin/nginx-h
nginx version:nginx/1.13.7
Usage:nginx [-?HVVTTQ] [-s signal] [-c filename] [-p prefix] [g direc Tives]
Options:
  -?,-H         : This help            -V: Show version and Exit-
  V: Show version and            configure Options then exit-
  T            : Test Configuration and Exit-
  T            : Test configuration, dump it and exit
  -q
  : Suppress NON-ERROR messages during configuration testing-
  s signal     : Send signal to a master process:stop, Quit, reopen, reload-
  p prefix     : Set prefix path (default:/usr/local/share/applications/nginx-1.13.7//)
  -c filename   : Set configuration file (default:conf/nginx.conf)-
  G directives:set global directives out of configuration file

9, configuration boot.

[Root@geeklp-nginx Sbin] echo "/usr/local/share/applications/nginx-1.13.7/sbin/nginx" >>/etc/rc.local
[ Root@geeklp-nginx sbin]# chmod u+x/etc/rc.d/rc.local

Other content later articles will be discussed further.

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.