centos6.5 安装nginx1.10

前端之家收集整理的这篇文章主要介绍了centos6.5 安装nginx1.10前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

系统环境centos6.5 x64 mini

关闭防火墙

关闭selinux

开始安装Nginx

创建用户

[root@zabbix-server sbin]# useradd -M Nginx -s /sbin/nologin

安装环境需要的包

yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

wgethttp://120.52.73.43/jaist.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.tar.gz

wgethttps://www.openssl.org/source/openssl-1.0.2h.tar.gz

wgethttp://zlib.net/zlib-1.2.8.tar.gz

wgethttp://nginx.org/download/nginx-1.10.0.tar.gz

这里下载的包,解压的位置和下面配置参数路径要一致。


解压安装Nginx

tar -zxvf Nginx-1.10.0.tar.gz

cd Nginx-1.10.0

配置

./configure \

�prefix=/usr/local/Nginx \

�lock-path=/usr/local/Nginx/Nginx.lock \

�user=Nginx \

�group=Nginx \

�http-client-body-temp-path=/usr/local/Nginx/client/ \

�http-proxy-temp-path=/usr/local/Nginx/proxy/ \

�http-fastcgi-temp-path=/usr/local/Nginx/fcgi/ \

�http-uwsgi-temp-path=/usr/local/Nginx/uwsgi \

�http-scgi-temp-path=/usr/local/Nginx/scgi \

�with-http_ssl_module \

�with-http_flv_module \

�with-http_mp4_module \

�with-http_gunzip_module \

�with-http_stub_status_module \

�with-http_gzip_static_module \

�with-file-aio \

�with-http_image_filter_module \

�with-http_realip_module \

�with-pcre=/tar/pcre-8.38 \

�with-stream \

�with-openssl=/tar/openssl-1.0.2h \

�with-zlib=/tar/zlib-1.2.8

编译&&编译安装

make && make install

启动Nginx

/usr/local/Nginx/sbin/Nginx

创建启动停止脚本

vim /etc/init.d/Nginx

#!/bin/sh

#

# Nginx � this script starts and stops the Nginx daemin

# chkconfig: � 85 15

# description:Nginx is an HTTP(S) server,HTTP(S) reverse \

# proxy and IMAP/POP3 proxy server

# processname: Nginx

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[ “$NETWORKING” = “no” ] && exit 0

Nginx=”/usr/local/Nginx/sbin/Nginx

prog=$(basename $Nginx)

Nginx_CONF_FILE=”/usr/local/Nginx/conf/Nginx.conf”

lockfile=/usr/local/Nginx/Nginx.lock

start() {

[ -x $Nginx ] || exit 5

[ -f $Nginx_CONF_FILE ] || exit 6

echo -n $”Starting $prog: “

daemon $Nginx -c $Nginx_CONF_FILE

retval=$?

echo

[ $retval -eq 0 ] && touch $lockfile

return $retval

}

stop() {

echo -n $”Stopping $prog: “

killproc $prog -QUIT

[ $retval -eq 0 ] && rm -f $lockfile

restart() {

configtest || return $?

stop

start

reload() {

echo -n $”Reloading $prog: “

killproc $Nginx -HUP

RETVAL=$?

force_reload() {

restart

configtest() {

$Nginx -t -c $Nginx_CONF_FILE

rh_status() {

status $prog

rh_status_q() {

rh_status >/dev/null 2>&1

case “$1” in

start)

rh_status_q && exit 0

$1

;;

stop)

rh_status_q || exit 0

restart|configtest)

reload)

rh_status_q || exit 7

force-reload)

force_reload

status)

rh_status

condrestart|try-restart)

;;

*)

echo $”Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}”

exit 2

esac

查看器启动状态

netstat -anpt|grep 80

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6217/Nginx

访问测试

http://ip地址

猜你在找的CentOS相关文章