docker-compose搭建lsky Pro 兰空 自建图库,php:7.3-apache
docker-compose搭建lsky Pro 自建图库这里写目录标题docker-compose搭建lsky Pro 自建图库注意事项docker-compose.yaml000-default.confentrypoint.shDockerfile开幕雷击,Docker镜像已经上传了,要用自己去下,点击我跳转源文件Github我已经在里面添加了阿里云的PHP加速了,构建速度会快很多RUN s
docker-compose搭建lsky Pro 自建图库
这里写目录标题
镜像包:https://hub.docker.com/repository/docker/zyugat/lskypro
构建文件:https://github.com/zyugat/lsky-DockerCompose-php7.3apache
1、思路
用Docker-Compose构建mysql+lskypro,然后用LNMP反向代理到域名。
2、拉取镜像
首先感谢这位大哥的Dockerfile文件,真的标准,我是在他的基础上加了个国内阿里云加速。
阿里云加速
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list && \
apt-get clean
docker pull zyugat/lskypro:1.6.3
docker pull zyugat/lskypro:1.6.3-noVolume
3、构建文件
./mysql/init
:初始化数据库
CREATE DATABASE IF NOT EXISTS lsky DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
docker-compose
# yml文件
version: '3'
services:
mysql-main:
image: mysql:5.7.22
restart: always
#名称(可以为空)
hostname: mysql-main
#容器名称
container_name: mysql-main
# 修改加密规则
command: --default-authentication-plugin=mysql_native_password
ports:
- "9306:3306"
volumes:
- mysql-data:/var/lib/mysql
- mysql-conf:/etc/mysql
- mysql-log:/var/log/mysql
- ./mysql/init:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: mysqlpsw
networks:
- mysql-net
lskypro:
# build:
# # 指定dockerfile文件的所在路径
# context: ./lskypro
# # 指定Dockerfile文件名称
# dockerfile: Dockerfile
image: zyugat/lskypro:1.6.3
restart: always
hostname: lskypro
container_name: lskypro
ports:
- "9080:80"
volumes:
- lsky-data:/var/www/html
networks:
- mysql-net
volumes:
mysql-data:
mysql-conf:
mysql-log:
lsky-data:
networks:
mysql-net:
/lskypro/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
/lskypro/entrypoint.sh
#!/bin/bash
set -eu
if [ ! -e '/var/www/html/public/index.php' ]; then
cp -a /var/www/lsky/* /var/www/html/
cp -a /var/www/lsky/.env.example /var/www/html
fi
chown -R www-data /var/www/html
chgrp -R www-data /var/www/html
chmod -R 777 /var/www/html/
exec "$@"
/lskypro/Dockerfile
FROM php:7.3-apache
RUN a2enmod rewrite
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list && \
apt-get clean
##安装相关拓展
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
exiftool \
zlib1g-dev \
libzip-dev \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install exif \
&& docker-php-ext-configure exif --enable-exif \
&& docker-php-ext-install pdo pdo_mysql \
&& docker-php-ext-install zip \
&& cd /usr/local/bin && ./docker-php-ext-install mysqli \
&& rm -rf /var/cache/apk/*
RUN { \
echo 'post_max_size = 10M;';\
echo 'upload_max_filesize = 10M;';\
echo 'max_execution_time = 300S;';\
} > /usr/local/etc/php/conf.d/docker-php-upload.ini;
RUN { \
echo 'opcache.enable=1'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=10000'; \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.save_comments=1'; \
echo 'opcache.revalidate_freq=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
\
echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \
\
echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \
\
mkdir /var/www/data; \
chown -R www-data:root /var/www; \
chmod -R g=u /var/www
COPY ./ /var/www/lsky/
# COPY ./apache2.conf /etc/apache2/
COPY ./000-default.conf /etc/apache2/sites-enabled/
COPY entrypoint.sh /
# COPY ./docker-php.conf /etc/apache2/conf-enabled
WORKDIR /var/www/html/
VOLUME /var/www/html
EXPOSE 80
RUN chmod a+x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apachectl","-D","FOREGROUND"]
4、运行
进入目录,我的是:cd /home/docker
运行:docker-compose up -d
测试:IP:9080
如果能打开就说明,你已经成功一半了,如果无法访问,检查防火墙有没有开启9080端口
5、配置lnmp反向代理
添加虚拟主机:lnmp vhost add
自己添加,这里不做多说明。
添加完后,编辑文件:vim /usr/local/nginx/conf/vhost/你的域名.conf
,在server里添加:
location / {
proxy_pass http://127.0.0.1:9080;
index index.html index.htm index.jsp;
}
防跨目录设置
参考:https://github.com/wisp-x/lsky-pro/issues/31
cd /opt/lnmp1.x/tools
./remove_open_basedir_restriction.sh
你可能会遇到的问题:
使用域名访问的时候报错,无法找到static目录,同时一直在转圈,无法保存配置。
GET https://域名/static/app/iconfont/iconfont.css net::ERR_ABORTED 404
GET https://域名/static/app/css/app.css?v=1.5 404
GET https://域名/static/app/css/markdown.css?v=1.0 net::ERR_ABORTED 404
...
解决办法:
编辑文件:vim /usr/local/nginx/conf/vhost/你的域名.conf
将以下内容全部注释,即可。
# location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
# {
# expires 30d;
# }
# location ~ .*\.(js|css)?$
# {
# expires 12h;
# }
# location ~ /.well-known {
# allow all;
# }
# location ~ /\.
# {
# deny all;
# }
6、获取连接数据库的地址
查询方式:docker network inspect docker_mysql-net
连接数据库地址:172.19.0.1
更多推荐
所有评论(0)