前提
使用vmware虚拟机创建CentOS7
安装的PHP版本是7.3
Apache 安装
1.查看是否安装有httpd
rpm -qa httpd
2.安装httpd
yum install httpd* -y
3.更改配置 需要root用户权限
vim /etc/httpd/conf/httpd.conf
在其中找到:
AddType application/x-gzip .gz .tgz
在其下面添加:
AddType application/x-httpd-php .php //添加支持对php脚本解析
找到:
DirectoryIndex index.html
把中间那一行改为:
DirectoryIndex index.html index.htm index.php //增加对php的索引
然后保存
按esc键
:wq!保存退出
PHP安装
1.首先安装EPEL源
yum install -y epel-release
2.安装 REMI 源
# CentOS 7
yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# CentOS 6
yum install -y http://rpms.remirepo.net/enterprise/remi-release-6.rpm
3.安装 Yum 源管理工具
yum -y install yum-utils
4.安装PHP软件
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll
5.重启计算机
6.编辑/etc/opt/remi/php73/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/opt/remi/php73/php.ini
7.重启php
systemctl restart php73-php-fpm
8.更新PHP
yum update
9.更新补丁
yum install mod_php
10.建议重启计算机
启动
设置开启运行启动服务PHP
systemctl enable php73-php-fpm
systemctl start php73-php-fpm
启动apache
ystemctl start httpd.service
添加PHP文件
vim /var/www/html/index.php
在其中输入<?PHP phpinfo(); ?>
打开网页
打开浏览器在网址中输入自己的IP