Linux Enterprise Common Service---Compile and install Nginx

Source: Internet
Author: User

Network download Nginx Source package:

wget http://nginx.org/download/nginx-1.6.2.tar.gz

Installation dependencies:

Yum install pcre-devel Zlib-devel # #本地的光盘作为yum源

Install Nginx:

Useradd-m-s/sbin/nologin Nginx

Tar zxvf nginx-1.6.2.tar.gz-c/usr/src/

Cd/usr/src/nginx-1.6.2/

[Email protected] nginx-1.6.2]#/configure--prefix=/usr/local/nginx--user=nginx--group=nginx--with-http_stub_ Status_module # #编译安装-Specify home directory-Specify user-Specify group-carry module

[[email protected] nginx-1.6.2]# make &&make Install

[Email protected] nginx-1.6.2]# ls/usr/local/nginx/# #验证安装

Conf HTML logs Sbin

Ln-s/usr/local/nginx/sbin/nginx/usr/local/sbin/# #优化执行路径

Ls-l/usr/local/sbin/

Total dosage 0

lrwxrwxrwx. 1 root root 27 December 20:03 Nginx-/usr/local/nginx/sbin/nginx


Start Nginx:

Nginx # #启动

NETSTAT-UTPLN |grep Nginx

TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8311/nginx

Access test:

/etc/init.d/iptables stop

Setenforce 0


[Email protected] ~]# elinks--dump Http://IP Address


Add Nginx for system service:

Vi/etc/init.d/nginx

#!/bin/bash

# Chkconfig:-99 20

# Description:nginx Server Control Script

np= "/usr/local/nginx/sbin/nginx"

npf= "/usr/local/nginx/logs/nginx.pid"

Case "$" in

Start

$NP;

If [$?-eq 0]

Then

echo "Nginx is starting!!"

Fi

;;

Stop

Kill-s QUIT $ (cat $NPF)

If [$?-eq 0]

Then

echo "Nginx is stopping!!"

Fi

;;

Restart

$ stop

$ start

;;

Reload

Kill-s HUP $ (cat $NPF)

If [$?-eq 0]

Then

echo "nginx config file is reload!"

Fi

;;

*)

echo "Usage: $ {start|stop|restart|reload}"

Exit 1

Esac

Exit 0

: Wq

chmod +x/etc/init.d/nginx

Chkconfig--add Nginx

/etc/init.d/nginx restart

[Email protected] conf]# pwd

/usr/local/nginx/conf

[Email protected] conf]# VI nginx.conf # #编辑配置文件在server中添加如下行:

Location/status {

Stub_status on;

Access_log off;

}

: Wq


/etc/init.d/nginx restart

Nginx is stopping!!

Nginx is starting!!


Access test: IE

HTTP://IP Address/status


This article is from the "Lp-linux" blog, make sure to keep this source http://linuxlp.blog.51cto.com/11463376/1773553

Linux Enterprise Common Service---Compile and install Nginx

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.