Nginx上传文件大小限制
站点配置文件加入/修改以下代码
# 打开高效传输文件模式
sendfile on;
# 最大上传文件为128MB
client_max_body_size 128M;
# 连接时间,默认60s
keepalive_timeout 600;
站点配置文件加入/修改以下代码
# 打开高效传输文件模式
sendfile on;
# 最大上传文件为128MB
client_max_body_size 128M;
# 连接时间,默认60s
keepalive_timeout 600;
# 查看所有服务状态(按 q 退出)
systemctl list-units
# 查看所有服务自启设置(按 q 退出)
systemctl list-unit-files
# 将服务设为开机自启
systemctl enable service
# 启动服务
systemctl start service
# 停止服务
systemctl stop service
# 查看服务状态
systemctl status service
# 重启服务
systemctl restart service
# 重载配置
systemctl stop service
# 将服务设为开机自启
systemctl enable service
# 禁用服务开机自启
systemctl disable service
# 查看当前用户的任务
crontab -l
# 编辑当前用户的任务
crontab -e
# 规则:
# 分 时 日 月 年 执行操作,以下内容即为 每天 01:30 执行 /root/backup.sh
# 30 01 * * * /bin/sh /root/backup.sh
# 重启 crontab
# CentOS 8
systemctl restart crond
# CentOS 7
service crond restart
# 下载安装包
wget http://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_centos7.0_x86_64.rpm
# 安装
yum -y localinstall ossfs_1.80.6_centos7.0_x86_64.rpm
# 设置参数,填写自己的阿里云 BucketName、AccessKey ID、Accesskey Secret
echo BucketName:AccessKeyId:AccessKeySecret > /etc/passwd-ossfs
# 设置配置文件的访问权限
chmod 640 /etc/passwd-ossfs
# 创建本地挂载的目录
mkdir /var/www/backup
# CentOS 8 需要安装,否则挂载时会报错,如果为7无需安装
yum -y install compat-openssl10
# 挂载,BucketName为自己的Backet名称、MountPath为要挂载的目录、ossEndpoint为Backet的地域节点
ossfs BucketName MountPath -ourl=ossEndpoint
# 卸载,可在备份完成后执行
fusermount -u mount-path
在站点配置文件加入此代码
location ~ (.db)$ {
return 404;
}
若还有其他不允许被查看的文件,如 .key,如此增加即可
location ~ (.db|.key)$ {
return 404;
}
在 /etc/nginx/nginx.conf 的 http{} 中添加以下代码
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable "MSIE [1-6].";
# 一般使用 yum 卸载,比如说卸载php
yum remove php
# 但有些软件使用 yum 卸不干净,可以用 rpm 卸载
# 查看软键安装了那些包
rpm -qa|grep php
# 把输出的包依次全部删掉,有些可能会删除失败,可以先删掉它提示的包再删它
rpm -e php-common-7.4.12-1.el8.remi.x86_64
rpm -e php-cli-7.4.12-1.el8.remi.x86_64
rpm -e php-mbstring-7.4.12-1.el8.remi.x86_64
rpm -e php-xml-7.4.12-1.el8.remi.x86_64
rpm -e php-7.4.12-1.el8.remi.x86_64
rpm -e php-json-7.4.12-1.el8.remi.x86_64
rpm -e php-fpm-7.4.12-1.el8.remi.x86_64
rpm -e php-opcache-7.4.12-1.el8.remi.x86_64
rpm -e oniguruma5php-6.9.6-1.el8.remi.x86_64
rpm -e php-mysqlnd-7.4.12-1.el8.remi.x86_64
rpm -e php-pdo-7.4.12-1.el8.remi.x86_64
rpm -e php-sodium-7.4.12-1.el8.remi.x86_64
rpm -e php-pecl-mysql-1.0.0-0.23.20190415.d7643af.el8.remi.7.4.x86_64
# 删除完成后执行,会提示 -bash: php: command not found
php -v
# 压缩文件
zip -r file.zip /data/dir
# 解压文件
unzip file.zip -d /data/dir
# 安装EPEL&Remi
dnf -y install https://dl.Fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
# 查看可以安装的PHP版本
dnf module list php