---
# System prepended metadata

title: HW06 安裝LNMP

---

# HW06 安裝LNMP

## 更新
sudo apt update
sudo apt upgrade
![](https://i.imgur.com/HGSsYkd.png)

## nginx安裝
https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10

### 下載 nginx

sudo apt install nginx
![](https://i.imgur.com/tihMIHc.png)

### 查看版本
nginx -v
![](https://i.imgur.com/II8X17p.png)

## 啟動Nginx服務
sudo systemctl start nginx
![](https://i.imgur.com/TS4cHB8.png)

## Firewall Setup

https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10

### 開啟防火牆
sudo ufw allow 443/80
sudo ufw status
![](https://i.imgur.com/ZyQnW0T.png)

## MariaDB安裝

https://mariadb.org/download/?t=repo-config&d=22.04+"jammy"&v=10.10&r_m=ossplanet

### 下載MariaDB
Step1
![](https://i.imgur.com/zjgRura.png)

Step2
![](https://i.imgur.com/tTAEPxN.png)
Step3
![](https://i.imgur.com/weezONy.png)
Step4
![](https://i.imgur.com/StKB5ei.png)

## MariaDB版本

MariaDB --version
![](https://i.imgur.com/jVVKO8Q.png)

## php安裝
https://ui-code.com/archives/286
### php下載
sudo apt install php
![](https://i.imgur.com/GzmKPEA.png)

### php版本
php --version
![](https://i.imgur.com/0KXkIaz.png)

## 為 Nginx 安裝 PHP
https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Nginx-PHP-FPM-config-example

### 下載 PHP-FPM

sudo apt install php8.1-fpm
![](https://i.imgur.com/uFEXJJz.png)

## 在 Nginx 的配置文件中啟用 PHP

sudo nano /etc/nginx/sites-enabled/default
![](https://i.imgur.com/c9AhSMj.png)
![](https://i.imgur.com/b01jLs1.png)

### 重新啟動服務器

sudo systemctl restart nginx
![](https://i.imgur.com/PJwrQ58.png)

## 測試 Nginx、PHP
![](https://i.imgur.com/soSe19R.png)



