I don't work with WP neither PHP. But sometimes I'm asked to have a look at a wordpress site (we've all been through this ... sight)
Instead of installing LAMP or whatever, I'd rather sandbox the shit in a docker, so I can easily uninstall everything once done.
I find the docker-compose
approach as suggested in the official wordpress docker kind of complicated.
Instead, since it is for development purpose only, I'd rather have a single Docker that would contain the whole PHP + MySQL config, and simply having to:
Replace DB_NAME
, DB_USER
, DB_PASSWORD
and DB_HOST
in wp-config.php
Import the SQL of the existing DB. Eg. docker run mydocker /bin/mysql-import ~/Desktop/export.sql
docker start mydocker --source ~/Workspace/myproject
Does this approach make sense? Are there any ressource I could find to achieve this (if it hasn't been done already)?
答案 0 :(得分:0)
这肯定会有所改进,但这是我采取的步骤:
docker pull linode/lamp
sudo docker run -p 80:80 -v <local_path_to_site_sources>:/var/www/<sitename> -t -i linode/lamp /bin/bash
在此步骤中,您已将Docker的端口80转发给您的主机80(这意味着您可以尝试http://localhost并获得结果),并使用包含您的来源的/var/www/<sitename>
输入到docker的bash中代码。
不幸的是还有一些小配置要做,这应该是自动化的恕我直言。
apt-get update
(不再是sudo,你是root用户)apt-get install php5-mysql
(由于某些不幸的原因,包裹丢失了)/var/www/<sitename>/log
mkdir -p /var/www/<sitename>/log
存在
使用以下内容运行nano /etc/apache2/sites-available/<sitename>.conf
(所有内容详细there):
ServerAdmin网站管理员@#可能不是强制性的 ServerAlias#可能不是强制性的
#Index文件和文档根目录(公共文件所在的位置) DirectoryIndex index.html index.php DocumentRoot / var / www / #日志文件位置 LogLevel警告 ErrorLog /var/www//log/error.log CustomLog /var/www//log/access.log结合起来
运行a2ensite <sitename>
mysql -u root -p
密码:Admin2015
,如[{3}} create database <dbname>;
然后exit
导入当前数据(如果存在):mysql -u root -p <dbname> < <dbbackupfile>.sql
(请注意,<dbbackupfile>.sql
需要在泊坞窗中可用,因此输入<local_path_to_site_sources>
会有所帮助。
更新(来自您的主机,而不是泊坞窗,共享文件)wp-config.php
:
/ ** Nom de la basededonnéesdeWordPress。 * / define('DB_NAME','');
/ **实用主义者基地dedonnéesMySQL。 * / define('DB_USER','root');
/ **基地deDonnéesMyrode passe de la basededonnéesMicrosoft。 * / define('DB_PASSWORD','Admin2015');/ ** Adresse de l'hébergementMySQL。 * / define('DB_HOST','127.0.0.1');
运行service apache2 restart; service mysql restart
去检查here:annnnnndd DONE !!