Red Hat Enterprise Linux 7 高薪入门pdf下载
一、安装libmcrypt
[root@localhost php]# rpm -ivh libmcrypt-2.5.8-4.el7.art.x86_64.rpm
rpm安装在安装php时:--with-mcrypt
二进制编码安装的安装php时:--with-mcrypt=/usr/local/libmcrypt
二、php安装
./configure --prefix=/usr/local/php --with-gd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --enable-mbstring --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr/ --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts --with-curl --enable-opcache --enable-session --enable-sockets --enable-xml --enable-fpm --enable-zip --enable-xml --enable-bcmath
make
make test
make install
安装完之后可能不解析php:
安装完之后可能没有php.ini
三、安装php可能出现的错误:
1、libxml2和libxml2-devel没安装的错误
configure: error: xml2-config not found. Please check your libxml2 installation.
下载libxml2:https://centos.pkgs.org/7/centos-x86_64/libxml2-2.9.1-6.el7_2.3.x86_64.rpm.html
下载libxml2-devel:https://centos.pkgs.org/7/centos-x86_64/libxml2-devel-2.9.1-6.el7_2.3.i686.rpm.html
[root@localhost php]# rpm -ivh libxml2-2.9.1-6.el7_2.3.x86_64.rpm
[root@localhost php]# rpm -ivh libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm --nodeps
2、zlib-devel没安装的错误
checking libxml2 install dir... /usr/
checking for xml2-config path... /usr//bin/xml2-config
checking whether libxml build works... no
configure: error: build test failed. Please check the config.log for details.
下载地址:http://rpmfind.net/linux/rpm2html/search.php?query=zlib-devel
[root@localhost php]# rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm
3、bzip2和bzip2-devel没安装错误
checking for BZip2 support... yes
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
下载地址:https://centos.pkgs.org/7/centos-x86_64/bzip2-1.0.6-13.el7.x86_64.rpm.html
[root@localhost php]# rpm -ivh bzip2-1.0.6-13.el7.x86_64.rpm
下载地址:https://centos.pkgs.org/7/centos-x86_64/bzip2-devel-1.0.6-13.el7.x86_64.rpm.html
4、 libcurl和libcurl-devel没有安装的错误
checking for cURL support... yes
checking for cURL in default path... not found
which: no dpkg-architecture in (/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
./configure: line 23538: curl-dir: No such file or directory
checking for cURL 7.10.5 or greater... ./configure: line 23553: curl-config: command not found
configure: error: cURL version 7.10.5 or later is required to compile php with cURL support
下载地址:http://www.rpmfind.net/linux/rpm2html/search.php?query=curl-devel
下载地址:http://www.rpmfind.net/linux/rpm2html/search.php?query=libcurl&submit=Search+...&system=&arch=
5、libjpeg-devel没安装的错误
checking for FreeType 2... yes
checking whether to enable truetype string function in GD... no
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-webp-dir=<DIR>
configure: error: jpeglib.h not found.
下载地址:https://centos.pkgs.org/7/centos-x86_64/libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm.html
[root@localhost php-7.0.27]# rpm -qa | grep libjpeg
libjpeg-turbo-1.2.90-5.el7.x86_64
安装:
[root@localhost php]# rpm -ivh libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm
6、安装libpng-devel
[root@localhost php-7.0.27]# rpm -qa | grep libpng
libpng-1.5.13-7.el7_2.x86_64
下载地址:https://centos.pkgs.org/7/centos-x86_64/libpng-devel-1.5.13-7.el7_2.x86_64.rpm.html
[root@localhost php]# rpm -ivh libpng-devel-1.5.13-7.el7_2.x86_64.rpm
7、freetype和freetype-devel没安装错误
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.
下载地址:https://centos.pkgs.org/7/centos-x86_64/freetype-devel-2.4.11-15.el7.x86_64.rpm.html
下载地址 :https://centos.pkgs.org/7/centos-x86_64/freetype-2.4.11-15.el7.x86_64.rpm.html
[root@localhost php]# rpm -ivh freetype-2.4.11-15.el7.x86_64.rpm
[root@localhost php]# rpm -ivh freetype-devel-2.4.11-15.el7.x86_64.rpm --nodeps
8、openldap和openldap-devel没安装错误
configure: error: Cannot find ldap.h
下载地址:https://pkgs.org/download/openldap
[root@localhost php]# rpm -ivh openldap-2.4.44-13.el7.x86_64.rpm
[root@localhost php]# rpm -ivh openldap-devel-2.4.44-13.el7.x86_64.rpm --nodeps
9、configure: error: Cannot find ldap libraries in /usr/lib
configure: error: Cannot find ldap libraries in /usr/lib
解决办法:
cp -frp /usr/lib64/libldap* /usr/lib/
10、libmcrypt和libmcrypt-devel没安装错误
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
下载地址:https://pkgs.org/download/libmcrypt
[root@localhost php]# rpm -ivh libmcrypt-2.5.8-13.el7.x86_64.rpm
[root@localhost php]# rpm -ivh libmcrypt-devel-2.5.8-13.el7.x86_64.rpm
11、mysql-devel和php-mysqlnd 没安装的错误
configure: error: wrong mysql library version or lib not found. Check config.log for more information.
下载地址:https://centos.pkgs.org/7/centos-sclo-rh/rh-mysql57-mysql-devel-5.7.21-3.el7.x86_64.rpm.html
[root@localhost php]# rpm -ivh rh-mysql57-mysql-devel-5.7.21-3.el7.x86_64.rpm --nodeps
[root@localhost php]# rpm -ivh rh-php70-php-mysqlnd-7.0.27-1.el7.x86_64.rpm
https://my.oschina.net/hhly/blog/1547227
12、安装完不解析php
(1)没有加上对应的php类型,所以不支持php的脚本解析
解决方法:
在配置文件/usr/local/apache/conf/httpd.conf中,找到AddType application/x-gzip .gz .tgz,在
下面添加一行内容:AddType application/x-httpd-php .php
(2)没有加上针对php的索引,如果没有该索引的支持,则无法解析用php编写的网页
解决办法:
在配置文件/usr/local/apache/conf/httpd.conf中,找到DirectoryIndex index.html,改为
DirectoryIndex index.html index.htm index.php 即可
(3)防火墙没有关闭
我们在实际工作中一般都是要关闭selinux的,可以用命令getenforce来查看一下目前防火墙的状态,如
果是Enforcing,则说明是打开的,可在配置文件中关闭,vim /etc/selinux/config,将enforcing改为
disabled
(4)没有加载 php5_module(shared)模块
我们可以用命令查看一下是否加载了该模块:/usr/local/apache/bin/apachectl -M
看看显示的内容中是否包含了php5_module (shared),如果没有,需要手动加载,在httpd.conf下添加
php模块 LoadModule php5_module modules/libphp5.so
(5)在编译apache时可以加上两个参数,这样以后就不用手动去加载各种模块了,省了很多麻烦
--enable-modes-shared=most //编译加载最多的模块
--enalbe-so
13、没有zip模块,导致系统无法导入excel错误
atal error: Uncaught Error: Class 'ZipArchive' not found in
cd /opt/php/php-7.0.27/ext/zip
[root@localhost zip]# /usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
14、安装php扩展是执行phpize提示错误(没有m4和autoconf导致的错误)
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
安装
[root@localhost php]# rpm -ivh m4-1.4.16-10.el7.x86_64.rpm
[root@localhost php]# rpm -ivh autoconf-2.69-11.el7.noarch.rpm
输出结果:
[root@localhost zip]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20151012/
修改php.ini配置文件:
1)zlib.output_compression = Off 改为 zlib.output_compression = On
2)增加extension = /usr/local/php/lib/php/extensions/no-debug-zts-20151012/zip.so
重启apache
通过phpinfo();输出查看,发现zip依然没有安装成功
15、执行phpize生成configure时的错误(perl-Data-Dumper引起)
Can't locate Data/Dumper.pm in @INC (@INC contains: /usr/share/autoconf /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/share/autoconf/Autom4te/C4che.pm line 33.
BEGIN failed--compilation aborted at /usr/share/autoconf/Autom4te/C4che.pm line 33.
Compilation failed in require at /usr/bin/autom4te line 37.
BEGIN failed--compilation aborted at /usr/bin/autom4te line 37.
安装:perl-Data-Dumper-2.145-3.el7.x86_64.rpm
[root@localhost php]# rpm -ivh perl-Data-Dumper-2.145-3.el7.x86_64.rpm
再次执行
cd /opt/php/php-7.0.27/ext/zip
[root@localhost zip]# /usr/local/php/bin/phpize
/opt/php/php-7.0.27/ext/zip目录中,生成了configure文件
16、php -m提示(没加入环境变量)
[root@localhost ~]# php -m
-bash: php: command not found
解决办法:
export PATH=$PATH:/usr/local/php/bin
然后,再 echo $PATH 看看,就看见了。
[root@localhost ~]# echo $PATH
/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/php/bin
转载请注明:谷谷点程序 » Linux/redhat7.3 安装php以及常见错误