# 系統
Linux huanghetest 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
1、安裝LAMP或LEMP
# 更新系統包
sudo apt update
sudo apt upgrade
# 安裝LAMP(Linux, Apache, MySQL, PHP)
# 或者安裝LEMP(Linux, Nginx, MySQL, PHP)
# 我這里已經有Nginx和Mysql了覆致,所以我這里只安裝PHP擴展
sudo apt install php-fpm php-mysql php-xml php-gd php-mbstring php-zip
二侄旬、下載并安裝WordPress
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
root@huanghetest:/var/www/wordpress# ls
index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php
license.txt wp-admin wp-config-sample.php wp-includes wp-login.php wp-signup.php
readme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php
三、配置MySQL數據庫
# 使用mysql-workbench創(chuàng)建一個庫wordpressdb煌妈;
CREATE DATABASE wordpressdb;
# 配置數據庫信息
cp wp-config-sample.php wp-config.php
vi wp-config.php
# 修改數據庫的名稱儡羔、賬號、密碼璧诵、HOST
define( 'DB_NAME', 'database_name_here' );
/** Database username */
define( 'DB_USER', 'username_here' );
/** Database password */
define( 'DB_PASSWORD', 'password_here' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
四汰蜘、配置Nginx
# 將 your_domain_or_IP 按實際情況修改;
# 將/var/www/html 改為 /var/www/wordpress之宿;
server {
listen 8881 ssl;
server_name your_domain_or_IP;
error_log /var/log/nginx-error.log info;
ssl_certificate /usr/local/nginx/cert/3682644__.pem;
ssl_certificate_key /usr/local/nginx/cert/3682644__.key;
ssl_session_timeout 8m;
root /var/www/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # 根據你的PHP版本調整
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
#
mkdir snippets
chmod -R 777 snippets
cp /etc/nginx/snippets/fastcgi-php.conf /usr/local/nginx/conf/snippets
# 檢查nginx是否有語法錯誤 sudo nginx -t
# 重啟nginx /usr/local/nginx/sbin/nginx
sudo systemctl status php7.2-fpm.service
sudo systemctl enable php7.2-fpm.service
六族操、訪問 your_domain_or_IP:8881