源码编译安装
- 环境 OS: 14.04.1-Ubuntu PHP: php7.0.0
下载地址
- web下载地址
- 真实下载地址
下载解压
//进入要存放文件包目录 比如 /opt cd /opt sudo wget http://cn2.php.net/get/php-7.0.0.tar.gz/from/this/mirror sudo mv mirror php-7.0.0.tar.gz sudo tar -axvf php-7.0.0.tar.gz
编译安装
./configure --prefix=/usr/local/php --enable-fpm --enable-mbstring --disable-pdo --with-curl=/usr/local/curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysqli --with-gd --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/png --with-mcrypt=/usr/local/libmcrypt sudo make sudo make install
错误及解决
- PS:错误&&解决方法非顺序出现
no acceptable C compiler found in $PATH
# err configure: error: in `/opt/php-7.0.0': configure: error: no acceptable C compiler found in $PATH # solve sudo apt-get install gcc
Unable to fetch some archives
# err Err http://security.ubuntu.com/ubuntu/ trusty-security/main linux-libc-dev amd64 3.13.0-68.111 404 Not Found [IP: 91.189.91.13 80] Fetched 18.5 MB in 24s (768 kB/s) E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_3.13.0-68.111_amd64.deb 404 Not Found [IP: 91.189.91.13 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? # solve sudo sudo apt-get update
configure: error: xml2-config not found. Please check your libxml2 installation.
# err configure: error: xml2-config not found. Please check your libxml2 installation. # solve sudo apt-get install libxml2 sudo apt-get install libxml2-dev
Cannot find libz
# err configure: error: Cannot find libz # solve sudo curl -O http://zlib.net/zlib-1.2.8.tar.gz sudo tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8/ sudo ./configure sudo make sudo make install
The program 'make' is currently not installed
# err The program 'make' is currently not installed. You can install it by typing: sudo apt-get install make # solve sudo apt-get install make
configure: error: Please reinstall the BZip2 distribution
# err checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution # solve sudo curl -O http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz sudo tar -zxvf bzip2-1.0.6.tar.gz sudo make sudo make install
configure: error: Please reinstall the libcurl distribution
# err checking for cURL support... yes checking for cURL in default path... not found configure: error: Please reinstall the libcurl distribution - easy.h should be in/include/curl/ # solve sudo curl -O http://curl.haxx.se/download/curl-7.46.0.tar.gz sudo tar -zxvf curl-7.46.0.tar.gz cd curl-7.46.0/ sudo ./configure --prefix=/usr/local/curl sudo make sudo make install
configure: error: jpeglib.h not found.
# err checking whether to enable JIS-mapped Japanese font support in GD... no If configure fails try --with-webp-dir=configure: error: jpeglib.h not found. # solve sudo curl -O http://www.ijg.org/files/jpegsrc.v9a.tar.gz sudo tar -axvf jpegsrc.v9a.tar.gz cd jpeg-9a/ sudo ./configure --prefix=/usr/local/jpeg sudo make sudo make install
configure: error: png.h not found.
# err checking for jpeg_read_header in -ljpeg... yes configure: error: png.h not found. # solve sudo wget http://download.sourceforge.net/libpng/libpng-1.6.19.tar.gz sudo tar -zxvf libpng-1.6.19.tar.gz sudo ./configure --prefix=/usr/local/png sudo make sudo make install
stdin: not in gzip format
# err sudo curl -O http://download.sourceforge.net/libpng/libpng-1.6.19.tar.gz sudo tar -zxvf libpng-1.6.19.tar.gz checking for j gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now # solve sudo wget http://download.sourceforge.net/libpng/libpng-1.6.19.tar.gz
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
# err sudo ./configure --prefix=/usr/local/libmcrypt checking for mcrypt support... yes configure: error: mcrypt.h not found. Please reinstall libmcrypt. # solve sudo wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz sudo tar -zxvf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7/ sudo ./configure --prefix=/usr/local/libmcrypt sudo make sudo make install
unrecognized options: --with-mysql
# err configure: WARNING: unrecognized options: --with-mysql # solve PHP7不支持mysql扩展[不允许该参数参与编译--with-mysql]