#wiki: https://github.com/2233466866/lnmp/wiki
#安装docker
wget -O /etc/yum.repos.d/ali_docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce-18.09.9-3.el7
rm -f /etc/docker/*
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://ajvcw8qn.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
systemctl enable docker.service
#安装lnmp
mkdir -p /data/lnmp/www /data/lnmp/mysql
docker run -d
--name=lnmp
-p 80:80
-p 443:443
--privileged=true
--name=lnmp 2233466866/lnmp
docker cp lnmp:/www /data/lnmp
mkdir -p /data/lnmp/mysql
docker rm -f lnmp
docker run -d
--name=lnmp
-p 80:80
-p 443:443
-v /data/lnmp/www:/www
-v /data/lnmp/mysql:/data/mysql
--privileged=true
--name=lnmp registry.cn-hangzhou.aliyuncs.com/chenleilei/lnmp1
#mysql账号密码获取:
进入容器:
docker exec -it lnmp sh
mysql_init
‘上面操作后密码会被修改为 ASDFqwer1234#### ’
cat /var/log/mysqld.log|grep 'A temporary password'
或者:
password=`cat /var/log/mysqld.log|grep 'A temporary password'`;password=${password:91};echo $password
#配置mysql账号密码
mysql -uroot -pASDFqwer1234####
create database wordpress;
set global validate_password_length=6; #设置密码策略
grant all on wordpress.* to wordpress@'%' identified by '123456';
安装:
cd /data/lnmp/www/wordpress
cp wp-config-sample.php wp-config.php
vim wp-config.php
改为以下:
/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');
/** MySQL数据库用户名 */
define('DB_USER', 'wordpress');
/** MySQL数据库密码 */
define('DB_PASSWORD', '123456');
/** MySQL主机 */
define('DB_HOST', '127.0.0.1');
/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');
/** 数据库整理类型。如不确定请勿更改 */
define('DB_COLLATE', '');
结果: