安装php

PHP的安装需要apache 和mysql两个基础环境

1,查看是否安装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 |grep httpd
4、lsof -i :3306
   lsof -i :80
查看是否有apxs:
rpm -ql httpd-devel |grep apxs
find / -name "apxs"
如果没有apxs,安装httpd-devel:yum install httpd-devel

2,上传到服务器后,解压到指定目录
tar -zxvf php-8.1.4.tar.gz -C /usr/local/

3,安装依赖包:
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 libxslt-devel -y

4,编译安装。
./configure --prefix=/usr/local/php8 --with-apxs2=/usr/bin/apxs --with-mysql=/usr/share/mysql --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd --with-jpeg-dir --with-png-dir --with-iconv --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap --enable-mbstring --enable-static --enable-gd-native-ttf --with-curl --with-xsl --enable-ftp --with-libxml-dir

5:安装完成后:
复制配置文件到安装目录
cd /usr/local
cp php-8.1.4/php.ini-production php8/lib/php.ini

6:配置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

7:测试配置
/usr/bin/apachectl -t                # -t:运行配置文件的语法检查
如果报错,说明没有php用户,解决办法就是新增php用户
useradd php -s /usr/bin/nologin -M   
#-s表示指定用户所用的shell,此处为/bin/nologin,表示不登录。-M表示不创建用户主目录。

再次检查:/usr/bin/apachectl -t
Syntax ok

/usr/bin/apachectl graceful  刷新服务,不中断连接。

检查进程:ps -ef |grep httpd

8:查看PHP模块
cd /etc/httpd/conf
grep php httpd.conf

9:配置测试首页文件
在apache的发布目录:/var/www/html 中
vim index.php
写入: <?php
         phpinfo();
       ?>
保存后退出,在浏览器输入服务器IP测试。

报错解决方案:
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
原因: 在Centos8环境中配置php-7.4.19出现如上错误是因为缺少sqlite相关库
解决方法如下
yum install sqlite-devel

configure: error: Package requirements (oniguruma) were not met:No package 'oniguruma' found
解决:
wget http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/oniguruma-5.9.5-3.el7.art.x86_64.rpm
yum localinstall oniguruma-5.9.5-3.el7.art.x86_64.rpm
wget http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/oniguruma-devel-5.9.5-3.el7.art.x86_64.rpm
yum localinstall oniguruma-devel-5.9.5-3.el7.art.x86_64.rpm

make && make install
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值