LAMP下Chevereto图床搭建
Markdown语法支持图片链接的插入,但是最近我经常用到的几个图床网站都出现了莫名的bug,俗话说自己动手丰衣足食,所以打算在闲置吃灰的云服务器上运行一个图床。简单在网上查了一下,部署相对简单且用户友好的图床有Chevereto,下面这张图片就是上传到这台服务器上图床的,速度蛮快的。
废话不多说,开始介绍Chevereto搭建步骤
环境
- 运行Ubuntu 16.04的云服务器
- 拥有
sudo
权限的非root用户
依赖
在开始前请安装下列软件包
1 | # 更新系统 |
下边可以继续安装 LAMP server
Chevereto运行在 Apache web server, written in PHP languages 并且使用 MariaDB来存储他们的数据.所以你需要在你的系统上安装 LAMP(Apache,PHP,MariaDB)
1 | sudo apt-get install apache2 libapache2-mod-php7.0 mariadb-server mariadb-client php7.0 php7.0-mysql php7.0-dom php7.0-gd php7.0-mbstring php7.0-common bc php7.0-bcmath -y |
配置数据库
默认数据库是不安全的,你可以通过下列命令使其安全
1 | mysql_secure_installation |
This command will set the root password, remove anonymous user, disallow root login remotely and remove test database.
按照下面的例子回答问题
1 | Set root password? [Y/n] n |
数据库安全配置好之后,你需要为Chevereto创建一个数据库和用户.首先,用下列命令登录数据库Shell
1 | mysql -u root -p |
输入你的密码,然后用下列命令为Chevereto创建一个数据库及用户
1 | MariaDB [(none)]>CREATE DATABASE cheveretodb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; |
下面为Chevereto创建一个用户并赋予访问修改 Chevereto数据库的权限
1 | MariaDB [(none)]>GRANT ALL PRIVILEGES ON cheveretodb.* TO 'chevereto'@'localhost' IDENTIFIED BY 'password'; |
用下面的命令更新
1 | MariaDB [(none)]>FLUSH PRIVILEGES; |
下载安装Chevereto
1 | # 下面开始从git仓库下载安装最新版本的 Chevereto |
在settings.php
文件中写入以下内容
1 | <?php |
保存退出文件,然后给 Chevereto 文件夹正确的权限
1 | sudo chown -R admin:admin /var/www/html/chevereto |
为Chevereto配置Apache
Next, you will need to create an Apache virtual host directive for Chevereto. You can do this by creating chevereto.conf file inside /etc/apache2/sites-available directory:
在文件中写入下列内容
1 | <VirtualHost *:80> |
保存关闭文件,然后使配置生效
1 | sudo a2ensite chevereto |
配置防火墙
1 | sudo ufw enable |
访问网站链接
你的数据库信息如下
1 | Database host : localhost |
提供你的admin user 如下
1 | Admin username : admin |
Next, click on the Install Chevereto button. You will be redirected to the Installation Completed page. Click on the admin dashboardbutton. You will be redirected to the Chevereto login page.
Now, enter your admin username and password and click on the sign in button. You will be redirected to the Chevereto dashboad.
真正有趣的部分