群晖、NAS、PVE、飞牛、二手品牌机、垃圾佬

每一位热爱生活的垃圾佬都值得敬畏

PVE系列教程(十九)、ubuntu22.04使用Nginx配置chevereto服务器

内容目录 PVE系列教程(十九)、ubuntu22.04使用Nginx配置chevereto服务器 为了更好的 […]
内容目录

PVE系列教程(十九)、ubuntu22.04使用Nginx配置chevereto服务器

为了更好的浏览体验,欢迎光顾勤奋的凯尔森同学个人博客http://www.huerpu.cc:7000

一、环境说明

这里使用的是Ubuntu22.04,mysql8已经在其他服务器安装好了,如果需要可以查看上面的教程。chevereto使用的V3最新版。

二、安装Nginx

#切换到root
sudo su -

#更新
apt update 
apt upgrade -y

#安装nginx
apt install nginx -y

#防火墙放行Nginx
ufw allow 'Nginx Full'
ufw enable
ufw status 

三、安装php7.4

#添加源
add-apt-repository ppa:ondrej/php
# 然后回车即可

#安装php相关软件
apt install php7.4 php7.4-bcmath php7.4-cli php7.4-common php7.4-curl php7.4-dev php7.4-fpm php7.4-enchant php7.4-gd php7.4-json php7.4-mysql  php7.4-mbstring php7.4-xml php7.4-zip -y

四、配置chevereto静态文件

#安装zip解压缩软件
apt install unzip

#把chevereto压缩包传入服务器,我这里使用的是MobaXterm,你也可以使用wget等方式

#进入到这个目录,为了把文件解压到此处
cd /var/www/html

#解压chevereto文件
unzip Chevereto.zip

#修改文件夹名称为chevereto
mv Chevereto/ chevereto/

#把chevereto及其下面所有文件和文件夹赋予最高权限777
chdmod -R 777 chevereto

#修改数据库配置
cd chevereto
cd app
vim settings.php

#修改settings.php的内容如下
<?php
$settings = array (
  'db_host' => '192.168.1.97:3306',
  'db_name' => 'hep_chevereto',
  'db_user' => 'root',
  'db_pass' => 'admin123*',
  'db_table_prefix' => 'hep_',
  'db_driver' => 'mysql',
  'db_pdo_attrs' =>
  array (
  ),
  'debug_level' => 1,
);

五、配置nginx

#修改nginx默认文件
vim /etc/nginx/sites-available/default

修改内容如下

#修改到/var/www/html/chevereto/
root /var/www/html/chevereto/;

# 最后一个改成index.php
index index.html index.htm index.php;

server_name _;

#注释掉404,并添加一行try_files $uri $uri/ /index.php?$query_string;
location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        #try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php?$query_string;
}

#下面几个都是新增的
# Image not found replacement
location ~* (jpe?g|png|gif) {
        log_not_found off;
        error_page 404 /content/images/system/default/404.gif;
}

# CORS header (avoids font rendering issues)
location ~ \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
        add_header Access-Control-Allow-Origin "*";
}

# pass PHP scripts to FastCGI server
location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}     

测试一下nginx文件配置是否正确

nginx -t

因为我们一直都是root登录并做的修改,用作web访问的时候www-data用户组没有权限,可以用chmod更改文件夹权限

chown -R www-data:www-data chevereto/中chown是更改权限命令,-R表示递归,www-data:www-data表示更改的目标用户组和用户,chevereto/是更改的目标文件夹,也就是/var/www/html/chevereto。

#www-data指的是apache2或nginx伺服器能读的账号以及群组
cd /var/www/html
chown -R www-data:www-data chevereto/

#重启nginx和php服务
systemctl restart nginx
systemctl restart php7.4-fpm
#或者使用
service nginx start
service php7.4-fpm start

备注:修改端口号

#把80改成自己想要的即可
vim /etc/nginx/sites-available/default

六、访问并安装chevereto

在浏览器输入chevereto服务器ip地址,即可出现配置页面。

七、修改上传文件大小限制

  • 修改php的upload参数

给出官方文档的参数说明,我们只修改两个参数post_max_size、upload_max_filesize。

multiphp-ini-keys.83901b7f

# 修改下面这两个文件,把post_max_size、upload_max_filesize按自己的需要都调大
vim /etc/php/7.4/cli/php.ini
vim /etc/php/7.4/fpm/php.ini

#可以输入/进行搜索
post_max_size = 1024M
upload_max_filesize = 512M
  • 修改nginx的upload参数
#修改nginx的upload上传大小限制
find / -name nginx.conf
vim /etc/nginx/nginx.conf
#新增下面两项
client_body_buffer_size 2048M;
client_max_body_size 1024M;

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注