【10.15】PHP、nginx
4.27/28/29 php编译安装
1、下载php安装包
https://www.php.net/distributions/php-7.3.0.tar.bz2
2、解压
可能需要先安装 bzip2
[root@localhost src]# tar xvf php-7.3.0.tar.bz2
3、编译
[root@localhost src]# cd php-7.3.0
[root@localhost php-7.3.0]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
4、解决问题
- 常遇到报错及结局
1、gcc … no
安装 gcc
2、xml2-config not found.
需要安装 libxml2-devel
3、少cURL
安装 libcurl-devel
4、少OpenSSL’s <evp.h>
安装 openssl、openssl-devel
5、jpeglib.h not found.
安装 libjpeg-devel
6、png.h not found.
安装 libpng-devel
7、freetype-config not found.
安装 freetype-devel
8、mcrypt.h not found.
安装 libmcrypt-devel
9、wrong mysql library version or lib not found
安装旧版本的 mysql 或 mariadb,,直接下载http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.45-linux-glibc2.12-x86_64.tar.gz
解压后将文件夹移动到/usr/local/ 下并改名为 mysql5.6
[root@localhost src]# tar xvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql5.6
[root@localhost src]# cd !$
cd /usr/local/mysql5.6
[root@localhost mysql5.6]# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
- 再重新编译,注意 /usr/local/mysql5.6 才是文件目录,注意更改
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql5.6 --with-mysqli=/usr/local/mysql5.6/bin/mysql_config --with-pdo-mysql=/usr/local/mysql5.6 --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
5、重新编译
[root@localhost mysql5.6]# cd ../src/php-7.3.0
[root@localhost php-7.3.0]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql5.6 --with-mysqli=/usr/local/mysql5.6/bin/mysql_config --with-pdo-mysql=/usr/local/mysql5.6 --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
提示:configure: WARNING: unrecognized options: --with-mysql, --with-mcrypt, --enable-gd-native-ttf,以上几个参数已经不适用新版本php编译了,编译时可以取消
6、make && make install
[root@localhost php-7.3.0]# make && make install
7、拷贝配置文件
[root@localhost php-7.3.0]# cd /usr/local/php-fpm/etc/
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# cp /usr/local/src/php-7.3.0/php.ini-development ./php.ini
[root@localhost etc]# ls
pear.conf php-fpm.conf php