zl程序教程

您现在的位置是:首页 >  后端

当前栏目

编译安装php

PHP安装 编译
2023-06-13 09:15:41 时间
#安装相关包,依赖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

修改下面行

 IfModule dir_module 

 DirectoryIndex index.php index.html

 /IfModule 
编译安装 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

#修改下面行

 IfModule dir_module 

 DirectoryIndex index.php index.html

 /IfModule 

#加下面四行

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

本文链接:http://www.yunweipai.com/36109.html

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/52450.html

apachemysqlphpPHP5