# VPS Linux re-build後設定 :house: [回筆記首頁](https://www.mirai.tw) ###### 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 ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## 2. date :vps系統時間 3. timedatectl set-timezone Asia/Taipei 4. 檢查更新 apt update (如果是 centos或amalinux請將apt改成yum,以下也一樣) 5. 系統更新 apt upgrade 6. 安裝nano編輯器 apt install nano (下面指令安裝網路相關的小程式) 7. apt -y install net-tools 8. apt install wget 9. apt -y install lynx 10. 新增 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 11. 安裝 htop: apt install htop 12. 安裝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套件 ```bash apt -y install php php-fpm php-common php-pear php-mbstring ``` * 啟用PHP-FPM ```bash systemctl enable php7.3-fpm systemctl start php7.3-fpm ``` * 編輯設定檔 ```bash nano /etc/nginx/sites-available/default ``` * 在server{}中加入 ```bash location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.3-fpm.sock; } ``` * 重啟PHP-FPM及nginx ```bash systemctl restart php7.3-fpm nginx ``` * 建立測試檔案 ```bash nano /var/www/html/index.php <?php phpinfo(); ?> ```
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.