LDNMP多网站共存解决方案!
本位学习资料将实现一台VPS多个网站运行
更新系统
apt update -y && apt upgrade -y && apt install -y curl wget sudo socat unzip
安装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
https://github.com/kejilion/docker/blob/main/LNMP-docker-compose.yml
申请证书
curl https://get.acme.sh | sh
~/.acme.sh/acme.sh --register-account -m xxxx@gmail.com --issue -d wp1.kejilion.eu.org -d wp2.kejilion.eu.org -d wp3.kejilion.eu.org --standalone --key-file /home/web/certs/key.pem --cert-file /home/web/certs/cert.pem --force
NGINX配置
https://github.com/kejilion/nginx/blob/main/nginx.conf
下载源码
wordpress
cd /home/web/html/ && mkdir wp1 && wget https://cn.wordpress.org/wordpress-6.2.2-zh_CN.zip && unzip wordpress-6.2.2-zh_CN.zip -d wp1 && rm wordpress-6.2.2-zh_CN.zip
运行
cd /home/web && docker-compose up -d
赋予权限
docker exec -it nginx 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'
重启php
docker restart php
跳过FTP更新主题插件的限制
echo "define('FS_METHOD', 'direct');" >> /home/web/html/wp1/wordpress/wp-config.php
echo "define('FS_METHOD', 'direct');" >> /home/web/html/wp2/wordpress/wp-config.php
echo "define('FS_METHOD', 'direct');" >> /home/web/html/wp3/wordpress/wp-config.php
调整上传文件大小限制
docker exec -it php sh -c 'echo "upload_max_filesize=50M \n post_max_size=50M" > /usr/local/etc/php/conf.d/uploads.ini'
重启服务器
reboot
评论
发表评论