title: 【从零开始配置VPS】04:WordPress tags: [] id: '2099' categories:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8081:80
environment:
WORDPRESS_DB_HOST: 172.17.0.1
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: wordpress
volumes:
- ./www:/var/www/html
mkdir -p ~/app/WordPress && cd ~/app/WordPress && nano docker-compose.yml
sudo docker-compose up -d
反代 8081
cd ~/app/WordPress/www
wget https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1.php -O .php
访问 limour.top/.php
服务器:172.17.0.1
用户名:root
密码:ROOT_ACCESS_PASSWORD
左侧输入框填写数据库名字 wordpress
右边的编码选择 utf8mb4_general_ci
创建好数据库之后,默认进入该数据库的表和视图,在该界面点击“权限”链接
在此界面点击“创建用户”链接
权限 勾选 All privileges
用户名 wordpress
密码 examplepass
访问 limour.top
按提示完成初始化
if(isset($_SERVER['HTTP_X_REAL_IP'])) {
$list = explode(',',$_SERVER['HTTP_X_REAL_IP']);
$_SERVER['REMOTE_ADDR'] = $list[0];
$_SERVER['HTTPS']='on';
$_SERVER["SERVER_PORT"] = 443;
define('WP_HOME', 'https://'.$_SERVER['HTTP_HOST']);
define('WP_SITEURL', 'https://'.$_SERVER['HTTP_HOST']);
define('WP_CONTENT_URL', 'https://'.$_SERVER['HTTP_HOST'].'/wp-content');
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);
}
nano ~/app/WordPress/www/wp-config.php
添加以上代码
Easy WP SMTP
WP-Optimize
sudo docker exec -it wordpress-wordpress-1 bash
php -i grep php.ini
ls /usr/local/etc/php
exit
cd ~/app/WordPress
sudo docker cp wordpress-wordpress-1:/usr/local/etc/php/php.ini-production ./php.ini
nano ./php.ini
upload_max_filesize = 20M
post_max_size = 20M
sudo docker cp ./php.ini wordpress-wordpress-1:/usr/local/etc/php/php.ini
sudo docker-compose restart