穩定性高
系統資源消耗低
對HTTP并發連接的處理能力高
mysql-boost-5.7.20.tar.gz nginx-1.12.2.tar.gz php-7.1.20.tar.gz
[root@localhost LNMP]# tar zxvf nginx-1.12.2.tar.gz -C /opt/
.......//省略解壓過程
[root@localhost LNMP]# yum -y install gcc gcc-c++ pcre-devel zlib-devel
........//省略安裝過程
[root@localhost LNMP]#
[root@localhost LNMP]# useradd -M -s /sbin/nologin nginx //-M,不創建家目錄
[root@localhost LNMP]# id nginx //查看nginx用戶
uid=1001(nginx) gid=1001(nginx) 組=1001(nginx)
[root@localhost LNMP]#
[root@localhost LNMP]# cd /opt/nginx-1.12.2/
[root@localhost nginx-1.12.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@localhost nginx-1.12.2]# ./configure \
> --prefix=/usr/local/nginx \ //安裝路徑
> --user=nginx \ //屬主
> --group=nginx \ //屬組
> --with-http_stub_status_module //開啟統計模塊
........//省略配置過程
[root@localhost nginx-1.12.2]# make && make install
.........//省略編譯過程
[root@localhost nginx-1.12.2]#
[root@localhost nginx-1.12.2]# cd /usr/local/nginx/
[root@localhost nginx]# ls
conf html logs sbin
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ls
nginx
[root@localhost sbin]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@localhost sbin]#
[root@localhost sbin]# 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 sbin]# nginx //開啟服務
[root@localhost sbin]# netstat -ntap | grep 80 //查看80端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 52709/nginx: master
[root@localhost sbin]#
[root@localhost sbin]# systemctl stop firewalld.service //關閉防火墻
[root@localhost sbin]# setenforce 0 //關閉增強性安全功能
[root@localhost sbin]#
[root@localhost sbin]# yum install elinks -y //安裝工具
.........//省略安裝過程
[root@localhost sbin]#
[root@localhost sbin]# elinks http://localhost //測試能否訪問nginx服務
[root@localhost sbin]# service nginx stop //停止服務
[root@localhost sbin]# netstat -ntap | grep 80 //查看80端口,無
[root@localhost sbin]# service nginx start //開啟服務
[root@localhost sbin]# netstat -ntap | grep 80 //查看80端口,有
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 53614/nginx: master
[root@localhost sbin]#
[root@localhost sbin]# vim /usr/local/nginx/conf/nginx.conf
location / {
root html;
index index.html index.htm;
}
location /status {
stub_status on;
access_log off;
}
[root@localhost sbin]# service nginx stop
[root@localhost sbin]# service nginx start
[root@localhost sbin]#
[root@localhost sbin]# yum install httpd-tools -y
........//省略安裝過程
[root@localhost sbin]#
[root@localhost sbin]# htpasswd -c /usr/local/nginx/passwd.db test
New password:
Re-type new password:
Adding password for user test
[root@localhost sbin]# cat /usr/local/nginx/passwd.db
test:$apr1$od5a34WH$MduYUJbQ2W0oihB0Bs/bx.
[root@localhost sbin]#
[root@localhost sbin]# service nginx stop
[root@localhost sbin]# service nginx start
[root@localhost sbin]#
向AI問一下細節
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。