Docker部署LyChee图床(云相册)

Docker部署LyChee

最近用LyChee在centos服务器上部署了一个自己的云相册,当然也可以当图床用,为了简单一些,采用docker来部署,在此记录一下部署的过程。

文章目录

    • Docker部署LyChee
      • 1.检索镜像
      • 2. 前期准备
      • 3. 创建容器
      • 4. 配置云相册
      • 5. nginx跳转及https证书配置

1.检索镜像

在dockerhub上,可能存在多种镜像文件,挑一个下载量比较多的即可,本次我选择了官方的镜像 lycheeorg/lychee

docker pull lycheeorg/lychee

2. 前期准备

先安装mysql5.7数据库,这个因为网上有很多教程,这里就不再赘述了。
再此需要手动创建几个必备的映射目录

cd /home
mkdir lychee
cd lychee
mkdir conf
mkdir uploads
mkdir sym

3. 创建容器

按照官方的说明来即可,这里修改成你自己的数据库地址和用户名密码,还有端口号,-p

docker run -d \
--name=lychee \
-v /home/lychee/conf:/conf \
-v /home/lychee/uploads:/uploads \
-v /home/lychee/sym:/sym \
-e PUID=1000 \
-e PGID=1000 \
-e PHP_TZ=Asia/Hong_Kong \
-e DB_CONNECTION=mysql \
-e DB_HOST=127.0.0.1 \
-e DB_PORT=3306 \
-e DB_DATABASE=lychee \
-e DB_USERNAME=user \
-e DB_PASSWORD=password \
-p 8080:80 \
lycheeorg/lychee

# 检查运行状态,看容器是否已经起来了
docker ps 

4. 配置云相册

等容器起来之后,浏览器中输入地址及端口号,就可以根据系统的提示,进行相应的配置了,如配置用户名和密码,及一些页面显示标题等,具体就不细说了,如图所示的配置页面
Docker部署LyChee图床(云相册)_第1张图片

5. nginx跳转及https证书配置

其中免费的证书要自己去阿里云上申请,并拷贝到服务器自定义的目录下,因为我的服务器上还有一个自己的博客网站,所以就不得不再开一个端口,我又对nginx的rewrite语法不熟,所以就采用了比较笨的办法,一对一地址映射过去,所以看起来比繁琐。

server
{
        listen 443 ssl;
        server_name xxxx.cn www.xxxx.cn;
        ssl_certificate  /root/ssl/4903461_xxxx.cn.pem;
        ssl_certificate_key /root/ssl/4903461_xxxx.cn.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        location / {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8088;
        }
	location /images {
            	root /home/halo;
            	autoindex on;
        }
	location /photo {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/;
	}
	location /dist  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/dist/;
        }
	location /php  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/php;
        }

	location /api/Albums::get  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/api/Albums::get;
        }
	location /api/Album::get  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/api/Album::get;
        }

	location /api/Photo::get  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/api/Photo::get;
        }

	location /img  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/img;
        }
	location /uploads/thumb  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/uploads/thumb;
        }
	location /uploads/small  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/uploads/small;
        }
	location /uploads/medium  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/uploads/medium;
        }
	location /uploads/big  {
                proxy_buffer_size  128k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                proxy_pass http://127.0.0.1:8080/uploads/big;
        }

}
server
{
        listen 80;
        server_name xxxx.cn www.xxxx.cn;
        rewrite ^(.*)$ https://$host$1 permanent;
}

你可能感兴趣的:(Linux,docker,nginx,lychee,云相册,图床)