Ubuntu下搭建Nignx環境及卸載環境

搭建環境

```sh
1、安裝先決條件(Mac需要加sudo)
apt install curl gnupg2 ca-certificates lsb-release
2、設置穩定版本nginx的apt倉庫
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \  | sudo tee /etc/apt/sources.list.d/nginx.list
3、導入nginx官方簽名
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
4、驗證是否需要正確的公鑰
sudo apt-key fingerprint ABF5BD827BD9BF62
5、安裝前的更新與安裝
sudo apt update
sudo apt install nginx

6、啓動nignx
systemctl start nginx

如果啓動失敗、檢查nignx所在位置
1、which nignx
2、cd /usr
3、ls
4、cd local
5、cat /etc/systemd/system/multi-user.target.wants/nginx.service
6、/usr/sbin/nginx -c /etc/nginx/nginx.conf
7、ps -ef
8、curl http://127.0.0.1(可以查看靜態資源內容了)
9、cat /etc/nginx/nginx.conf (查看靜態資源)
10、cat include /etc/nginx/conf.d/*.conf;
11、cd /usr/share/nginx/html(找到靜態資源入口文件)
12、vi index.html (編輯內容、保存之後刷新頁面http://127.0.0.1即可看到效果)

備註:配置nginx環境請參考

http://nginx.org/en/linux_packages.html#Ubuntu

卸載待補充

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章