# LAMP 西苑 - 10/21 Sat. - 講師 張世澤: shize@shize.tw - 簡報:[PDF](https://drive.google.com/file/d/1fuA9ed5PzVcw8jQ8BzDOWfXxASE5Yfht/view?usp=share_link) - 課程網頁: [https://sysh.shize.tw/home/](https://sysh.shize.tw/home/) - 檔案下載: [http://172.17.15.100](http://172.17.15.100) ## 備用機 命令提示字元 > 輸入 `ssh -p 22022 帳號@sysh.shize.tw` > 輸入密碼 ## 課程綱要 - 使用 VirtualBox 安裝 Ubuntu 23.04 - 備援: 預先建立好 Ubuntu Server 並設定好 Nginx, MariaDB, PHP + user public dir - 在 Ubuntu 上安裝 Nginx, MariaDB 10.6, PHP 8.3, PhpMyAdmin - 安裝 Wordpress - 寫 PHP, HTML, CSS 程式 ## 環境設定步驟 ### 1. ssh Doc: https://ubuntu.com/server/docs/service-openssh ```bash sudo apt update sudo apt upgrade ``` - 裝置 > 插入 Guest Addition - 點選 Run > 輸入密碼 > 按 Enter ``` sudo apt install openssh-client openssh-server ``` 軟體中心 > 搜尋 visual studio code > 安裝 ```bash sudo systemctl enable ssh sudo systemctl start ssh ``` 機器 > 設定 > 網路 > 連接埠轉送 > + > `0.0.0.0 | 22 | 10.0.2.15 | 22` 測試:回到 Windows 使用 命令提示字元 > `ssh 帳號@127.0.0.1` Microsoft Store > 搜尋 Windows Terminal > 安裝 ### 2. L(A/N)MP Doc: https://ubuntu.com/server/docs/lamp-applications Doc - Nginx: https://ubuntu.com/tutorials/install-and-configure-nginx#1-overview LNMP: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-22-04 #### Ubuntu setup ```bash sudo apt update ``` #### Nginx ```bash sudo apt install nginx ``` #### PHP ```bash sudo apt install php php-fpm php-mbstring php-xml php-curl php-zip php-bcmath php-cli php-pdo php-common php-tokenizer php-mysql php-json ``` #### PHP+Nginx ```bash cd /etc/nginx sudo nano /etc/nginx/sites-available/default sudo systemctl start php8.1-fpm sudo systemctl start nginx ``` ```bash= cd /var/www/html rm index.html rm index.nginx-debian.html sudo nano index.html ``` ##### 使用備援機 ```bash mkdir ~/www chmod a+x ~ chmod a+rx ~/www nano ~/www/index.html ``` 查看: https://帳號.u.sysh.shize.tw/index.html #### Wordpress ```bash= cd ~ wget https://tw.wordpress.org/latest-zh_TW.zip unzip latest-zh_TW.zip sudo mv wordpress/ /var/www/html/ sudo nano /etc/nginx/sites-available/default sudo systemctl reload nginx sudo nano /var/www/html/wordpress/wp-config.php ``` 查看: http://127.0.0.1/wordpress ##### 使用備援機 ```bash cd ~ wget https://tw.wordpress.org/latest-zh_TW.zip unzip latest-zh_TW.zip sudo mv wordpress/ ~/www/ sudo nano /var/www/html/wordpress/wp-config.php ``` 查看: https://帳號.u.sysh.shize.tw/wordpress #### MariaDB ```bash sudo apt install mariadb-server mariadb-client sudo mysql_secure_installation ``` 建立一組帳密及資料庫 ```bash sudo mysql CREATE USER '帳號'@'localhost' IDENTIFIED BY '密碼'; GRANT ALL PRIVILEGES ON *.* TO '帳號'@'localhost' WITH GRANT OPTION; CREATE DATABASE wordpress; ``` #### phpMyAdmin Ref: https://ui-code.com/archives/689 ```bash sudo apt install phpmyadmin ``` ```bash sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin ```
×
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