linux服务器-LAMP安装配置3-安装php

安装php(php-5.6.24.tar.gz):

​tar zxvf php-5.6.24.tar.gz

cd php-5.6.24

该版本的php要先下载​libXpm-devel:yum -y install libXpm-devel

./configure --prefix=/usr/local/php \

–with-config-file-path=/usr/local/php/etc \

–with-apxs2=/usr/local/apache/bin/apxs \

–with-mysql=/usr/local/mysql/ \

–with-libxml-dir=/usr/local/libxml2/ \

–with-png-dir=/usr/local/libpng/ \

–with-jpeg-dir=/usr/local/jpegsrc/ \

–with-freetype-dir=/usr/local/freetype/ \

–with-gd=/usr/local/libgd/ \

–with-zlib-dir=/usr/local/zlib/ \

–with-mcrypt=/usr/local/libmcrypt/ \

–with-mysqli=/usr/local/mysql/bin/mysql_config \

–enable-soap \

–enable-mbstring=all \

–enable-sockets \

​–with-xpm-dir=/usr/lib64

出现错误:configure: error: Cannot find libmysqlclient_r under /usr/local/mysql/.

Note that the MySQL client library is not bundled anymore!

解决:由于/usr/local/mysql/lib中做的链接是libmysqlclient.so,需要的是libmysqlclient_r.so,所以再做个链接:

​ cd /usr/local/mysql/lib

ln -s libmysqlclient.so libmysqlclient_r.so

好了,返回安装目录重新执行上面的操作后

make

出现错误:​error: X11/xpm.h: No such file or directory

解决:yum -y install libXpm-devel

出现错误:undefined referenceto `XpmLibraryVersion’

解决:./configure中增加–with-xpm-dir=/usr/lib64

此处解决方案来自:http://www.th7.cn/Program/php/201406/213224.shtml

make install

​注意:这里编译安装出现PEAR package PHP_Archive not installed

解决:​成功编译安装完成后,再安装pear:

wget http://pear.php.net/go-pear.phar

​/usr/local/bin/php go-pear.phar​

此处解决方案来自:​http://www.cnblogs.com/tjxwg/p/3967744.html

安装完成后,需要建立PHP配置文件。在使用configure命令安装配置时使用“–with-config-file-path=/usr /local/php/etc/”选项,指定了配置文件的位置。将源码包下面的php.ini-development 文件复制到/usr/local /php/etc/中,并改名为php.ini即可​

cp php.ini-development /usr/local/php/etc/php.ini

修改php.ini 把;date.timezone 前面的分号去掉,改成date.timezone =“PRC”
​修改apache配置文件:

vim ​/etc/httpd/httpd.conf

找到AddType application/x-gzip .gz .tgz指令选项,并在其下方添加一 条指令AddType application/x-httpd-php .php .phtml

重启apache:/usr/local/apache/bin/apachectl restart

测试PHP环境是否可以正常运行,在/usr/local/apache/htdocs目录下建一个test.php或test.phtml的文件,内容如下示:

浏览器打开:http://服务器IP/test.php ,显示如下信息表示成功安装php

猜你喜欢

转载自blog.csdn.net/weixin_42878826/article/details/83448140