免费视频网站制作,找个网站,如何查询网站是哪家公司做的,郑州短视频拍摄公司最近将小服务器升级了下系统#xff0c;使用了 debian12 的版本#xff0c;正好试试 nginx 和 php-fpm 这种方式运行 Nextcloud 这个私有云的配置。
一、基本系统及应用安装
系统#xff1a;debian12 x86_64 位版本最小安装#xff0c;安装后可根据自己需求安装一些工具使用了 debian12 的版本正好试试 nginx 和 php-fpm 这种方式运行 Nextcloud 这个私有云的配置。
一、基本系统及应用安装
系统debian12 x86_64 位版本最小安装安装后可根据自己需求安装一些工具比如 neofetch 等自己喜欢的工具
nginx使用系统源的包进行安装主要是为了省事儿要不然还得找服务启动脚本等各种配置内容里会记录 nginx 的配置文件内容另如需要使用源码安装的话想使用系统的服务启动服务脚本在最后的“附件”里查看
php使用系统源中的包进行安装主要是使用 php-fpm 方式主要也是为了省事儿看缺什么组件就直接安装就可以当前源中的版本是 8.2.7 版本这个不太建议使用源码安装主要是太麻烦不容易记录也不必要弄太麻烦
nextcloud使用的是当前最新的版本 28.0.4数据库使用 sqlite 主要也是为了省事儿也没特别大的数据所以就不再另安装数据库系统
二、系统配置
1、配置 debian12
最小安装完成后要注意安装过程中要选择安装 ssh 服务要不然系统安装完成还得自己另安装太麻烦修改源到自己习惯的国内源并更新到最新
apt update apt upgrade -y
安装一些自己习惯使用工具比如 neofetch、btop、net-tools 什么的
并将系统的的 IP 设置为固定即可方式很多我使用的是直接设置 interfaces 文件
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).source /etc/network/interfaces.d/*# The loopback network interface
auto lo
iface lo inet loopback# The primary network interface
allow-hotplug enp1s0
# iface enp1s0 inet dhcp
iface enp1s0 inet staticaddress X.X.X.X/24gateway X.X.X.Xdns-nameservers X.X.X.X
重新网络服务以使其生效
systemctl restart networking.service
系统已经设置完毕
2、安装配置 Nginx
apt install nginx # 安装nginx
编写 nginx 配置文件注意按配置文件内容中可以看到 nextcloud 程序的位置是在/var/www/nextcloud 下后面直接将 nextcloud 解压到/var/www/下即可
vim /etc/nginx/sites-available/nextcloud
# 注这是访问方式为 http://IP:PORT/ 的配置
server {listen 80;server_name X.X.X.X;root /var/www/nextcloud;index index.html index.htm index.php;location / {try_files $uri $uri/ /index.php$is_args$args;}location ~ \.php(?:$|/) {fastcgi_split_path_info ^(.\.php)(/.)$;# 要注意下面这行的接口的版本版本要与 php 的版本一样可以去指定的地址查看一下fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;fastcgi_index index.php;include fastcgi_params;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param PATH_INFO $fastcgi_path_info;}location ~ /\.ht {deny all;}# 解决 nextcloud 中的一个安全检查的 .mjs 问题location ~* \.mjs$ {types { }default_type application/javascript;}location ^~ /.well-known {# The rules in this block are an adaptation of the rules# in .htaccess that concern /.well-known.location /.well-known/carddav { return 301 /remote.php/dav/; }location /.well-known/caldav { return 301 /remote.php/dav/; }location /.well-known/acme-challenge { try_files $uri $uri/ 404; }location /.well-known/pki-validation { try_files $uri $uri/ 404; }# Let Nextclouds API for /.well-known URIs handle all other# requests by passing them to the front-end controller.return 301 /index.php$request_uri;}# Optional: set long EXPIRES header on static assetslocation ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {expires 30d;access_log off;}
}
或是使用 url 路径的方式使用 http://IP:PORT/nextcloud/ 的配置内容使用这种安装的会在nextcloud页面安装完成后自动转到没有 url 地址的网址进而导致无法打开此时手工加上 url 地址就可以
根据自己需要二选一即可
mkdir -p /var/www/app
tar xjvf nextcloud-28.0.4.tar.bz2 -C /var/www/app/ # 解压 nextcloud 到 app 目录中
chown -R www-data:www-data /var/www/app
# 使用 url 路径的方式使用 http://IP:PORT/nextcloud/ 的配置
server {listen 80;server_name X.X.X.X;root /var/www/app;index index.html index.htm index.php;location /nextcloud {try_files $uri $uri/ /nextcloud/index.php$request_uri;}location ~ \.php(?:$|/) {fastcgi_split_path_info ^(.\.php)(/.)$;# 要注意下面这行的接口的版本版本要与 php 的版本一样可以去指定的地址查看一下fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;fastcgi_index index.php;include fastcgi_params;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param PATH_INFO $fastcgi_path_info;}location ~ /\.ht {deny all;}# 解决 nextcloud 中的一个安全检查的 .mjs 问题location ~* \.mjs$ {types { }default_type application/javascript;}location ^~ /.well-known {# The rules in this block are an adaptation of the rules# in .htaccess that concern /.well-known.location /.well-known/carddav { return 301 /nextcloud/remote.php/dav/; }location /.well-known/caldav { return 301 /nextcloud/remote.php/dav/; }location /.well-known/webfinger { return 301 /nextcloud/index.php/.well-known/webfinger; }location /.well-known/nodeinfo { return 301 /nextcloud/index.php/.well-known/nodeinfo; }location /.well-known/acme-challenge { try_files $uri $uri/ 404; }location /.well-known/pki-validation { try_files $uri $uri/ 404; }# Let Nextclouds API for /.well-known URIs handle all other# requests by passing them to the front-end controller.return 301 /nextcloud/index.php$request_uri;}# Optional: set long EXPIRES header on static assetslocation ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {expires 30d;access_log off;}
}
创建一个软链接
ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/
systemctl restart nginx.service # 重启nginx服务
3、安装配置 php
直接使用系统源中的版本就可以当前版本是 8.2.7
# 安装 php 及 php-fpm
apt install php8.2-fpm -y# 安装 nextcloud 所需要的必要 php 组件可以在运行 nextcloud 时看提示所缺少的组件安装也可以
apt install php8.2-sqlite3 php8.2-zip php8.2-xml php8.2-mbstring php8.2-gd php8.2-curl -y# 安装 nextcloud 正常使用时建议安装的 php 组件
apt install php8.2-gmp php8.2-bcmath php8.2-intl php8.2-imagick -y# 按 nextcloud 建议修改 php-fpm 的配置
# 解决PHP 内存限制低于建议值 512 MB
vim /etc/php/8.2/fpm/php.ini
# 搜索 memory_limit并将原值 128M 修改为 512M 后保存
# 搜索 interned_strings_buffer启用并将原值 8 修改为 16因为这个有可能会被提示需进行优化vim /etc/php/8.2/fpm/pool.d/www.conf
# 搜索 PATH找到 env[PATH] 的内容为在系统中的 PATH 值echo $PATH 的结果
# 例如env[PATH] /usr/local/bin:/usr/bin:/bin# 重启服务使组件及配置生效
systemctl restart php8.2-fpm.service
4、安装 Nextcloud
可以直接到官网上下载就可以这个是官方各个版本的下载地址选一个自己喜欢的就可以Index of /server/releases (nextcloud.com)https://download.nextcloud.com/server/releases/我选择下载最新的版本
# 下载指定的版本包
wget https://download.nextcloud.com/server/releases/nextcloud-28.0.4.tar.bz2
# 解压到指定位置也是按 nginx 的配置文件中所指的位置运行解压
tar xjvf nextcloud-28.0.4.tar.bz2 -C /var/www/
# 修改目标目录的所属权限
chown -R www-data:www-data /var/www/nextcloud/
# 此时输入 ip:port 就可以正常访问 nextcloud 第一运行的安装向导页面了
# 如果 php 组件没有安装完全也会提示按提示安装完全后重启 php 服务并刷新页面即可
# 需要另找一个位置专门给 nextcloud 存数据文件使用所有上传的文件都会保存在该目录下
# 数据目录的权限也是 www-data 用户的例如
mkdir /nextcloud-data
chown -R www-data:www-data /nextcloud-data/5、配置 nextcloud
在安装完成后可以修改配置文件中的内容修改一些设置
vim /var/www/nextcloud/config/config.php
# 如果有域名的可以在这段里添加
trusted_domains array (0 127.0.0.1:80,1 www.abc.com:80,),# 解决默认电话区域和默认地域的提示在配置文件中添加default_phone_region CN,default_language zh_CN,default_locale zh,附件一
nginx 源码安装并使用服务启动管理所需使用脚本暂未测试但看着应该是可以正常使用
vim /etc/init.d/nginx # 创建服务启动脚本
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFODAEMON/usr/local/nginx/sbin/nginx
NAMEnginx
DESCnginxtest -x $DAEMON || exit 0case $1 instart)echo -n Starting $DESC: $DAEMONecho $NAME.;;stop)echo -n Stopping $DESC: $DAEMON -s stopecho $NAME.;;reload)echo -n Reloading $DESC configuration: $DAEMON -s reloadecho $NAME.;;restart)echo -n Restarting $DESC: $DAEMON -s quit$DAEMONecho $NAME.;;*)N/etc/init.d/$NAMEecho Usage: $N {start|stop|restart|reload} 2exit 1;;
esacexit 0
chmod ax /etc/init.d/nginx # 添加可执行权限
update-rc.d nginx defaults # 添加并更新到启动服务使其可以自动启动
# 之后的启动服务操作
sudo /etc/init.d/nginx start sudo /etc/init.d/nginx stop sudo /etc/init.d/nginx reload