編譯安裝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
修改下面行
<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.avtobanya.com/36109.html
網友評論comments