Try   HackMD

VPS Linux re-build後設定

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
回筆記首頁

tags: server Ngix vps Linux
  1. hostnamectl :檢查vps的狀態
 Static hostname: server2
       Icon name: computer-vm
         Chassis: vm 🖴
      Machine ID: bc0a3908a261d1fdecb5bcbd8b9032bc
         Boot ID: 44791200de3046fdbd210cfa8dea6242
  Virtualization: kvm
Operating System: AlmaLinux 9.0 (Emerald Puma)        
     CPE OS Name: cpe:/o:almalinux:almalinux:9::baseos
          Kernel: Linux 5.14.0-70.30.1.el9_0.x86_64
    Architecture: x86-64
 Hardware Vendor: Red Hat
  Hardware Model: KVM

命令:curl -sL yabs.sh | bash

## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

Yet-Another-Bench-Script v2023-09-06 https://github.com/masonr/yet-another-bench-script

## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

  1. date :vps系統時間
  2. timedatectl set-timezone Asia/Taipei
  3. 檢查更新 apt update
    (如果是 centos或amalinux請將apt改成yum,以下也一樣)
  4. 系統更新 apt upgrade
  5. 安裝nano編輯器 apt install nano
    (下面指令安裝網路相關的小程式)
  6. apt -y install net-tools
  7. apt install wget
  8. apt -y install lynx
  9. 新增 PPA 個人套件庫
    先安裝 add-apt-repository,如果系統裡已經有了,跳過這步驟 apt install software-properties-common
    add-apt-repository ppa:nginx/stable
    如果是centos:
    安裝Epel擴充資源庫(Extra Packages for Enterprise Linux)
    yum install epel-release
    yum install yum-utils
  10. 安裝 htop: apt install htop
  11. 安裝nginx:
    apt install nginx
    systemctl enable nginx
    systemctl start nginx

<如果有需要關聯式資料庫可繼續安裝> 13. 安裝 mariaDB
apt -y install mariadb-server
systemctl enable mariadb
systemctl start mariadb
接著馬上更改 mariadb的密碼
mysql_secure_installation

<如果有需要php-fpm可繼續安裝> 14. 安裝 php-fpm

  • 讓Nginx可以支援PHP,先安裝PHP套件
    ​​apt -y install php php-fpm php-common php-pear php-mbstring
    
  • 啟用PHP-FPM
    ​​systemctl enable php7.3-fpm
    ​​systemctl start php7.3-fpm
    
  • 編輯設定檔
    ​​nano /etc/nginx/sites-available/default
    
  • 在server{}中加入
    ​​  location ~ \.php$ {
    ​​    include snippets/fastcgi-php.conf;
    ​​    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    ​​  }
    ​​
    
  • 重啟PHP-FPM及nginx
    ​​systemctl restart php7.3-fpm nginx 
    
  • 建立測試檔案
    ​​nano /var/www/html/index.php
    ​​<?php phpinfo(); ?>