---
# System prepended metadata

title: HW06 安裝LNMP

---

# HW06 安裝LNMP


## 安裝LNMP
## 1.安裝nginx
sudo apt update
sudo apt upgrade
![](https://i.imgur.com/y8mfDEu.png)
![](https://i.imgur.com/wabfO4m.png)

![](https://i.imgur.com/wabfO4m.png)

下載ngnix
sudo apt install nginx
![](https://i.imgur.com/aDpKj8z.png)
查看版本
nginx -v
![](https://i.imgur.com/BjZyXcx.png)
啟動Nginx服務
sudo systemctl start nginx

查看服務狀態： sudo systemctl status nginx
![](https://i.imgur.com/2OTNksH.png)
輸入網址： http://YOUR_IP/index.nginx-debian.html 確認有沒有Welcome to nginx !
在瀏覽器輸入10.7.200.95檢查有沒有安裝成功，看到以下畫面就是成功安裝
()
![](https://i.imgur.com/9poVGix.png)


## **2.安裝mariadb**
安裝mariadb: $sudo apt install mariadb-server mariadb-client
![](https://i.imgur.com/9SSsV7s.png)
啟動mariadb: $sudo systemctl start mariadb
設定開機啟動mariadb: $sudo systemctl enable mariadb
檢查是否安裝成功: $sudo mysql
![](https://i.imgur.com/Y6EnPyo.png)
# 安装php
安装php: $sudo apt install php8.1-cli php8.1-common php8.1-mysqlnd php8.1-fpm
![](https://i.imgur.com/S5xrZLW.png)
啟動php: $sudo systemctl start php8.1-fpm
設定開機啟動php: $sudo systemctl enable php8.1-fpm
![](https://i.imgur.com/qKpPCyR.png)
修改nginx配置以支持php(改成如下圖): $sudo nano /etc/nginx/sites-enabled/default
![](https://i.imgur.com/M5yL8lA.png)
重啟nginx: sudo systemctl restart nginx

在瀏覽器輸入10.7.200.95/phpinfo.php，看到以下畫面就是成功安裝
結果圖:
![](https://i.imgur.com/CHEDOXB.png)
