云服务器
常见问题
yum安装报错:Errors during downloading metadata for repository 'AppStream'的处理
https://support.huaweicloud.com/tstg-kunpengwebs/kunpenghttpress_06_0004.html#kunpenghttpress_06_0004__zh-cn_topic_0000001214226182_section03527251282
原因
CentOS 8项目官方已于2021年底停止,相关源已无法使用。
- 备份Yum源
cd /etc/yum.repos.d
mkdir bak
mv *.repo bak
- 下载外网Yum源 (1)如果是阿里云,则执行下面的命令
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
(2)如果是华为云,则执行下面的命令
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-8-reg.repo
提示
如果wget未安装,执行以下命令进行安装。 yum -y install wget
- 修改Yum源
sed -i "s/\$releasever/8-stream/g" /etc/yum.repos.d/CentOS-Base.repo
cat /etc/yum.repos.d/CentOS-Base.repo
- 使Yum源生效
yum clean all
yum makecache
yum list
安装php rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-8.rpm --nodeps --force 添加相关的库后,启用 PHP 7.4 的 Remi 模块并进行安装。 dnf -y install dnf-utils #使用这个命令查看php7.4 yum search php74*
运行一下
yum install php74-php
#运行并查看版本 php74 -v #重启命令php-fpm systemctl restart php74-php-fpm #添加自动启动 systemctl enable php74-php-fpm #查看php7.4的安装路径 whereis php #链接php文件 ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php
一些配置文件的路径
The current PHP memory limit is below the recommended value of 512MB.
vi /etc/opt/remi/php74/php.ini memory_limit = 512M
#如果你运行的是nginx而不是apache,修改 vi /etc/opt/remi/php74/php-fpm.d/www.conf user = apache group = apache
Replace the values with
user = nginx group = nginx
http访问重定向至https
server{ listen 80; server_name www.dongyunit.com; rewrite ^(.*)$ https://$host$1 permanent; }
https访问
server { listen 443 ssl http2; server_name www.dongyunit.com; ssl_certificate cert/www.dongyunit.com.pem; ssl_certificate_key cert/www.dongyunit.com.key; ssl_session_cache shared:SSL:10m; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { root /usr/share/nginx/html/dongyun; try_files $uri $uri/ /index.html; index index.html index.htm index.php; } location ~ .php$ { root /usr/share/nginx/html/dongyun; fastcgi_pass unix:/var/opt/remi/php74/run/php-fpm/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
将文件 /var/opt/remi/php74/run/php-fpm/www.sock 权限设置为666