安装准备
官网
按照要求,上传index.php到服务器,得到下面的信息:
Your websever lacks some requirements that must be fixed to install Chevereto.
Please check:
Enable curl, mbstring and PDO_MYSQL PHP extensions
Enable ZipArchive PHP class
No PHP 1 permission in /var/www/chevereto/
No PHP 1 permission in /var/www/chevereto/index.php
Enable PHP cURL
需要安装:
sudo apt install php-curl php-mbstring php-mysql php-zip
出现以下错误:
The requested URL /install was not found on this server.
根据作者解答, 需要:
Apache: Check if mod_rewrite is loaded and configured properly (allowOverride).
Nginx: Make sure to add the rules that you will find in the download package.
解决方案:
在这个讨论里,提到了.htaccess
文件。
经过搜索,apache官网推荐在<Directory>
中指定htaccess的内容,因此,修改/etc/apache2/apache2.conf
的内容为:
0 <Directory /media/sata1/www/>
1 Options Indexes FollowSymLinks MultiViews
2 AllowOverride All
3 Require all granted
4 #Order allow,deny
5 #Allow from all
6 # Disable server signature
7 ServerSignature Off
8
9
10
11 # Disable directory listing (-indexes), Multiviews (-MultiViews) and enable Follow system links (+FollowSymLinks)
12 Options -Indexes
13 Options -MultiViews
14 Options +FollowSymLinks
15
16 <IfModule mod_rewrite.c>
17
18 RewriteEngine On
19
20 # If you have problems with the rewrite rules remove the "#" from the following RewriteBase line
21 # You will also have to change the path to reflect the path to your Chevereto installation
22 # If you are using alias is most likely that you will need this.
23 #RewriteBase /
24
25 # 404 images
26 # If you want to have your own fancy "image not found" image remove the "#" from RewriteCond and RewriteRule lines
27 # Make sure to apply the correct paths to reflect your current installation
28 RewriteCond %{REQUEST_FILENAME} !-f
29 RewriteRule images/.+\.(gif|jpe?g|png|bmp) - [NC,L,R=404]
30 #RewriteRule images/.+\.(gif|jpe?g|png|bmp) content/images/system/default/404.gif [NC,L]
31
32 RewriteCond %{REQUEST_FILENAME} !-f
33 RewriteCond %{REQUEST_FILENAME} !-d
34 RewriteCond %{REQUEST_URI} !\.(css|js|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|
35 RewriteRule . index.php [L]
36
37 </IfModule>
38 </Directory>
以上内容来自于讨论中的htaccess
文件。
配置数据库
使用的是Mariadb数据库,这是一个替代mysql的数据库。
设置root密码:
- 以root身份在终端登陆,必须
- 输入 mysqladmin -u root -p password root
后面的 root 是要设置的密码 - 回车后出现 Enter password
输入就密码,如果没有,直接回车
创建用户
- 以root登录数据库:
mysql -u root -p
SHOW DATABASES
可以查看数据库use mysql
使用这个数据库SHOW TABLES
查看其中的表,里面user这个存放的是用户名SELECT User,Host,Password FROM mysql.user;
可以查看当前的用户名和密码insert into mysql.user(Host,User,Password) values("localhost","admin",password("admin"));
创建新用户flush privileges;
刷新系统权限表
以上就完成了新用户的创建。
更改安全权限
使用mysql_secure_installation
命令更改安全权限。
主要是回答以下问题:
Set root password? [Y/n] n
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
修改mariadb默认存储位置
参考这个
其中,复制这一步可以使用rsync:
sudo rsync -av /var/lib/mysql ./mysql-data/
在修改datadir,socket属性的时候,要注意,在ubuntu中,需要修改/etc/mysql/mariadb.cnf
,但是其中声明了几个cnf文件的顺序,并且指出重复的变量以后出现的为准,因此需要将后面出现的datadir及Socket属性注释掉。
创建数据库
参照这个
CREATE DATABASE cheveretodb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON cheveretodb.* TO 'chevereto'@'localhost' IDENTIFIED BY 'password';
以上设置用户名为chevereto,密码为password,在后续设置是会使用。
连接数据库
php需要连接数据库,因此需要修改php.ini中的pdo_mysql.default_socket
的值为mariadb.cnf
中的sock文件的路径。
然后重启apach2即可。
否则会报错:
sqlstate[hy000] [2002] No such file or directory in
小结
至此就完成了chevereto的安装。后续使用可以摸索一下api文档。