linux 下php环境搭建

linux 下php环境搭建

 

 

Centos 先用root安装这一堆

yum install libpng

yum install libpng-devel

yum -y install libjpeg-devel

yum -y install curl-devel

yum install bzip2

yum install bzip2-devel

yum install libxml2

yum install libxml2-devel -y

yum install libmcrypt

yum install libmcrypt-devel

php安装:

http://jingyan.baidu.com/article/29697b91145c44ab20de3ccf.html

 

makefile

./configure --prefix=/data/php  --enable-fpm --with-mcrypt \--enable-mbstring --disable-pdo --with-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-mysql --with-mysqli \--with-gd --with-jpeg-dir

 

make

 

出现一些错误:

RFC: DateTime and Daylight Saving Time Transitions (zone type 3, bd2) [ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt]  XFAIL REASON: Still not quite right

RFC: DateTime and Daylight Saving Time Transitions (zone type 3, fs) [ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt]  XFAIL REASON: Still not quite right

Bug #42718 (unsafe_raw filter not applied when configured as default filter) [ext/filter/tests/bug42718.phpt]  XFAIL REASON: FILTER_UNSAFE_RAW not applied when configured as default filter, even with flags

Bug #67296 (filter_input doesn't validate variables) [ext/filter/tests/bug49184.phpt]  XFAIL REASON: See Bug #49184

zend multibyte (7) [ext/mbstring/tests/zend_multibyte-07.phpt]  XFAIL REASON: https://bugs.php.net/bug.php?id=66582

zend multibyte (9) [ext/mbstring/tests/zend_multibyte-09.phpt]  XFAIL REASON: https://bugs.php.net/bug.php?id=66582

Bug #45712 (NaN/INF comparison) [ext/standard/tests/math/bug45712.phpt]  XFAIL REASON: Bug 45712 not fixed yet.

=====================================================================

=====================================================================

FAILED TEST SUMMARY

---------------------------------------------------------------------

Bug #52202 (CURLOPT_PRIVATE gets clobbered) [ext/curl/tests/bug52202.phpt]

Phar: phpinfo display 1 [ext/phar/tests/phpinfo_001.phpt]

Phar: phpinfo display 2 [ext/phar/tests/phpinfo_002.phpt]

Phar: phpinfo display 4 [ext/phar/tests/phpinfo_004.phpt]

Test setlocale() function : usage variations - Setting all available locales in the platform [ext/standard/tests/strings/setlocale_variation2.phpt]

=====================================================================

=====================================================================

WARNED TEST SUMMARY

---------------------------------------------------------------------

zend multibyte (2) [ext/mbstring/tests/zend_multibyte-02.phpt] (warn: XFAIL section but test passes)

zend multibyte (6) [ext/mbstring/tests/zend_multibyte-06.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 [email protected] later.

Do you want to send this report now? [Yns]: n

 

不用管,继续安装

make install

 

chown root /安装目录/sbin/php-fpm 

chmod u+s /安装目录/sbin/php-fpm 

拷贝配置文件

cp php.ini-production /安装目录/lib/php.ini  #php配置文件

cp /安装目录/etc/php-fpm.conf.default /安装目录/etc/php-fpm.conf #php-fpm配置文件

 设置你的配置文件

 vi php-fpm.conf

user = 你创建的非root用户

group = 你创建的非root用户组 

 启动php-fpm

 /安装目录/sbin/php-fpm 

结束进程php-fpm(root权限)

pkill php-fpm

 查看是否启动成功: 

netstat -lnt | grep 9000

tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN

 启动nginx

 /安装目录/nginx/nginx

 

测试一下数据库的连接:

<?php

echo"asdasdasd";

$DB = mysql_connect ( "数据库地址" , "用户名" , "密码" ) ;

if($DB)

{echo "链接成功";}

else

{echo "链接失败";}?>

 

 

Notice: Undefined variable的解决办法:

http://www.shangxueba.com/jingyan/1919822.html

 

 PHP默认配置会报这个错误,我的PHP版本是5.2.13,存在这个问题:

    Notice: Undefined variable

    这就是将警告在页面上打印出来,虽然这是有利于暴露问题,但实现使用中会存在很多问题。

    需要设置显示错误级别,来解决问题。

    网络上的通用解决办法是修改php.ini的配置:

    解决方法:

   

    1) error_reporting设置:

    找到error_reporting = E_ALL

    修改为error_reporting = E_ALL & ~E_NOTICE

猜你喜欢

转载自crabdave.iteye.com/blog/2299466
今日推荐