CentOS - huyx/1 GitHub Wiki

CentOS

安装 Apache2 + PHP(5.4.16)

yum install httpd php

安装 PHP 5.6

参考: PHP 5.6 on CentOS/RHEL 7.2 and 6.7 via Yum

卸载刚刚安装的 PHP 5.4

yum list installed | grep php
yum erase php-cli.x86_64 php-common.x86_64 php.x86_64

添加 yum 库(Webtatic EL),注意要按顺序执行:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装 PHP 5.6 的 mod_php SAPI, 包括 opcode cache

yum install php56w php56w-opcache

也可以安装 php-fpm SAPI(包括 opcode cache)

yum install php56w-fpm php56w-opcache

安装 PHP 其他软件包

软件包 作用
php56w-pdo PDO
php56w-mysql MySQL
php56w-pecl-xdebug Xdebug

启动/停止 apache2

systemctl start httpd.service
systemctl stop httpd.service
systemctl restart httpd.service
systemctl reload httpd.service

让 .htaccess 中的 mod_rewrite 生效

<Directory "/var/www/html/api">
    AllowOverride FileInfo
    Require all granted
</Directory>

注意其中的 AllowOverride FileInfo

⚠️ **GitHub.com Fallback** ⚠️