---
# System prepended metadata

title: Linux HW06 在ubuntu安裝LNMP

---

# Linux HW06 在ubuntu安裝LNMP
## 1.安裝NGINX
更新系統
![](https://i.imgur.com/73fActb.png)
安裝NGINX
```
sudo apt install nginx
```
查詢ip
![](https://i.imgur.com/hXCZ4Y7.png)
在伺服器輸入ip就會跳出此畫面
![](https://i.imgur.com/ZmnyOLG.png)
## 2.安裝MariaDB
```
sudo apt-get install apt-transport-https curl
sudo curl -o /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo sh -c "echo 'deb https://ftp.ubuntu-tw.org/mirror/mariadb/repo/10.10/ubuntu jammy main' >>/etc/apt/sources.list"
sudo apt-get update
sudo apt-get install mariadb-server
```
## 3.安裝php
```
sudo apt install php8.1
sudo apt install php8.1-fpm
```
## 4.查看資訊
编辑nginx配置
![](https://i.imgur.com/oS4JaU8.png)
![](https://i.imgur.com/aK9c805.png)
進入info.php
![](https://i.imgur.com/VfbQOlt.png)
修改內容
![](https://i.imgur.com/JyzloKu.png)
重新啟動NGINX
![](https://i.imgur.com/RFnqmDw.png)
在伺服器輸入http://server_ip/info.php就可以查看各種資訊
![](https://i.imgur.com/W4PkI1z.png)
php版本
![](https://i.imgur.com/1pGfIdb.png)
nginx版本
![](https://i.imgur.com/uxH3vqU.png)
MariaDB版本
![](https://i.imgur.com/1EKE8bN.png)

## 參考資料
https://wangliguang.com/index.php/server/ubuntu-install-lnmp.html
https://www.bandwagonhost.net/11385.html
https://mariadb.org/download/?t=repo-config

