One of linux configuration nginx

In the past two nights, I have configured nginx on the liunx service. I have been unable to open the index.html page on the external network. Later, I checked on Baidu and said that the latest server has a security group. Later, I asked my classmates and said yes, and then I went to Alibaba Cloud adds security group rules, which can be accessed from the external network later

Links: 1. http://blog.51cto.com/dreamfire/1140965

2、http://www.linuxidc.com/Linux/2016-08/134110.htm

3、http://www.cnblogs.com/zhang-shijie/p/5294162.html

4 、 https://www.cnblogs.com/dennisit/archive/2012/12/26/2834719.html

5、http://www.jb51.net/article/107152.htm

Configuration main steps:

1: When installing software on CentOS, some support libraries may be missing, and an error is reported. Here, first install the support libraries commonly used by the system. Then it will reduce a lot of errors during installation.

# yum install -y gcc gdb

strace gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel

freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc

glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel

curl curl-devel e2fsprogs patch e2fsprogs-devel krb5-devel libidn

libidn-devel openldap-devel nss_ldap openldap-clients openldap-servers

libevent-devel libevent uuid-devel uuid mysql-devel


2: Make sure that you have installed the linux common necessary support libraries. Check if g++ and gcc are installed. 3 packages need to appear after rpm -qa | grep gcc as shown in the figure below. If it doesn't appear. Need to install g++, gcc.

  # yum install gcc-c++

3: The installation of Nginx depends on the following three packages, which means that you must first install the following three packages before installing Nginx. The installation order is the order I wrote:

           3.1 The SSL function requires openssl library, download address: http://www.openssl.org/

           3.2 gzip module requires zlib library, download address: http://www.zlib.net/

           3.3 The rewrite module requires the pcre library, download address: http://www.pcre.org/

           3.4 Nginx installation package: The download address is: http://nginx.org/en/download.html


4: Upload these software to the server with ftp in turn: (the path can be set by yourself)



5: Install the software in sequence

5.1. First, we install the openssl library plug-in required by the SSL function. Note: The installation process is installed according to the file path I set under linux. The command is as follows:

    a.1   tar -zxvf  src/openssl-1.0.2n.tar.gz

    a.2   cd  openssl-1.0.2n

    a.3   ./config

    a.4   make && make install

5.2. Install the encryption library, the command is as follows:

    a.1   tar -zxvf  src/libmcrypt-2.5.8.tar.gz

    a.2   cd  libmcrypt-2.5.8

    a.3   ./config

     a.4   make && make install

Other dependent packages are also installed in this way;

6: Install nginx

6.1: Unzip nginx

       tar -zxvf nginx-1.10.3.tar.gz

       cd  nginx-1.10.3

       useradd nginx -s /sbin/nologin //Create a background process management user for the nginx server 

       ./configure--user=nginx--group=nginx--prefix=/data/soft/nginx/ --with-http_stub_status_module --with-http_ssl_module

        make && make install

7: Check if the installation is successful

       cd  /usr/local/nginx/sbin

       ./nginx -t

       The results show that:

      nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

      nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

8: Open nginx

  /data/soft/nginx/sbin/nginx

The reason why the external network may not be displayed: (try to turn off the firewall)

  8.1 Check whether the process is enabled by ps -ef|grep 'nginx'



It means that nginx has been turned on, and you can also check whether it can run through elinks127.0.0.1



This means that local access is no problem. If liunx says that the elinks command cannot be found, you can install yum install elinks

At this time, you can visit the Internet to see:



The installation is complete.

The problem I encountered during the installation was that I did not set up a security group (port 80) in Alibaba Cloud, and added the following:




Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326771650&siteId=291194637