安装PHP
yum install php
yum install php-curl php-gd php-json php-mbstring php-exif php-mysqlnd php-pgsql php-pdo php-xml
配置文件
/etc/php.ini
修改参数
date.timezone = Asia/Shanghai
max_execution_time = 60
memory_limit = 1280M
post_max_size = 200M
file_uploads = On
upload_max_filesize = 2000M
expose_php = Off
安装Apache
yum install httpd
启动Apache
systemctl start httpd
配置文件
/etc/httpd/conf/httpd.conf
添加参数
TraceEnable off
ServerTokens ProductOnly
ServerSignature Off
检查/etc/httpd/conf.modules.d/00-base.conf
是否开启以下模块
LoadModule headers_module modules/mod_headers.so
LoadModule rewrite_module modules/mod_rewrite.so
如果没有则加上
然后重启Apache
systemctl restart httpd
无法访问php网页
测试静态网页、图片等正常,但是无法访问php网页,提示500错误 Internal Server Error
修改/etc/httpd/conf.modules.d/15-php.conf
以下
<IfModule !mod_php5.c>
<IfModule prefork.c>
LoadModule php7_module modules/libphp7.so
</IfModule>
</IfModule>
改为
<IfModule !mod_php5.c>
LoadModule php7_module modules/libphp7.so
</IfModule>
重启Apache
systemctl restart httpd
重启Apache时加载PHP模块报错
Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.
修改/etc/httpd/conf.modules.d/00-mpm.conf
禁用LoadModule mpm_event_module modules/mod_mpm_event.so
开启LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
修改/etc/httpd/conf.modules.d/15-php.conf
恢复为之前的设置
<IfModule !mod_php5.c>
<IfModule prefork.c>
LoadModule php7_module modules/libphp7.so
</IfModule>
</IfModule>
重启Apache
systemctl restart httpd
验证是否加载模块
httpd -M
结果包含
php7_module (shared)
可以访问php网页了