# Linux 系統管理 - HW06 ## A. 安裝 nginx 1. 下載 nginx ``` sudo apt install nginx ```  2. 查看nginx的狀態 ``` systemctl status nginx ```  3. 利用瀏覽器確認  ## B. 安裝php 1. 安裝PPA ``` sudo add-apt-repository ppa:ondrej/php ```   * 備註 : PPA 是 Personal Package Archive 的縮寫,軟體開發者將原始碼上傳至 Launchpad 後,透過其線上編譯服務,產生預先編譯好的套件,提供使用者使用。由於 PPA 是屬於非官方的套件庫,所以通常軟體版本比較新,但穩定性也較差。 2. 下載 php (php8.1)  3. 查看 php,恩,果然不行  4. 下載 php-fpm  5. 查看 php-fpm  ## C. 安裝 MariaDB 1. 下載必要套件 ``` sudo apt install wget software-properties-common dirmngr ca-certificates apt-transport-https ```  2. 下載 MariaDB ``` sudo apt install mariadb-server mariadb-client ```  3. 查看是否正確安裝並確認是否啟動 ``` mariadb --version systemctl status mariadb ```  4. 利用瀏覽器確認  ## D. 設定php與nginx之間的參數 1. 用nano打開 ``` sudo nano /etc/nginx/sites-available/default // 如果前項指令無法正常執行,請執行以下: sudo nano /etc/nginx/sites-enabled/default ```  2. 更改參數 ``` server { # Example PHP Nginx FPM config file listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.php to setup Nginx, PHP & PHP-FPM config index index.php index.html index.htm index.nginx-debian.html; server_name _; location / { try_files $uri $uri/ =404; } # pass PHP scripts on Nginx to FastCGI (PHP-FPM) server location ~ \.php$ { include snippets/fastcgi-php.conf; # Nginx php-fpm sock config: fastcgi_pass unix:/run/php/php8.1-fpm.sock; # Nginx php-cgi config : # Nginx PHP fastcgi_pass 127.0.0.1:9000; } # deny access to Apache .htaccess on Nginx with PHP, # if Apache and Nginx document roots concur location ~ /\.ht { deny all; } } # End of PHP FPM Nginx config example ``` 3. 測試編輯是否有錯誤 ``` sudo nginx -t ```  4. 建立 info.php  5. 重新啟動服務 ``` sudo systemctl restart nginx ``` 6. 用瀏覽器確認  ## reference [How to Install and Set Up MariaDB on Ubuntu 22.04](https://www.makeuseof.com/install-set-up-mariadb-on-ubuntu/) https://www.ibm.com/support/pages/disabling-http-port-80-security-network-ips-appliances [網頁伺服器-CLI及phpinfo()](https://ithelp.ithome.com.tw/articles/10243646) ###### tags: `Linux`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up