Lychee是一个免费、开源、优雅且易于使用的照片管理系统,它配备了安全管理和共享服务器上的照片所需的所有必要功能。它允许您通过简单的 Web 应用程序在几秒钟内轻松管理(上传、移动、重命名、描述、删除或搜索)您的照片。
![](https://www.alaica.com/wp-content/uploads/linux-3.jpeg)
荔枝特点
- 一个令人惊叹的、漂亮的界面,可以直接从浏览器在一个地方管理您的所有照片。
- 一键共享照片和相册,并带有密码保护。
- 使用键盘以全屏模式查看所有图像,并使用键盘前进和后退导航,或者通过公开照片让其他人浏览您的照片。
- 支持从各种来源导入照片:本地主机、Dropbox、远程服务器或使用链接。
要安装 Lychee,您需要的只是一个正在运行的 Web 服务器,例如带有PHP 5.5或更高版本的Apache或Nginx以及一个MySQL 数据库。
出于本文的目的,我将在域名为lychee.example.com的RHEL 8 VPS上安装带有Nginx、PHP-FPM 7.0和MariaDB的Lychee照片管理系统。
第 1 步:安装 Nginx、PHP 和 MariaDB
1.首先安装Nginx、带有所需扩展的PHP和MariaDB数据库,以建立运行Lychee 的托管环境。
在 Cent/RHEL/Rocky Linux 和 AlmaLinux 上
# 百胜安装 https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm # 百胜安装http://rpms.remirepo.net/enterprise/remi-release-8.rpm # yum 安装 yum-utils # yum-config-manager --enable remi-php74 [安装 PHP 7.4] # yum 安装 nginx php php-fpm php-mysqli php-exif php-mbstring php-json php-zip php-gd php-imagick mariadb-server mariadb-client
在 Ubuntu 和 Debian 上
$ sudo apt install nginx php php-fpm php-mysqli php-exif php-mbstring php-json php-zip php-gd php-imagick mariadb-server mariadb-client
2.安装必要的软件包后,启动nginx、php-fpm和mariadb服务,在启动时启用它们并检查这些服务是否已启动并正在运行。
------------ CentOS/RHEL ------------ # systemctl 启动 nginx php-fpm mariadb # systemctl 状态 nginx php-fpm mariadb # systemctl 启用 nginx php-fpm mariadb
------------ Debian/Ubuntu ------------ $ sudo systemctl 启动 nginx php7.4-fpm mysql $ sudo systemctl 状态 nginx php7.4-fpm mysql $ sudo systemctl 启用 nginx php7.4-fpm mysql
3. Next, if you have a firewall enabled on your system, you need to open the ports 80 and 443 in the firewall to allow client requests to the Nginx web server on the HTTP and HTTPS respectively, as shown.
------------ Debian/Ubuntu ------------ $ sudo ufw allow 80/tcp $ sudo ufw allow 443/tcp $ sudo ufw reload
------------ CentOS/RHEL ------------ # firewall-cmd --zone=public --permanent --add-port=80/tcp # firewall-cmd --zone=public --permanent --add-port=443/tcp # firewall-cmd --reload
4. In order to run Lychee effectively, it is recommended to increase the values of the following properties in php.ini
file.
# vim /etc/php/php.ini #CentOS/RHEL $ sudo vim /etc/php/7.4/fpm/php.ini #Ubuntu/Debian
Search for these PHP parameters and change their values to:
max_execution_time = 200 post_max_size = 100M upload_max_size = 100M upload_max_filesize = 20M memory_limit = 256M
5. Now configure PHP-FPM to set the user and group, listen socket www.conf
file as explained.
# vim /etc/php-fpm.d/www.conf #CentOS/RHEL $ sudo vim /etc/php/7.0/fpm/pool.d/www.conf #Ubuntu/Debian
Look for the directives below to set the Unix user/group of processes (change www-data to nginx on CentOS).
user = www-data group = www-data
Also, change the listen directive on which to accept FastCGI requests to a Unix socket.
listen = /run/php/php7.4-fpm.sock
And set the appropriate ownership permissions for the Unix socket using the directive (change www-data to nginx on CentOS/RHEL).
listen.owner = www-data listen.group = www-data
Save the file and restart the nginx and php-fpm services.
# systemctl restart nginx php-fpm #CentOS/RHEL $ sudo systemctl restart nginx php7.4-fpm #Ubuntu/Debian
Step 2: Secure MariaDB Installation
6. In this step, you should secure the MariaDB database installation (which is unsecured by default if installed on a fresh system), by running the security script which comes with the binary package.
Run the following command as root, to launch the script.
$ sudo mysql_secure_installation
You will be prompted to set a root password, remove anonymous users, disable root login remotely and remove the test database. After creating a root password, and answer yes/y
to the rest of the questions.
Enter current password for root (enter for none): Set root password? [Y/n]y
Remove anonymous users? [Y/n]y
Disallow root login remotely? [Y/n]y
Remove test database and access to it? [Y/n]y
Reload privilege tables now? [Y/n]y
Step 3: Install Lychee Photo Management System
7. To install Lychee, first, you need to create a database for it with appropriate permissions using the following commands.
$ sudo mysql -u root -p MariaDB [(none)]> CREATE DATABASE lychee; MariaDB [(none)]> CREATE USER 'lycheeadmin'@'localhost' IDENTIFIED BY '=@!#@%$Lost'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON lychee.* TO 'lycheeadmin'@'localhost'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit
8. Next, move into the web document root and grab the latest version of Lychee using the git command-line tool, as shown.
$ cd /var/www/html/ $ sudo git clone --recurse-submodules https://github.com/LycheeOrg/Lychee.git
9. Then set the correct permissions and ownership on the installation directory as shown (replace admin with a username on your system).
------------ CentOS/RHEL ------------ # chown admin:nginx -R /var/www/html/Lychee/public # chmod 775 -R /var/www/html/Lychee/public
------------ Debian/Ubuntu ------------ $ sudo chown admin:www-data -R /var/www/html/Lychee/public $ sudo chmod 775 -R /var/www/html/Lychee/public
10. In this step, you need to set up composer in the lychee installation directory, which will be used to install PHP dependencies.
# cd Lychee/ # php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" # php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" # php composer-setup.php # php -r "unlink('composer-setup.php');" # php composer.phar update
Step 4: Configure Nginx Server Block for Lychee
12. Next, you need to create and configure an Nginx server block for the Lychee application under /etc/nginx/conf.d/.
# vim /etc/nginx/conf.d/lychee.conf
Add the following configuration in the above file, remember to use your own domain name instead of lychee.example.com (this is just a dummy domain).
server { listen 80; server_name lychee.example.com; root /var/www/html/Lychee/public; 索引index.html; 字符集utf-8; gzip 打开; gzip_types 文本/css 应用程序/javascript 文本/javascript 应用程序/x-javascript 图像/svg+xml 文本/纯文本/xsd 文本/xsl 文本/xml 图像/x-图标; 地点 / { try_files $uri $uri/ /index.php?$query_string; } 位置 ~ .php { 包含 fastcgi.conf; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } 位置 ~ /.ht { 否认一切; } }
然后保存文件并重新启动Nginx Web 服务器和PHP-FPM以应用最近的更改。
# systemctl 重新启动 nginx php-fpm #CentOS/RHEL $ sudo systemctl restart nginx php7.0-fpm #Ubuntu/Debian
第 5 步:通过 Web 浏览器完成 Lychee 安装
13.现在使用 URLlychee.example.com
在浏览器中打开 Lychee Web 安装程序,提供数据库连接设置,输入为 lychee 创建的数据库名称,然后单击“连接”。
![](https://www.alaica.com/wp-content/uploads/linux-410.png)
14.接下来,输入安装的用户名和密码,然后单击“创建登录”。登录后,您将进入管理仪表板,其中包含默认相册,如以下屏幕截图所示。
![](https://www.alaica.com/wp-content/uploads/linux-411.png)
要上传照片或从链接导入或从Dropbox或其他服务器导入或添加相册,请单击该+
标志。要查看相册中的照片,只需单击它即可。
欲了解更多信息,请访问Lychee主页:https ://lycheeorg.github.io/
Lychee是一个开源、易于使用且优雅的 PHP 照片管理系统,用于管理和共享照片。如果您有任何问题或意见,请使用下面的表格写信给我们。