(centos7-x86)apache+php-7.4

举报
QGS 发表于 2022/01/12 15:10:41 2022/01/12
【摘要】 apache+php-7.4
#安装httpd(自带有)
yum install httpd -y
systemctl restart httpd 
#配置文件
/etc/httpd/conf/httpd.conf
/var/www/html
#浏览器访问
http://IP

编译安装php-7.4

#官网地址
https://www.php.net/downloads
#或国内网站
https://mirrors.sohu.com/php/

#下载php压缩包
wget https://mirrors.sohu.com/php/php-7.4.9.tar.gz

#安装依赖
yum -y install libxml2 libxml2-devel  curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel openldap openldap-devel sqlite-devel oniguruma-devel
yum -y install pcre pcre-devel zlib openssl openssl-devel
yum -y install gcc gcc-c++
yum -y install wget

#解压,编译安装
mv php-7.4.9.tar.gz /opt/
cd /opt/
tar zxvf php-7.4.9.tar.gz
useradd -s /sbin/nologin -M php
#安装目录/usr/local/php7
cd php-7.4.9
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --enable-bcmath  --enable-gd --with-jpeg --with-freetype  --enable-mbstring --enable-ftp --enable-sockets   --with-gettext --enable-session --with-curl   --enable-fpm --with-fpm-user=php --with-fpm-group=php   --enable-pdo -enable-tokenizer --with-zip

#解决报错No package 'oniguruma' found 
yum  -y  install autoconf automake libtool
wget https://github.com/kkos/oniguruma/archive/v6.9.5_rev1.tar.gz
tar zxvf v6.9.5_rev1.tar.gz 
cd oniguruma-6.9.5_rev1/
./autogen.sh 
./configure --prefix=/usr --libdir=/lib64
make && make install

#解决报错No package 'libzip' found
wget https://libzip.org/download/libzip-1.3.2.tar.gz
tar xf libzip-1.3.2.tar.gz
cd libzip-1.3.2
./configure && make && make install
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" 
#解决报错,重新编译安装php
cd php-7.4.9
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --enable-bcmath  --enable-gd --with-jpeg --with-freetype  --enable-mbstring --enable-ftp --enable-sockets   --with-gettext --enable-session --with-curl   --enable-fpm --with-fpm-user=php --with-fpm-group=php   --enable-pdo -enable-tokenizer --with-zip
make && make install

yum install net-tools -y
yum install psmisc -y
#配置文件改名
cd /usr/local/php7/etc/
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf
#php命令设置软链接
ln -s /usr/local/php7/bin/* /usr/local/bin
ln -s /usr/local/php7/sbin/* /usr/local/sbin
#查看php的版本
php -v
#
php-fpm
netstat -antp | grep php-fpm



#查看运行日记
tail -f /usr/local/php7/var/log/php-fpm.log

#杀死当前php进程,重启
killall php-fpm
php-fpm
netstat -antp | grep php-fpm
tail -f /usr/local/php7/var/log/php-fpm.log
netstat -tln | grep 9000
netstat -tln | grep 80

安装ldap扩展模块

#安装ldap扩展模块
cd /opt/php-7.4.9/ext/ldap
find / -name phpize
#运行phpize
/usr/local/php7/bin/phpize
#复制库文件
cp -frp /usr/lib64/libldap* /usr/lib/
#安装至/usr/local/php7/bin/php-config
./configure --with-php-config=/usr/local/php7/bin/php-config

#编译安装
make && make install

#修改参数
cd /opt/php-7.4.9/
cp php.ini-production /usr/local/php7/etc/php.ini
vim /usr/local/php7/etc/php.ini

extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20190902/"
extension=ldap.so

max_execution_time = 300
post_max_size = 16M
max_input_time = 300
date.timezone = Asia/Shanghai  

#Apache网页目录下编写简单的php网页,验证访问Apache的php网页
vim /var/www/html/index.php

<?php
 phpinfo();
?>


#配置Apache解析PHP
vim /etc/httpd/conf.d/php-fpm.conf

<FilesMatch \.php$>
        SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>


#浏览器访问
http://IP/index.php

【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。