? Nginx (engine x)是一個(gè)高性能的HTTP和反向代理web服務(wù)器 ,同時(shí)也提供了IMAP/POP3/SMTP服務(wù)。Nginx是由伊戈?duì)栙愃饕驗(yàn)槎砹_斯訪問(wèn)量第二的Ramblerru站點(diǎn)(俄文: Pamonep) 開(kāi)發(fā)的,第-一個(gè)公開(kāi)版本0. 1.0發(fā)布于2004年10月4日。
? 其將源代碼以類BSD許可證的形式發(fā)布,因它的穩(wěn)定性、豐富的功能集、示例配置文件和低系統(tǒng)資源的消耗而聞名。2011年6月1日,nginx 1.0.4發(fā)布。
? Nginx是一款輕量級(jí)的Web服務(wù)器反向代理服務(wù)器及電子郵件(IMAP/POP3) 代理服務(wù)器,在BSD-like協(xié)議下發(fā)行。其特點(diǎn)是占有內(nèi)存少,并發(fā)能力強(qiáng),事實(shí)上nginx的并發(fā)能力在同類型的網(wǎng)頁(yè)服務(wù)器中表現(xiàn)較好,中國(guó)大陸使用nginx網(wǎng)站用戶有:百度、京東、新浪、網(wǎng)易、騰訊、淘寶等。
安裝環(huán)境:Centos7、nginx-1.12.0.tar.gz
Nginx手工編譯安裝流程步驟細(xì)解如下:
#Nginx設(shè)置
nginx-1.12.0.tar.gz
1.解壓縮軟件包
tar zxf nginx-1.12.0 tar.gz -C /opt/
2.安裝所需編譯安裝環(huán)境包
yum install gcc gcc-c++ pcre pcre-devel zlib-devel -y
3.創(chuàng)建家目錄但不創(chuàng)建家目錄
useradd -M -s /sbin/nologin nginx
4.配置相關(guān)參數(shù)
cd /opt/nginx-1.12.0
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
(統(tǒng)計(jì)模塊)
5.編譯安裝
make &&make install
6.測(cè)試
#cd /usr/local/nginx
#ls
#conf html logs sbin
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
#nginx -t
nginx
netstat -natp | grep 80
systemctl stop firewalld.service
setenforce 0
#yum install -y elinks (測(cè)試網(wǎng)頁(yè)工具)
#elinks http://localhost
7.#基本管理
killall -3 (-s QUIT) nginx
netstat -antp | grep 80
killall -1 (-s HUP) nginx
8.制作管理腳本
[root@localhost ~]# yum install gcc gcc-c++ pcre pcre-devel zlib-devel -y
[root@localhost ~]# cd LNMP-C7/
[root@localhost LNMP-C7]# ls
Discuz_X3.4_SC_UTF8.zip php-7.1.10.tar.bz2
mysql-boost-5.7.20.tar.gz php-7.1.20.tar.bz2
ncurses-5.6.tar.gz php-7.1.20.tar.gz
nginx-1.12.2.tar.gz zend-loader-php5.6-linux-x86_64_update1.tar.gz
php-5.6.11.tar.bz2
[root@localhost LNMP-C7]# tar zxf nginx-1.12.2.tar.gz -C /opt/
[root@localhost nginx-1.12.2]# useradd -M -s /sbin/nologin nginx
[root@localhost LNMP-C7]# cd /opt/
[root@localhost opt]# cd nginx-1.12.2/
[root@localhost nginx-1.12.2]# ./configure \
> --prefix=/usr/local/nginx \
> --user=nginx \
> --group=nginx \
> --with-http_stub_status_module
.....//省略部分內(nèi)容
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@localhost nginx-1.12.2]# make && make install
...//省略部分內(nèi)容
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/opt/nginx-1.12.2'
[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@localhost nginx-1.12.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
[root@localhost nginx-1.12.2]# nginx
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 66585/nginx: master
[root@localhost nginx-1.12.2]# systemctl stop firewalld.service
[root@localhost nginx-1.12.2]# setenforce 0
[root@localhost nginx-1.12.2]# yum install -y elinks
[root@localhost nginx-1.12.2]# elinks http://localhost
//這里執(zhí)行命令后顯示對(duì)話框,ok回車,輸入q選擇yes回車則退出到原本界面
以上就是對(duì)Nginx的手工編譯安裝的過(guò)程,下面我們介紹一下對(duì)Nginx的基本管理命令
[root@localhost nginx-1.12.2]# killall -3 nginx //關(guān)閉Nginx服務(wù)
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
[root@localhost nginx-1.12.2]# nginx //啟動(dòng)Nginx服務(wù)
[root@localhost nginx-1.12.2]# killall -1 nginx //重啟Nginx服務(wù)
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 76326/nginx: master
//也可以使用以下命令進(jìn)行關(guān)閉和重啟
killall -s QUIT nginx
killall -s HUP nginx
[root@localhost nginx-1.12.2]# killall -s QUIT nginx
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
[root@localhost nginx-1.12.2]# nginx
[root@localhost nginx-1.12.2]# killall -s HUP nginx
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 79214/nginx: master
以上基本管理比較不方便,我們可以自己制作一個(gè)管理腳本,腳本如下
vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 99 20
# description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
[root@localhost init.d]# chmod +x nginx
[root@localhost init.d]# chkconfig -add nginx
[root@localhost init.d]# service nginx restart
本文主要講解有關(guān)Nginx的相關(guān)基礎(chǔ)點(diǎn),我們所要知道的就是其自身的特點(diǎn)以及其與Apache的區(qū)別。
特點(diǎn):穩(wěn)定性、輕量級(jí)、高并發(fā)、低資源
優(yōu)勢(shì):擅長(zhǎng)處理靜態(tài)網(wǎng)站(圖片文字視頻等文件)訪問(wèn)資源;
Apache擅長(zhǎng)動(dòng)態(tài)(例如:賬號(hào)注冊(cè)時(shí)所需要的交互)
下一篇文章我們將介紹如何在手工編譯安裝好Nginx服務(wù)的基礎(chǔ)上進(jìn)行Nginx虛擬主機(jī)的搭建,謝謝閱讀!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)頁(yè)名稱:Nginx的網(wǎng)站服務(wù)(手工編譯安裝過(guò)程細(xì)解)-創(chuàng)新互聯(lián)
文章網(wǎng)址:http://www.chinadenli.net/article36/disesg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、網(wǎng)站設(shè)計(jì)公司、云服務(wù)器、網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、手機(jī)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容