docker下LNMP环境搭建
更新系统
apt update -y && apt upgrade -y && apt install -y curl wget sudo socat
安装docker
curl -fsSL https://get.docker.com | sh curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
创建目录
cd /home
mkdir web
cd web
mkdir html
mkdir mysql
mkdir certs
touch nginx.conf
nano docker-compose.yml
配置docker-compose
https://github.com/kejilion/docker/blob/main/LNMP-docker-compose.yml
NGINX配置
https://github.com/kejilion/nginx/blob/main/nginx5.conf
测试项目
wordpress
cd /home/web && wget https://cn.wordpress.org/wordpress-6.2.2-zh_CN.zip && sudo apt-get install -y unzip && unzip wordpress-6.2.2-zh_CN.zip -d html && rm wordpress-6.2.2-zh_CN.zip && mv /home/web/html/wordpress/* /home/web/html/
运行
cd /home/web && docker-compose up -d
赋予权限
docker exec -it nginx chmod -R 777 /var/www/html
docker exec -it php chmod -R 777 /var/www/html
安装PHP扩展
docker exec php apt update && docker exec php apt install -y libmariadb-dev-compat libmariadb-dev libzip-dev libmagickwand-dev imagemagick
docker exec php docker-php-ext-install mysqli pdo_mysql zip exif gd intl bcmath opcache
docker exec php pecl install imagick && docker exec php sh -c 'echo "extension=imagick.so" > /usr/local/etc/php/conf.d/imagick.ini'
docker exec -it php sh -c 'echo "upload_max_filesize=50M \n post_max_size=50M" > /usr/local/etc/php/conf.d/uploads.ini'
重启php
docker restart php
可以去访问你的域名了,完成wp安装向导后再输入下面的命令!
跳过FTP更新主题插件的限制
echo "define('FS_METHOD', 'direct');" >> /home/web/html/wp-config.php