[測試] 淺談「httpd」及其安裝大略

本帖最後由 pipikeung 於 2026-6-30 18:09 編輯

既然已試裝了不同版本的「Linux」,都要用用「她」的強項,- 「網絡功能」。起個「LAMP」伺服器、攪攪「Wordpress」整個「網站」玩吓﹕

首先當然是先裝個「LAMP」伺服器﹕
L = Linux
A = Apache
M = Mysql /Maria DB
P = php/python/Perl

以前裝要「揼石仔」,安裝好一樣還一樣,頗費時間,現在十分輕省,以「Linux Mint」為例﹕一兩個指令便完成﹕
sudo apt update && sudo apt upgrade -y
sudo apt install lamp-server^

安裝完「LAMP」後為「root」加個「password」,預設是「root」不設「password」,但為方便操作「mysql」而安裝「phpmyadmin」,所以要為「root」加「password」否則不能使用「root」登入。
sudo mysql -u root
sql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Your_root_password' ;
FLUSH PRIVILEGES;
EXIT;
請用你想要的密號來置換「Your_root_password」

安裝「phpMyAdmin」
sudo apt install phpmyadmin

加個「mysql」使用者並獲取所有權限

sudo mysql -u root -p

sql
CREATE USER 'username'@'localhost' IDENTIFIED BY 'username password'

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION ;
將使用者名稱及密號置換「username及usernmae password」

FLUSH PRIVILEGES;
EXIT;

現在可以加添一個「資料庫」(Wordpress)
有兩個方法﹕
01 使用「phpmyadmin」有圖文介面,輕鬆完成。

02 也可以直接用mysql指令完成
   sql
   CREATE DATABASE database_name; 「這裏的database_name當然是用Wordpress」

從「wordpress.org」下載「Wordpress」的安裝檔壓縮檔。
解壓後移至/var/www/html/
sudo mv -R worrdpress /var/www/html/

打開溜灠器鍵入﹕http://localhost/wordpress

按指示輸入設定「使用者名稱」、「資料庫名稱」、「資料庫密號」、「電郵」等等

不需「數分鐘」便安裝好「Wordpress」- 你的私人網站。

給「Wordpress」設定正確權限,所有「資料夾」設定為「755」,所有「檔案」設定為「644」。
sudo chown -R www-data:www-data /var/www/html/wordpress

sudo find /var/www/html/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/html/wordpress -type f -exec chmod 644 {} \;

在其他版本的「Linux」如「ArchLinux」、「Debian」及其同系的「Debian-base」,都可以安裝「LAMP」伺服器搭載「Wordpress」或「Durpal」來創建個人網站。方法與在「LinuxMint」稍有不同、而「ArchLinux」比較「煩」少少。但網上有「海量」資訊,可以令你輕鬆完成。

在「LinuxMint+LAMP+Wordpress」並加裝了「phpMyAdmin」




在「ArchLinux+LAMP+Wordpress」並加裝了「phpMyAdmin」



在「Debian+LAMP+Wordpress」並加裝了「phpMyAdmin」



最後以「LinuxMint」為例,使用「Let.s Encrypt」產生「SSL」憑證
sudo a2enmod ssl
sudo a2enmod rewrite

sudo apt install cerbot python3-certbot-apache
sudo certbot --apache

使用「DDNS」綁定固定網域,便大功告成﹗
重啟「Apache2」
sudo systemctl restart apache2

綁定「固定網域(如﹕pipikeung.tplinkdns.com)」,在瀏灠器中鍵入「https://pipikeung.tplinkdns.com」,便能看到你創立的網站。( 因使用「TpLink」路由,「TpLink」有提供「DDNS」)
在「LinuxMint+LAMP+Wordpress」創建的網詀,便可在「https://pipikeung.tplinkdns.com」中瀏灠及使用﹕


「SSL」憑證由「Let's Encrypt」發出﹕


網上亦有很多免費的「DDNS」如「DuckDNS、No-IP、FreeDNS」....等等。

以上截圖展示分別在「LinuxMint」、「ArchLinux」、「Debian」中安裝「LAMP+Wordpress+phpMyAdmin」及使用「Certbot」產生「SSL」憑證,使用「DDNS」綁定固定網域,創建網站的大略操作。

好多年前入門玩 LAMP 果陣,
都有用過 Apache..

之後玩下玩下都係覺得 NGINX 好用d.

TOP

「Nginx」及「Apache」是主要建「web-site」的伺服器,兩者各有優勢。選擇「Apache」主要是搭載「wordpress」,網站依賴比較複雜的動態後台,而且流量相對穩定。

最想指出是使用「Linux」起個「綱站」是十分容易,無論使用什麽「Linux Distros」都可以,而且「一個仙」都不使,用開源軟件便順利完成,包括「SSL」憑證及「DDNS」綁定固定網域,網上都有「免費」資源可用。https://pipikeung.tplinkdns.com都在此條件下完成。

TOP

好有心機去紀錄,但大佬套stack 20年前用Debian或Ubuntu都一樣咁裝,係多咗個10年前有嘅certbot…..

我以為睇緊舊post但睇日期先知係新嘅

TOP

說得非常「啱」,「一點不虛」廿年前方法,如今還可應用,經得起「時間考驗」足以證明「老而彌堅」﹗「LAMP」可以搭載最新的「Wordpress 7.0」或「Drupal 11.4」來建站。

TOP

本帖最後由 pipikeung 於 2026-7-15 05:45 編輯

多一點點小補充,「Apache」與「Nginx」使用場景比較﹕
長話短說﹕「高併發、高流量、少資源」,網站以管理「靜態資源」為主。(如大量圖片、CSS、JavaScript...),使用「Nginx」

網站管理「動態內容為主,依賴PHP、Python等動態分析」,同時使用大量功能模組(Modules)者,使用「Apache」

已展示過安裝「LAMP+WordPress+phpMyAdmin+SSL+DDNS」的大致操作。
「LAMP」與「LEMP」只分別在使用「Apache」或「Nginx」而已,在「Nginx」中加裝「phpMyAdmin」與「Apache」有些少分別。網上可輕易找到詳細資訊,故不細表「贅」述。

下圖是「LEMP(Nginx)+Wordpress+phpMyAdmin」截圖﹕


TOP