安裝Chevereto

安裝準備

官網
按照要求,上傳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密碼:

  1. 以root身份在終端登陸,必須
  2. 輸入 mysqladmin -u root -p password root
    後面的 root 是要設置的密碼
  3. 回車後出現 Enter password
    輸入就密碼,如果沒有,直接回車

創建用戶

  1. 以root登錄數據庫:mysql -u root -p
  2. SHOW DATABASES 可以查看數據庫
  3. use mysql 使用這個數據庫
  4. SHOW TABLES 查看其中的表,裏面user這個存放的是用戶名
  5. SELECT User,Host,Password FROM mysql.user; 可以查看當前的用戶名和密碼
  6. insert into mysql.user(Host,User,Password) values("localhost","admin",password("admin")); 創建新用戶
  7. 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文檔。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章