Nginx在線安裝與啟動
系統環境:中科方德桌面操作系統 3.1
內核: SMP CDOS 4.9.25-1+1cdos44 (2019-12-20) x86_64 GNU/Linux
使用連接工具:FinalShell3.9.5.7
1、下載nginx
sudo apt-get update
2、安裝命令
sudo apt-get install nginx
安裝時報錯
Failed to start A high performance web server and a reverse proxy server
1、檢查nginx配置文件是否正確,可以使用nginx -t命令檢查配置文件是否正確;
2、檢查端口是否被占用,可以使用netstat -anp | grep 端口號命令查看;
3、檢查nginx的啟動用戶是否有權限,可以使用ps -ef | grep nginx查看;
4、檢查nginx的日志文件是否有權限,可以使用ls -l /var/log/nginx查看;
5、檢查nginx的進程是否存在,可以使用ps -ef | grep nginx查看;
6、檢查nginx的配置文件是否有權限,可以使用ls -l /etc/nginx查看。
nginx端口號為80,查詢netstat -anp | grep 80是否被apache占用。
若占用則停用apache:
sudo service apache2 stop
啟動:
sudo service apache2 start
3、卸載
#查看和nginx相關軟件
dpkg --get -selections-grep nginx
4、刪除nginx,包含相關文件
sudo apt-get remove nginx-commonsudo apt-get purge nginx-commonsudo apt-get autoremovesudo apt-get remove nginx-full nginx-common
5、啟動服務
sudo systemctl start nginx
/etc/init.d/nginx start|stop|reload
5、停止服務
sudo systemctl stop nginx
6、重啟服務
sudo systemctl restart nginx
7、查看nginx當前狀態
systemctl status nginx
8、查看nginx監聽狀態
sudo netstat -tnulp |grep nginx
9、安裝位置
默認安裝在ect/nginx,未找到時使用whereis nginx
10、查看nginx版本
sudo nginx -v
11、查看nginx當前配置及版本信息
sudo nginx -V
12、檢查配置文件是否有錯
nginx -t
此處nginx.conf syntax is ok 表示nginc.conf中無法錯誤,有語法錯誤時會提示錯誤行數
官方文檔:https://blog.redis.com.cn/doc/