在本页
- 先决条件
- 开始之前
- 安装 LAMP 服务器
- 为 ProjectSend 创建数据库
- 下载 ProjectSend
- 为 ProjectSend 配置 Apache
- 访问 ProjectSend Web 界面
- 使用 Let's Encrypt SSL 保护 ProjectSend
- 结论
ProjectSend 是一款免费的开源文件和图片共享应用程序,可帮助您在公司与客户端之间共享文件。它是一款面向客户端的文件共享工具,允许您在任何服务器上上传和共享不受大小限制的文件。它使用 PHP 编写,并使用 MySQL 数据库来存储信息。它提供丰富的功能集,包括实时统计、自助注册、自助登录、自定义电子邮件模板等。
在本教程中,我们将向您展示如何在 Ubuntu 20.04 上使用 Apache 和 Let's Encrypt SSL 安装 ProjectSend 文件共享应用程序。
先决条件
- 一台运行 Ubuntu 20.04 的服务器。
- 一个指向您服务器 IP 的有效域名。
- 服务器上已配置 root 密码。
开始之前
首先,通过运行以下命令将系统软件包更新到最新版本:
apt-get update -y
所有软件包更新完成后,您可以继续下一步。
安装 LAMP 服务器
首先,您需要在服务器上安装 Apache、MariaDB、PHP 以及其他必需的扩展。您可以使用以下命令安装所有这些软件:
apt-get install apache2 mariadb-server imagemagick php libapache2-mod-php php-imagick php7.4-common php7.4-mysql php7.4-gd php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-bcmath php7.4-gmp
安装完所有软件包后,编辑 php.ini 文件:
nano /etc/php/7.4/apache2/php.ini
更改以下设置:
memory_limit = 512M upload_max_filesize = 32M max_execution_time = 300 date.timezone = Asia/Kolkata
保存并关闭文件,然后重启 Apache 服务以使更改生效:
systemctl restart apache2
完成后,您可以继续下一步。
为 ProjectSend 创建数据库
接下来,您需要为 ProjectSend 创建数据库和用户。
为此,请使用以下命令登录 MariaDB:
mysql
登录成功后,使用以下命令创建数据库和用户:
MariaDB [(none)]> create database projectsend;
MariaDB [(none)]> create user projectsend@localhost identified by 'password';
接下来,使用以下命令授予 projectsend 数据库的所有权限:
MariaDB [(none)]> grant all privileges on projectsend.* to projectsend@localhost;
接下来,使用以下命令刷新权限并退出 MariaDB:
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
完成后,您可以继续下一步。
下载 ProjectSend
接下来,您需要从其官方网站下载最新版本的 ProjectSend。您可以使用以下命令下载:
wget -O projectsend.zip https://www.projectsend.org/download/387/
下载完成后,使用以下命令解压缩下载的文件:
unzip projectsend.zip -d /var/www/html/projectsend
接下来,切换到解压后的目录,并重命名默认的配置文件:
cd /var/www/html/projectsend/includes
cp sys.config.sample.php sys.config.php
接下来,使用以下命令编辑配置文件:
nano sys.config.php
更改以下设置:
define('DB_DRIVER', 'mysql');
/** Database name */
define('DB_NAME', 'projectsend');
/** Database host (in most cases it's localhost) */
define('DB_HOST', 'localhost');
/** Database username (must be assigned to the database) */
define('DB_USER', 'projectsend');
/** Database password */
define('DB_PASSWORD', 'password');
保存并关闭文件,然后使用以下命令设置适当的权限和所有权:
chown -R www-data:www-data /var/www/html/projectsend
chmod -R 775 /var/www/html/projectsend
chmod 644 /var/www/html/projectsend/includes/sys.config.php
完成后,您可以继续下一步。
为 ProjectSend 配置 Apache
接下来,使用以下命令创建 apache 虚拟主机配置文件:
nano /etc/apache2/sites-available/projectsend.conf
添加以下几行:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/projectsend/ ServerName projectsend.example.com <Directory /var/www/html/projectsend/> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/example.com-error_log CustomLog /var/log/apache2/example.com-access_log common </VirtualHost>
保存并关闭文件,然后使用以下命令启用 rewrite 模块和虚拟主机配置文件:
a2enmod rewrite
a2ensite projectsend.conf
接下来,重启 Apache 服务以使更改生效:
systemctl restart apache2
现在,您可以使用以下命令检查 Apache 的状态:
systemctl status apache2
您应该会看到以下输出:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-06-02 07:11:08 UTC; 5min ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 17680 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
Main PID: 14862 (apache2)
Tasks: 6 (limit: 2353)
Memory: 25.0M
CGroup: /system.slice/apache2.service
??14862 /usr/sbin/apache2 -k start
??17684 /usr/sbin/apache2 -k start
??17685 /usr/sbin/apache2 -k start
??17686 /usr/sbin/apache2 -k start
??17687 /usr/sbin/apache2 -k start
??17688 /usr/sbin/apache2 -k start
Jun 02 07:11:08 ubuntu2004 systemd[1]: Starting The Apache HTTP Server...
访问 ProjectSend Web 界面
现在,打开 Web 浏览器并使用 URL http://projectsend.example.com 访问 ProjectSend Web 界面。您应该会看到以下页面:

提供您的站点名称、站点 URL、管理员用户名、密码,然后单击 Install 按钮。您应该会看到以下页面:

现在,单击 Login 按钮。您应该会看到以下页面:

提供您的管理员用户名和密码,然后单击 Log in 按钮。您应该会在以下页面上看到 ProjectSend 仪表板:

使用 Let's Encrypt SSL 保护 ProjectSend
使用 Let's Encrypt SSL 保护您的网站始终是一个好主意。首先,您需要安装 Certbot 客户端来安装和管理 SSL。默认情况下,Certbot 软件包包含在 Ubuntu 默认存储库中,因此您可以使用以下命令安装它:
apt-get install python3-certbot-apache -y
Certbot 安装完成后,运行以下命令以使用 Let's Encrypt SSL 保护您的网站:
certbot --apache -d projectsend.example.com
系统将要求您提供电子邮件地址并接受服务条款,如下所示:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator standalone, Installer None Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): [email protected] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Plugins selected: Authenticator apache, Installer apache Obtaining a new certificate Performing the following challenges: http-01 challenge for projectsend.example.com Enabled Apache rewrite module Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/projectsend-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/projectsend-le-ssl.conf Enabling available site: /etc/apache2/sites-available/projectsend-le-ssl.conf
接下来,选择是否将 HTTP 流量重定向到 HTTPS,如下所示:
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
输入 2 并按 Enter 键,为您的网站安装 Let's Encrypt SSL:
Enabled Apache rewrite module Redirecting vhost in /etc/apache2/sites-enabled/projectsend.conf to ssl vhost in /etc/apache2/sites-available/projectsend-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://projectsend.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=projectsend.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/projectsend.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/projectsend.example.com/privkey.pem Your cert will expire on 2021-12-23. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
结论
恭喜!您已在 Ubuntu 20.04 上成功安装 ProjectSend,并配置了 Apache 和 Let's Encrypt SSL。您现在可以轻松地从 ProjectSend Web 界面共享文件和图片。