Nineth Day 1-8 Combat: Install Nginx Server

Source: Internet
Author: User

Introduction: Use Nginx source package, install Nginx Server, and configure it, test its results.
Imitate Baidu homepage!

First step: Check dependencies
[Email protected] ~]# rpm-q zlib-devel pcre-devel
Package zlib-devel are not installed
Package pcre-devel are not installed
[Email protected] ~]# ls/mnt/packages/*zlib*
/mnt/packages/zlib-1.2.7-15.el7.i686.rpm/mnt/packages/zlib-devel-1.2.7-15.el7.i686.rpm
/mnt/packages/zlib-1.2.7-15.el7.x86_64.rpm/mnt/packages/zlib-devel-1.2.7-15.el7.x86_64.rpm
[Email protected] ~]# ls/mnt/packages/*pcre-devel*
/mnt/packages/pcre-devel-8.32-15.el7.i686.rpm/mnt/packages/pcre-devel-8.32-15.el7.x86_64.rpm
[Email protected] ~]# rpm-ivh/mnt/packages/zlib-devel-1.2.7-15.el7.x86_64.rpm
Warning:/mnt/packages/zlib-devel-1.2.7-15.el7.x86_64.rpm:header V3 rsa/sha256 Signature, key ID Fd431d51:nokey
Preparing ... ################################# [100%]
Updating/installing ...
1:zlib-devel-1.2.7-15.el7 ################################# [100%]
[Email protected] ~]# rpm-ivh/mnt/packages/pcre-devel-8.32-15.el7.x86_64.rpm
Warning:/mnt/packages/pcre-devel-8.32-15.el7.x86_64.rpm:header V3 rsa/sha256 Signature, key ID Fd431d51:nokey
Preparing ... ################################# [100%]
Updating/installing ...
1:pcre-devel-8.32-15.el7 ################################# [100%]
Step Two: Create Nginx user, do not create host directory-m, specify cannot log in-s/sbin/nologin
[Email protected] ~]# useradd nginx-m-s/sbin/nologin
Useradd:cannot open/etc/passwd
[Email protected] ~]# LSATTR/ETC/PASSWD
----I-----------/etc/passwd
[Email protected] ~]# chattr-i/etc/passwd
[Email protected] ~]# useradd nginx-m-s/sbin/nologin
[Email protected] ~]# tail-1/etc/passwd
Nginx:x:1001:1001::/home/nginx:/sbin/nologin
[Email protected] ~]# ls/home/
Gan
Step Three: Extract the Nginx source package
(Download Nginx source package and upload to Linux virtual machine via Xmanager---> omitted here)
[Email protected] ~]# tar zxf nginx-1.11.2.tar.gz-c/usr/src
[Email protected] ~]# ls/usr/src/nginx-1.11.2
Auto changes changes.ru conf Configure contrib HTML LICENSE man README src
Fourth Step: Configure the installation files
[Email protected] ~]# cd/usr/src/nginx-1.11.2/
[Email protected] nginx-1.11.2]#/configure--prefix=/usr/local/nginx--user=nginx--group=nginx
########## #此处省略 ##############
[[email protected] nginx-1.11.2]# echo $?
0
Fifth step: Build the configuration file
[Email protected] nginx-1.11.2]# Make-j 4
[[email protected] nginx-1.11.2]# echo $?
0
Sixth step: Make install Installation
[[email protected] nginx-1.11.2]# make install
########## #此处省略 ##############
Seventh step: Optimize the startup script
[Email protected] nginx-1.11.2]# Cp/usr/local/nginx/sbin/nginx/usr/sbin
[Email protected] nginx-1.11.2]# nginx-t
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
#注释: nginx-t test nginx Service
Eighth step: Start Nginx and verify
[Email protected] nginx-1.11.2]# Nginx
[Email protected] nginx-1.11.2]# Netstat-anlpt | grep nginx
TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8540/nginx:master
[Email protected] nginx-1.11.2]#
Use the host, log in to the virtual machine IP to see, OK, see the following situation shows that has been built successfully!!!

Imitation:< note: Only as an experimental tutorial, please do not do other malicious damage >
First step: Go to a station homepage, right-click to view the source

Step Two: Ctrl + A then, right-click, copy  

Step three: Create a new text document on the desktop, copy the copied content Ctrl + V and Save as index.html

Fourth step: Use Xmanager to upload the new index.html file to the virtual machine and copy it to/usr/local/nginx/html/.

Fifth step: Using the host to enter the virtual machine IP view, OK, success

Nineth Day 1-8 Combat: Install Nginx Server

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.