PHP的安装需要apache和mysql两个基础环境
第一步:查看是否安装apache和mysql
1、rpm -qa |grep mysql
rpm -qa |grep httpd
2、netstat -atunp |grep mysql
netstat -atunp |grep httpd
3、ps -ef |grep mysql
ps -ef lgrep httpd
4、1sof -i :3306
lsof -i :80
查看是否有apxs:
rpm -ql httpd-devel |grep apxs
find / -name "apxs”
如果没有apxs,安装httpd-devel: yum install httpd-devel
第二步:上传到服务器后,解压到指定目录
tar -zxvf php-8.1.4.tar.gz -C /usr/local/
第三步:安装依赖包:
yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel
libxml2 libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel
curl-devel openssl-devel 1ibxslt-devel -y
配置apache支持PHP程序
修改apache的配置文件:
修改前备份:cp httpd.conf httpd.conf.bak
修改内容:
1、
User php
Group php
2、# If your host doesn't have a registered DNS name, enter its IP address here.
ServerName localhost:80
3、<IfModule dir_module>
DirectoryIndex index.php index.html 404.html
</IfModule>
4、 # If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
启动httpd,mysqld
systemctl start httpd #启动并加入开机自启动httpd
systemctl enable httpd
systemctl start mariadb #启动并加入开机自启动mysqld
systemctl enable mariadb
配置测试首页文件
在apache的发布目录:/var/www/html 中
vim index.php
写入: <?php
phpinfo();
?>
保存后退出,在浏览器输入服务器IP测试。