日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
CentOS編譯安裝Nginx

centos編譯安裝Nginx

陽(yáng)東ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!

下載

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

解壓縮

tar zxvf nginx-1.9.6.tar.gz

進(jìn)入nginx目錄

cd nginx-1.9.6

設(shè)置,編譯,安裝(configure過(guò)程可能出現(xiàn)的情況,見(jiàn)文章最尾)

./configure --prefix=/data/server/nginx
make && make install && make clean

修改nginx配置文件

vi /data/server/nginx/conf/nginx.conf1

將根目錄修改至 /data/webroot/localhost

找到
location / {
    root    html;              # 根目錄
    index index.html index.htm; # 默認(rèn)文檔
}
改為
location / {
    root /data/webroot/localhost;  # 站點(diǎn)根目錄路徑
    index index.html index.htm;    # 目前只放靜態(tài)頁(yè),所以不需要改
}

創(chuàng)建nginx系統(tǒng)服務(wù)腳本

vi /etc/init.d/nginx

填入如下內(nèi)容

#!/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
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:    /data/webroot/logs/localhost/nginx.pid

# 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="/data/server/nginx/sbin/nginx" # nginx啟動(dòng)文件
prog=$(basename $nginx)

NGINX_CONF_FILE="/data/server/nginx/conf/nginx.conf" # 配置文件路徑

lockfile=/var/lock/subsys/nginx

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=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    configtest || return $?
    stop
    start
}

reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}

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
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

保存

:wq對(duì)腳本添加可執(zhí)行權(quán)限

chmod +x /etc/init.d/nginx

添加nginx到自啟動(dòng)服務(wù)

chkconfig --add nginx

設(shè)置開機(jī)啟動(dòng)

chkconfig nginx on

開啟訪問(wèn)端口
vi /etc/sysconfig/iptables

添加如下

-A INPUT –m state –state NEW –m tcp –p tcp –dport 80 –j ACCEPT

重啟防火墻以應(yīng)用規(guī)則

/etc/init.d/iptables restart1

 
此后,執(zhí)行命令腳本即可,無(wú)需執(zhí)行原路徑的執(zhí)行文件

/etc/init.d/nginx start    # 啟動(dòng)nginx
/etc/init.d/nginx stop      # 停止nginx
/etc/init.d/nginx restart  # 重啟nginx
/etc/init.d/nginx reload    # 重新加載配置文件

原操作命令

/data/server/nginx/sbin/nginx              # start server
/data/server/nginx/sbin/nginx -s stop      # fast shutdown
/data/server/nginx/sbin/nginx -s quit      # graceful shutdown
/data/server/nginx/sbin/nginx -s reload    # reloading the configuration file
/data/server/nginx/sbin/nginx -s reopen    # reopening the log files

至此,nginx的安裝與最基本的配置已完成

configure過(guò)程可能出現(xiàn)的情況

缺少C編譯器,需要安裝gcc
運(yùn)行安裝命令,yum install -y gcc

未安裝PCRE
運(yùn)行安裝命令,yum install -y pcre pcre-devel

缺少安全庫(kù)

運(yùn)行安裝命令,yum install -y openssl openssl-devel


分享標(biāo)題:CentOS編譯安裝Nginx
標(biāo)題URL:http://www.5511xx.com/article/dhigdej.html