您的位置:首页 > 编程语言 > PHP开发

LAMP环境配置之安装PHP

2014-10-17 00:00 423 查看
安装最新版的PHP模块
ps:服务器:CentOS6.5
PHP:php-5.6.1.tar.gz
进入php-5.4.11源码包编译
[root@localhost php-5.4.11]# ./configure \
> --prefix=/usr/local/php \
> --with-config-file-path=/usr/local/php/etc \
> --with-apxs2=/usr/local/apache/bin/apxs \ (编译libphp5.so 是解析php的重要步骤,注意)
> --with-mysql=/usr/local/mysql/ \
> --with-libxml-dir=/usr/local/libxml2/ \
> --with-png-dir=/usr/local/libpng/ \
> --with-jpeg-dir=/usr/local/jpeg8/ \
> --with-freetype-dir=/usr/local/freetype/ \
> --with-gd=/usr/local/gd/ \
> --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
make(配置) 提示信息: Build complete.
Don't forget to run 'make test'. 解决方案:
不要make test 直接make install 配置时可能会出现下面的错误: checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no checking for MySQL UNIX socket location... no
configure: error: Cannot find libmysqlclient_r under /usr/local/mysql. Note that the MySQL client library is not bundled anymore!
其实这跟PHP没有关系,那是因为在编译APACHE的时候,使用--with-mpm模块,所以就必须在编译MYSQL的时候加上 --enable-thread-safe-client.参数
这是PHP5.2的一个改进,在PHP5.2.0之前的版本都不需要MYSQL启用安全线程。关于--enable-thread-safe-client项的官方介绍如下:如何生成线程式客户端库总是线程安全的。最大的问题在于从套接字读取的net.c中的子程序并不是中断安全的。或许你可能希望用自己的告警中断对服务器的长时间读取,以此来解决问题。如果为SIGPIPE中断安装了中断处理程序,套接字处理功能应是线程安全的。SupeSite/X-为了避免连接中断时放弃程序,MySQL将在首次调用mysql_server_init()、mysql_init()或mysql_connect()时屏蔽SIGPIPE。如果你打算使用自己的SIGPIPE处理程序,首先应调用mysql_server_init(),然后安装你的处理程序.
还有第二种解决方法比较方便 :编译之前,先处理一下mysql的库,默认查找libmysqlclient_r.so,可是mysql默认为libmysqlclient.so,内容完全一样,做个链接即可
# cd /usr/local/mysql/lib/mysql/
# ln -s libmysqlclient.so.15.0.0 libmysqlclient_r.so (以上解决方法来自互联网!) 还会报make: *** [ext/gd/gd.lo] error 解决方法如下:
好像说这个错误算是php5.4的bug,下面对应的两篇文章有对应的说明: https://bugs.php.net/bug.php?id=55224 https://bugs.php.net/bug.php?id=60108 解决方法:
vi <gd_dir>/include/gd_io.h gdIOCtx结构中增加void *data; 格式如下
typedef struct gdIOCtx {
int (*getC) (struct gdIOCtx *);
int (*getBuf) (struct gdIOCtx *, void *, int);
void (*putC) (struct gdIOCtx *, int);
int (*putBuf) (struct gdIOCtx *, const void *, int);
/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */ int (*seek) (struct gdIOCtx *, const int);
long (*tell) (struct gdIOCtx *);
void (*gd_free) (struct gdIOCtx *); void (*data); }
gdIOCtx;
我的GD安装在/usr/local/gd2目录下,所以是#vi vi /usr/local/gd/include/gd_io.h libltdl.so.3: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127 解决方法:
ln -s /usr/local/lib/libltdl.so.3 /usr/lib/libltdl.so.3 [root@localhost ~]# cd /usr/local/libpng/lib/ [root@localhost lib]# ls
libpng15.a libpng15.so libpng15.so.15.10.0 libpng.la pkgconfig libpng15.la libpng15.so.15 libpng.a libpng.so 可以看到libpng15.so.15
然后修改/etc/ld.so.conf 文件:vi /etc/ld.so.conf
在第一行下面追加/usr/local/libpng/lib这个路径。 然后重新编译安装即可。 提示信息:
=====================================================================
===================================================================== WARNED TEST SUMMARY
--------------------------------------------------------------------- Bug
#52062
(large
timestamps
with
DateTime::getTimestamp
and
DateTime::setTimestamp) (32 bit) [ext/date/tests/bug52062.phpt] (warn: XFAIL section but test passes)
=====================================================================
You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at http://qa.php.net/reports and http://news.php.net/php.qa.reports This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it. You can then email it to qa-reports@lists.php.net later. Do you want to send this report now? [Yns]: 解决方案:
不要make test 直接make install
安装完成后,需要建立PHP配置文件。在使用configure命令安装配置时使用
“--with-config-file-path=/usr/local/php/etc/”选项,指定了配置文件的位置。将源码包下面的php.ini-development 文件复制到/usr/local/php/etc/中,并改名为php.ini即可,如下示:
[root@localhost php-5.4.11]# cp php.ini-development /usr/local/php/etc/php.ini 修改php.ini 把;date.timezone 前面的分号去掉,改成date.timezone ="PRC"
整合Apache与PHP,上面编译之前,我们使用configure命令安装配置时,使用--with-apxs2=/usr/local/apache242/bin/apxs选项以使Apache 2将PHP作为功能模块使用。但我们还要修改Apahce配置文件,添加PHP的支持,告诉Apache将哪些后缀作为PHP解析。例如,让Apache把.php或.phtml后缀名解析为PHP.使用vi打开Apache的配置文件/etc/httpd/httpd.conf,找到AddType application/x-gzip .gz .tgz指令选项,并在其下方添加一条指令AddType application/x-httpd-php .php .phtml。也可以将任何后缀的文件解析为PHP,只要在添加的语句中加入并用空格分开,这里以多添加一个.phtml来示例,如下示:
# If the AddEncoding directives above are commented-out, then you # probably should define those extensions to indicate media types: #
AddType application/x-compress .Z AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .phtml
修改完成后必须重启Apache服务器,才能重新加载配置文件使修改生效。 [root@localhost php-5.4.11]#/usr/local/apache243/bin/apachectl stop [root@localhost php-5.4.11]#/usr/local/apache243/bin/apachectl start
测试PHP环境是否可以正常运行,在/usr/local/apache243/htdocs目录下建一个test.php或test.phtml的文件,内容如下示: <?php
phpinfo(); ?>
打开浏览器,在地址栏输入http://192.168.146.129/test.php来运行该文件,如果出现下图内容,说明LAMP环境安装成功。



上例中使用phpinfo()函数,作用是输出有关PHP当前状态的大部分信息内容,这包括关于PHP的编译和扩展信息、PHP版本、服务器信息和环境、PHP的环境、操作系统信息、路径、主要的和本地配置选项的值、HTTP头信息和PHP许可等。因为每个系统的安装不同,phpinfo()函数可以用于检查某一特定系统配置设置和可用的预定义变量等。它也是一个宝贵的调试工具,因为它包含了所有EGPCS(Environment,GET,POST,Cookie,Server)数据。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐