使用Docker搭wordpress并启用sqlite

1、准备物料

  • docker
  • nginx
  • wordpress镜像
  • mysql镜像

2、启动mysql镜像

docker run -itd --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql

3、启动wordpress 镜像

docker run -itd --name wordpress \ 
-v /wordpress/themes:/var/www/html/wp-content/themes/ \  
-v /wordpress/plugins:/var/www/html/wp-content/plugins \  
-v /wordpress/uploads:/var/www/html/wp-content/uploads \ 
-v /wordpress/database:/var/www/html/wp-content/database/ \ 
-p 60000:80 wordpress

4、进行初始化安装(此步骤需要连接mysql)

5、登录后台,查找 SQLite Database Integration 插件,根据提示重新安装wordpress

6、配置nginx

server {

    listen 443 ssl;
    listen 80;
    server_name zuole.net;

    access_log logs/zuole.net.log;
    error_log logs/zuole.net.log;

    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem; 


    location / {
	proxy_pass http://127.0.0.1:6000;
	proxy_redirect  off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;

    }
}

7、在wp-config.php里添加如下代码

define('FORCE_SSL_ADMIN', true);

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false){
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = 443;
}
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

define('WP_HOME','https://zuole.net/');
define('WP_SITEURL','https://zuole.net/');

8、安装好后,登录后台,右上角显示 Database: SQLite,说明安装成功。

9、清理mysql镜像,安装成功

docker stop mysql
docker rm mysql
docker rmi mysql

You May Also Like

More From Author

+ There are no comments

Add yours