环境
Centos7
Nginx 1.16.0
PHP 7.2.21
Mariadb 10.3.17
Chevereto 1.1.3
相关环境的安装
-
Nginx的安装: Centos7: Nginx安装与配置
-
Mariadb的安装: Centos7: Mariadb安装与配置
-
PHP7.2的安装: Centos7: PHP7.2安装与配置
-
Chevereto的下载:
进入Centos7的环境下:
1
2
3
4
5
6
7
8
9
10
11# 进入用户目录
cd ~
# 利用wget下载chevereto-free
wget https://github.com/Chevereto/Chevereto-Free/archive/1.1.3.zip
# 解压
unzip 1.1.3.zip
# 将解压后的文件移动并且更改文件名
sudo mv Chevereto-Free-1.1.3 /var/www/chevereto
# 设置权限
sudo chown -R nginx:nginx /var/www/chevereto
sudo chmod -R 775 /var/www/chevereto
相关环境的配置
-
Nginx配置:
如果在之前你没有在
conf.d
配置过其他的网络服务, 那么这里的default.conf
文件直接重命名令其失效(如果之前配置过其他的网络服务, 那么直接在chevereto.conf文件中的服务名那里设置为二级域名, 并且在DNS服务商里设置二级域名的A类型):1
sudo mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
添加Nginx新的配置:
1
sudo vim /etc/nginx/conf.d/chevereto.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54server {
listen 443;
server_name <your_ip/domain>;
root /var/www/chevereto/;
index index.php;
# 这里是申请的ssl证书的存放地址
ssl_certificate "/etc/letsencrypt/live/<domain>/fullchain.pem";
ssl_certificate_key "/etc/letsencrypt/live/<domain>/privkey.pem";
#Chevereto: Disable access to sensitive files
location ~* /(app|content|lib)/.*\.(po|php|lock|sql)$ {
deny all;
}
#Chevereto: CORS headers
location ~* /.*\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js) {
add_header Access-Control-Allow-Origin "*";
}
#Chevereto: Upload path for image content only and set 404 replacement
# 添加错误页面, 利于搜索引擎收录及良好的用户体验
location ^~ /images/ {
location ~* (jpe?g|png|gif) {
log_not_found off;
error_page 404 /content/images/system/default/404.gif;
}
return 403;
}
#Chevereto: Pretty URLs
location / {
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
# 添加对php的解析
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 注意该处文件的确切位置
include /etc/nginx/fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
# 接受http访问, 并进行301重定向
server {
listen 80;
server_name <your_ip/domain>;
if ($request_method = GET) {
return 301 https://$server_name$request_uri;
}
return 308 https://$server_name$request_uri;
}Notice:
如果没有申请过SSL证书进行网络服务访问的加密, 则不需要对443端口的监听以及301重定向. -
PHP配置:
对php.ini文件进行配置:
1
sudo vim /etc/php.ini
1
2
3
4
5max_execution_time = 60
max_input_time = 60
memory_limit = 512M
upload_max_filesize = 20M
post_max_size = 20M对php-fpm进行配置:
1
sudo vim /etc/php-fpm.d/www.conf
1
2user = nginx
group = nginx当然, 对于上面两个文件还有更加快捷配置的办法, 利用Sed命令, 可以对数据进行搜寻并替换:
1
2# Sed可以用行为单位进行部分数据的搜寻并取代, -i:插入
sudo sed -i 's/要被取代的字串/新的字串/g'配置权限:
1
2sudo chown -R nginx:nginx /var/lib/php/session
sudo chmod -R 775 /var/lib/php/session -
Mariadb配置:
这里可以参考Centos7: Mariadb安装与配置中的配置部分, 启动服务以及创建数据库:
1
2
3
4
5# 启动服务
sudo systemctl start mariadb
sudo systemctl enable mariadb
# 设置root密码
sudo mysql_secure_installation1
2
3
4
5
6
7mysql -u root -p
# 输入密码
create database <dataname>;
create user <username> identified by '<user_password>';
grant all privileges on <dataname>.* to <username>@'localhost' identified by '<user_password>';
flush privileges;
quit; -
对其他服务进行配置:
1
2
3
4sudo systemctl enable nginx && \
sudo systemctl start nginx && \
sudo systemctl enable php-fpm && \
sudo systemctl start php-fpm开启防火墙:
1
2
3sudo firewall-cmd --add-service=http --permanent && \
sudo firewall-cmd --add-service=https --permanent && \
sudo firewall-cmd --reload
安装Chevereto
在浏览器中输入chevereto.conf
中配置的server_name
访问:
- 输入数据库的信息进行连接;
- 创建后台用户的信息;
- 点击完成, 进入Chevereto.