[Linux] install Nginx on Linux and nginx on linux

Source: Internet
Author: User
Tags openssl library

[Linux] install Nginx on Linux and nginx on linux

This article describes how to install Nginx in Linux. the Linux system is CentOS 7.2.

1. Download Nginx from the official Nginx website. The version used here is 1.13.6.

2. Upload the downloaded Nginx to Linux. The/opt/nginx directory is used as an example. Run"Tar-zxvf nginx-1.13.6.tar.gz.

3. Switch to the/opt/nginx/nginx-1.13.6 directory and run./configure for Initialization Configuration. If the following prompt is displayed, it means that PCRE is not installed on the machine, and Nginx needs to be dependent on PCRE. You need to install PCRE manually. For details, see http://www.linuxidc.com/linux/2015-03/114986.htm.

 

InstallPcre:

PCRE (Perl Compatible Regular Expressions) is a lightweight Perl function library, including a perl-Compatible Regular Expression Library. It is much smaller than the regular expression library such as Boost. PCRE is very easy to use and has powerful functions. Its performance exceeds the POSIX Regular Expression Library and some classic Regular Expression Libraries.

1. First go to this https://sourceforge.net/projects/pcre/files/pcre/ to download pcre, where the download version is 8.40.

2. Upload pcre-8.40.tar.gz to the/opt/pcre directory and runTar-zxvf pcre-8.40.tar.gz, Decompress the pcre-8.40 directory, and then run the chmod-R 777 pcre-8.40 to grant all read and write permissions to the current folder.

3. Enter the/pcre-8.40 directory and run./ConfigureInitialize the configuration and print a bunch of information. If the following prompt is displayed, the C ++ compiler is missing.

Solution: UseYum-y install gcc-c ++Command to install the C ++ compiler.

Run the C ++ compiler after it is installed successfully../Configure.

4. Execute the make operation to compile.

5. Execute the make install command. Now the pcre installation is complete.

 

Continue back to the/opt/nginx/nginx-1.13.6 directory and run. /configure to initialize the nginx configuration, and print the following information to prove the success. The red arrow points to the address that is the path when nginx is started.

(Note: When you run./configure for nginx Initialization Configuration, you can use the following command to add an ssl module:

./Configure -- prefix =/usr/local/nginx -- with-http_ssl_module

If openssl is not installed before executing the preceding command, the following message is displayed:

./Configure: error: SSL modules require the OpenSSL library.

ExecuteYum-y install openssl-develAfter openssl is installed, you can perform the above operations smoothly)

 

4. Run make install to install

5. Run./nginx in the/usr/local/nginx/sbin directory to start nginx.

6. test whether the installation and startup are successful. Enter the Server IP Address: Port (80 by default) in the browser. If shown, the installation and startup are successful.

 

Common nginx commands:

View nginx processes: ps-ef | grep nginx

Start nginx and run:./nginx in the/usr/local/nginx/sbin directory.

Disable nginx: In the/usr/local/nginx/sbin directory, run:./Nginx-s quit

The nginx configuration file is in/usr/local/nginx/conf/nginx. conf, when the configuration file nginx. after the conf is modified, restart nginx to make the configuration take effect. /nginx-s reload can make the modified configuration take effect, so you don't have to stop and start it again.

 

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.