Docker部署LyChee
最近用LyChee在centos服务器上部署了一个自己的云相册,当然也可以当图床用,为了简单一些,采用docker来部署,在此记录一下部署的过程。
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. 配置云相册
等容器起来之后,浏览器中输入地址及端口号,就可以根据系统的提示,进行相应的配置了,如配置用户名和密码,及一些页面显示标题等,具体就不细说了,如图所示的配置页面
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; }
转载声明:本站文章若无特别说明,皆为原创,转载请注明来源:www.88531.cn资享网,谢谢!^^
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END