以docker部署wordpress

首先用下列指令建立一個名稱為wordpress_db的mysql container.

docker run -d \
  --restart=always \
  --name wordpress_db \
  -e MYSQL_ROOT_PASSWORD=xxxxxxxxx \
  mysql:latest

其中xxxxxxxxx是資料庫root的密碼.

接著建立一個名稱為wordpress_web的wordpress container,並將剛剛建立的wordpress_db連結成mysql.

docker run -d \
  --rworestart=always \
  --name wordpress_web \
  -e VIRTUAL_HOST=slanla.com \
  --link wordpress_db:mysql \
  -p 23456:80 \
  wordpress

其中23456為對外聯繫的port. 閱讀全文

php.ini 常見設定

php.ini檔案位置/etc/php5/apache2/php.ini
php-fpm檔案位置/etc/php5/fpm/php.ini
而php cli位置應該是在 /etc/php5/cli/php.ini

sudo vim /etc/php5/apache2/php.ini
# or
sudo vim /etc/php5/fpm/php.ini
# or
sudo vim /etc/php5/cli/php.ini

可以用下列指令確認

php -i |grep php\.ini

我個人常用的設定為(for debug):

short_open_tag=On
memory_limit=2000M
error_reporting=E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT
display_error=On
post_max_size=20000M
upload_max_filesize=20000M
max_file_uploads=200

其中,memory_limit > post_max_size > upload_max_filesize

修改之後,得要重新啟動apache2

sudo /etc/init.d/apache2 restart
# or
sudo service apache2 restart

vim 快速修改方式:

#for apache2
sudo vim /etc/php5/apache2/php.ini
:1,$s/short_open_tag\ =\ Off/short_open_tag\ =\ On/g
:1,$s/memory_limit\ =\ 128M/memory_limit\ =\ 2000M/g
:1,$s/display_errors\ =\ Off/display_errors\ =\ On/g
:1,$s/post_max_size\ =\ 8M/post_max_size\ =\ 2000M/g
:1,$s/upload_max_filesize\ =\ 2M/upload_max_filesize\ =\ 2000M/g
:1,$s/max_file_uploads\ =\ 20/max_file_uploads\ =\ 200/g
/error_reporting
/
:1,$s/error_reporting\ =\ E_ALL\ &\ \~E_DEPRECATED\ &\ \~E_STRICT//g
aerror_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT
#for cli
sudo vim /etc/php5/cli/php.ini
:1,$s/short_open_tag\ =\ Off/short_open_tag\ =\ On/g
:1,$s/memory_limit\ =\ 128M/memory_limit\ =\ 2000M/g
:1,$s/display_errors\ =\ Off/display_errors\ =\ On/g
:1,$s/post_max_size\ =\ 8M/post_max_size\ =\ 2000M/g
:1,$s/upload_max_filesize\ =\ 2M/upload_max_filesize\ =\ 2000M/g
:1,$s/max_file_uploads\ =\ 20/max_file_uploads\ =\ 200/g
/error_reporting
/
:1,$s/error_reporting\ =\ E_ALL\ &\ \~E_DEPRECATED\ &\ \~E_STRICT//g
aerror_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT