linux CentOS 安裝 nginx

 

官方網址:http://nginx.org/en/download.html

 

1、安裝基礎組件

yum install gcc-c++

yum install pcre

yum install pcre-devel

yum install zlib 

yum install zlib-devel

yum install openssl

yum install openssl-devel

2、安裝Nginx

第一種:下載安裝:html

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

 

tar -zxvf nginx-1.15.9.tar.gz

 

#cd nginx-1.10.3

 

./configure

 

make

 

make install

 

./nginx 
./nginx -s stop
./nginx -s quit
./nginx -s reload

配置nginx開機啓動

cd /lib/systemd/system/
vim nginx.service

切換到/lib/systemd/system/目錄,建立nginx.service文件vim nginx.servicenginx

[Unit]
Description=nginx 
After=network.target 
   
[Service] 
Type=forking 
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true 
   
[Install] 
WantedBy=multi-user.target

退出並保存文件,執行systemctl enable nginx.service使nginx開機啓動c++

systemctl enable nginx.service

systemctl start nginx.service    啓動nginxvim

systemctl stop nginx.service    結束nginxcentos

systemctl restart nginx.service    重啓nginxbash

 

第二種:YUM安裝:ui

查看yum庫中的 nginx安裝包rest

yum -y list nginx*

安裝yum庫中的 nginxcode

 

安裝源:yum install nginx-release-centos-6-0.el6.ngx.noarch.rpm -y(注意-y參數)htm

安裝Nginx:yum install nginx

啓動Nginx服務:service nginx start

中止Nginx服務:service nginx stop

查看Nginx運行狀態:service nginx status

檢查Nginx配置文件:nginx -t

服務運行中從新加載配置:nginx -s reload

添加Nginx服務自啓動:chkconfig nginx on

相關文章
相關標籤/搜索