CentOS 6.3 Installation Configuration Nginx method _nginx

Source: Internet
Author: User
Tags openssl iptables

Zhoulf 2013-02-09 New Year's Eve original

Installation Instructions

System Environment: CentOS-6.3
Software: nginx-1.2.6.tar.gz
Installation Method: source code compilation installation
Installation Location:/usr/local/nginx
Download Address: http://nginx.org/en/download.html

Installation Prerequisites

Before installing Nginx, you need to make sure that the system has g++, GCC, Openssl-devel, Pcre-devel, and Zlib-devel software installed. Installation must be software:

Copy Code code as follows:

[Root@admin/] #yum install gcc-c++
Yum-y install zlib zlib-devel OpenSSL openssl--devel pcre pcre-devel

Check the nginx of the system installation:

Copy Code code as follows:

[Root@admin local]# find-name Nginx
./nginx
./nginx/sbin/nginx
./nginx-1.2.6/objs/nginx

Uninstall the original Nginx

Copy Code code as follows:

[Root@admin/]# Yum Remove Nginx

Installation
Upload the installation package file to/usr/local to perform the following actions:

Copy Code code as follows:

[Root@admin local]# cd/usr/local
[Root@admin local]# tar-zxv-f nginx-1.2.6.tar.gz
[Root@admin local]# RM-RF nginx-1.2.6.tar.gz
[Root@admin local]# MV nginx-1.2.6 nginx
[Root@admin local]# Cd/usr/local/nginx
[Root@admin nginx]#./configure--prefix=/usr/local/nginx
[Root@admin nginx]# make
[Root@admin nginx]# make install

Configuration

Copy Code code as follows:

#修改防火墙配置:
[Root@admin nginx-1.2.6]# VI +/etc/sysconfig/iptables
#添加配置项
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
#重启防火墙
[Root@admin nginx-1.2.6]# Service iptables restart

Start

Copy Code code as follows:

#方法1
[Root@admin nginx-1.2.6]#/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
#方法2
[Root@admin nginx-1.2.6]# Cd/usr/local/nginx/sbin
[Root@admin sbin]#./nginx

Stop it

Copy Code code as follows:

#查询nginx主进程号
Ps-ef | grep nginx
#停止进程
Kill-quit Main process Number
#快速停止
Kill-term Main process Number
#强制停止
Pkill-9 Nginx

Reboot

[Root@admin local]#/usr/local/nginx/sbin/nginx-s Reload

Test

Copy Code code as follows:

#测试端口
Netstat–na|grep 80
#浏览器中测试
Http://ip:80

Related Article

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.