系统:LINUX CentOS 7.3
apache2.4.27
PHP官网:www.php.net
下载源码包
wget http://cn2.php.net/distributions/php-7.1.9.tar.gz
解压
tar -zxvf php-7.1.9.tar.gz
编译
./configure \
--prefix=/usr/local/php7.1.9/ \
--with-apxs2=/usr/local/apache/bin/apxs \
--enable-mbstring \
--with-curl \
--with-gd \
--enable-fpm \
--enable-mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
安装
make && make install
安装完成后文件位置
Build complete.
Don't forget to run 'make test'.
Installing PHP SAPI module: apache2handler
/usr/local/apache2.4.27/build/instdso.sh SH_LIBTOOL='/usr/local/apache2.4.27/build/libtool' libphp7.la /usr/local/apache2.4.27/modules
/usr/local/apache2.4.27/build/libtool --mode=install install libphp7.la /usr/local/apache2.4.27/modules/
libtool: install: install .libs/libphp7.so /usr/local/apache2.4.27/modules/libphp7.so
libtool: install: install .libs/libphp7.lai /usr/local/apache2.4.27/modules/libphp7.la
libtool: warning: remember to run 'libtool --finish /root/tools/php-7.1.9/libs'
chmod 755 /usr/local/apache2.4.27/modules/libphp7.so
[activating module `php7' in /usr/local/apache2.4.27/conf/httpd.conf]
Installing shared extensions: /usr/local/php7.1.9/lib/php/extensions/no-debug-zts-20160303/
Installing PHP CLI binary: /usr/local/php7.1.9/bin/
Installing PHP CLI man page: /usr/local/php7.1.9/php/man/man1/
Installing PHP FPM binary: /usr/local/php7.1.9/sbin/
Installing PHP FPM defconfig: /usr/local/php7.1.9/etc/
Installing PHP FPM man page: /usr/local/php7.1.9/php/man/man8/
Installing PHP FPM status page: /usr/local/php7.1.9/php/php/fpm/
Installing phpdbg binary: /usr/local/php7.1.9/bin/
Installing phpdbg man page: /usr/local/php7.1.9/php/man/man1/
Installing PHP CGI binary: /usr/local/php7.1.9/bin/
Installing PHP CGI man page: /usr/local/php7.1.9/php/man/man1/
Installing build environment: /usr/local/php7.1.9/lib/php/build/
Installing header files: /usr/local/php7.1.9/include/php/
Installing helper programs: /usr/local/php7.1.9/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php7.1.9/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php7.1.9/lib/php/
[PEAR] Archive_Tar - installed: 1.4.3
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.4.2
[PEAR] PEAR - installed: 1.10.5
Wrote PEAR system config file at: /usr/local/php7.1.9/etc/pear.conf
You may want to add: /usr/local/php7.1.9/lib/php to your php.ini include_path
/root/tools/php-7.1.9/build/shtool install -c ext/phar/phar.phar /usr/local/php7.1.9/bin
ln -s -f phar.phar /usr/local/php7.1.9/bin/phar
Installing PDO headers: /usr/local/php7.1.9/include/php/ext/pdo/
符一个别人的生产环境设置
另外,附一个可用于生产环境的php的编译参数列表
./configure --prefix=/usr/local/php \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-mcrypt \
--with-curlwrappers \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear
检查PHP是否解析成功
在/usr/local/apache/htdocs 目录下新建test.php
里面写入
<?
phpinfo();
然后在修改/usr/local/apache/conf/httpd.conf
在后面加入
AddHandler application/x-httpd-php .php
保存后重启apache
/usr/local/apache/bin/apachectl restart
在浏览器中输入
ip/test.php
即显示PHP相关信息
PHP安装完成后安装nextcloud的时候发现少了zip zlibp openssl模块
但是用phpize安装完成后还是显示缺少这些模块
最后重新编译一遍PHP加上这些模块后才好
看见官方给的缺少模块的方法也是重新编译安装
而不是用什么phpize