栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > LAMP教程

编译安装php

LAMP教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

编译安装php

编译安装php 编译安装 httpd 模块方式的php5.6
#安装相关包,依赖epel源
yum install gcc make libxml2-devel  bzip2-devel libmcrypt-devel

#编译安装php
tar xvf php-5.6.30.tar.bz2
cd php-5.6.30
./configure --prefix=/apps/php 
--with-mysql=/usr/local/mysql 
--with-openssl 
--with-mysqli=/usr/local/mysql/bin/mysql_config 
--enable-mbstring 
--with-png-dir 
--with-jpeg-dir 
--with-freetype-dir 
--with-zlib 
--with-libxml-dir=/usr 
--enable-xml 
--enable-sockets 
--with-apxs2=/app/httpd24/bin/apxs 
--with-mcrypt 
--with-config-file-path=/etc 
--with-config-file-scan-dir=/etc/php.d 
--with-bz2

make -j 4 && make install

#准备php的配置文件
cd php-5.6.30
cp php.ini-production /etc/php.ini

#修改httpd配置文件支持php
vim /etc/httpd24/conf/httpd.conf
#下面加二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

#定位至DirectoryIndex index.html, 修改为
DirectoryIndex index.php index.html

apachectl restart
编译安装 httpd 模块方式的 php 7.3
#安装相关包, 依赖epel源
yum install gcc make libxml2-devel bzip2-devel libmcrypt-devel

#编译安装php 7.3
tar xvf php-7.3.10.tar.xz 
cd php-7.3.10/
./configure 
--prefix=/apps/php 
--enable-mysqlnd 
--with-mysqli=mysqlnd 
--with-openssl 
--with-pdo-mysql=mysqlnd 
--enable-mbstring 
--with-freetype-dir 
--with-jpeg-dir 
--with-png-dir 
--with-zlib 
--with-libxml-dir=/usr 
--enable-xml 
--enable-sockets 
--with-apxs2=/app/httpd24/bin/apxs 
--with-config-file-path=/etc 
--with-config-file-scan-dir=/etc/php.d 
--enable-maintainer-zts   
--disable-fileinfo

#说明:
#--enable-maintainer-zts 仅针对mpm为event和worker的情况,编译成zts模块,如果是prefork则不需要
#php-7.0 以上版本使用--enable-mysqlnd --with-mysqli=mysqlnd ,原--with-mysql不再支持

make -j 4 && make install

cp php.ini-production /etc/php.ini

vim /etc/httpd24/httpd.conf
在文件尾部加两行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
修改下面行

    DirectoryIndex index.php index.html
编译安装 fastcgi 方式的php 7.3
#安装相关包,依赖EPEL源
yum install gcc make  libxml2-devel  bzip2-devel libmcrypt-devel 

#编译安装 php 7.3
tar xvf php-7.3.10.tar.bz2 
cd php-7.3.10/
./configure --prefix=/apps/php 
--enable-mysqlnd 
--with-mysqli=mysqlnd 
--with-pdo-mysql=mysqlnd 
--with-openssl 
--with-freetype-dir 
--with-jpeg-dir 
--with-png-dir 
--with-zlib 
--with-libxml-dir=/usr 
--with-config-file-path=/etc 
--with-config-file-scan-dir=/etc/php.d 
--enable-mbstring  
--enable-xml 
--enable-sockets 
--enable-fpm  
--enable-maintainer-zts 
--disable-fileinfo 
make && make install

#准备php的配置文件
cd php-7.3.10/
cp php.ini-production  /etc/php.ini
cd /apps/php/etc
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default  php-fpm.d/www.conf

#准备php-fpm启动脚本或service unit文件
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm 
chkconfig --add php-fpm 
chkconfig php-fpm on
service php-fpm start

#或者
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start php-fpm

#配置httpd支持php-fpm
vim /apps/httpd24/conf/httpd.conf 
#取消下面两行的注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
#修改下面行

    DirectoryIndex index.php index.html

#加下面四行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off
ProxyPassMatch  ^/(.*.php) fcgi://127.0.0.1:9000/var/www/html/$1

#支持opcache加速
vim /etc/php.ini
[opcache]
zend_extension=opcache.so                                                                  opcache.enable=1
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/10391.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号