nginx 官網(wǎng)
http://nginx.org/en/download.html
yum 安裝
選擇centos 結(jié)合官網(wǎng)看。注意版本7 指的的centos 的版本冷守,7或者7.x ,8或者8.x 都可以湾揽。
安裝好后羹呵,查看版本。
[root@VM-0-2-centos ~]# nginx -v
nginx version: nginx/1.18.0
nginx -V 顯示編譯的參數(shù)滤愕。
[root@VM-0-2-centos ~]# nginx -V
yum 安裝好nginx 后,用 rpm -ql nginx 查詢安裝的目錄
[root@localhost yum.repos.d]# rpm -ql nginx
/etc/logrotate.d/nginx
/etc/nginx
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/modules
/etc/nginx/nginx.conf
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/sysconfig/nginx
nginx 的啟動(dòng),停止谎僻,重啟
########關(guān)閉
service nginx stop
systemctl stop nginx
########啟動(dòng)
service nginx reload
systemctl restart nginx
#########隨系統(tǒng)啟動(dòng)自動(dòng)運(yùn)行
systemctl enable nginx
#######禁止隨系統(tǒng)啟動(dòng)自動(dòng)運(yùn)行
systemctl disable nginx
########
nginx 啟動(dòng)后,輸入ip,如下表示 啟動(dòng)成功寓辱。
知識(shí)點(diǎn)擴(kuò)展:
首先利用配置文件啟動(dòng)nginx艘绍。
[命令](https://www.linuxcool.com/ "命令"):
首先利用配置文件啟動(dòng)nginx。
[命令](https://www.linuxcool.com/ "命令"):
nginx -c /usr/local/nginx/conf/nginx.conf
重啟服務(wù): service nginx restart
1. 快速停止或關(guān)閉Nginx:nginx -s stop
2. 正常停止或關(guān)閉Nginx:nginx -s quit
3. 配置文件修改重裝載[命令](https://www.linuxcool.com/ "命令"):nginx -s reload
[root@VM-0-2-centos conf.d]# cat default.conf
#代表服務(wù)配置
server {
listen 80; #端口配置
server_name localhost; #服務(wù)器名
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
#當(dāng)用戶訪問(wèn)http://ip:80/
location / {
root /usr/share/nginx/html; #當(dāng)匹配到/這個(gè)規(guī)則時(shí)(因?yàn)閘ocation 后面是 /)秫筏,指向目錄/usr/share/nginx/html诱鞠。
index index.html index.htm; #當(dāng)訪問(wèn)不指定具體頁(yè)面時(shí),默認(rèn)顯示的頁(yè)面这敬,類似于 web.xml 的 welcomefiles;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#當(dāng)服務(wù)出現(xiàn)500的錯(cuò)誤時(shí)航夺,訪問(wèn)的頁(yè)面。
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}