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地址,即可出现配置页面。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

勤奋的凯尔森同学

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值