当前位置: 首页 » 产品 » 微商货源 » 正文

php5.3.10的安装配置步骤详解

放大字体  缩小字体 发布日期: 2024-09-25 18:25   来源:http://www.baidu.com/  作者:无忧资讯  浏览次数:23
核心提示:  在linux中php安装配置与windows中有不小的区别了,在linux中几乎都是代码形式了,下面我们一起来看看php5.3.10的安装配置步

  在linux中php安装配置与windows中有不小的区别了,在linux中几乎都是代码形式了,下面我们一起来看看php5.3.10的安装配置步骤详解,希望下文可帮助到各位。

  下面以最新的php-5.3.10为例进行安装。

  wget

  tar -zxvf php-5.3.10.tar.gz

  cd php-5.3.10

  http://www.jsgho.com/help/fwq/configure --prefix=http://www.3lian.com/usr/local/php --with-config-file-path=http://www.3lian.com/usr/local/php/etc --with-mysql=http://www.3lian.com/usr/local/mysql --with-mysqli=http://www.3lian.com/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap

  上面的具体参数可以使用http://www.jsgho.com/help/fwq/configure --help查看

  make ZEND_EXTRA_LIBS='-liconv'

  make test

  make && make install (此处最好分开做,因为make的时候会有报错出现。)

  我在上面的make时就报了下面的错误

  root/source/php-5.3.10/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

  make: *** [ext/phar/phar.php] Error 127

  解决办法是(我的mysql安装目录是/usr/local/msyql,这个视自己的mysql安装路径而定。)

  ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/

  64位系统应使用下面的这行

  ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

  若报下面的错,就是编绎mysql的时候没有加上mysqli这一项,把下面标红的那部分取消掉,重新编绎就行了。

  make: *** [ext/mysqli/mysqli.lo] Error 1

  http://www.jsgho.com/help/fwq/configure --prefix=http://www.3lian.com/usr/local/php --with-config-file-path=http://www.3lian.com/usr/local/php/etc --with-mysql=http://www.3lian.com/usr/local/mysql --with-mysqli=http://www.3lian.com/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap

  另外,也有报下面错的可能。该问题有可能是没有安装iconv这个编码转换的包,也有可以装了,但是仍有这个错。

  sapi/cli/php: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory

  make[1]: *** [install-pear-installer] Error 127

  make: *** [install-pear] Error 2

  find / -name libiconv.so.2在/usr/lib/libiconv.so.2位置发现libiconv已经安装。

  于是运行/sbin/ldconfig,再重新编译,不再报上面的错。ldconfig用于加载最新编绎过的包。

  注:上面很多需要的包我都是通过通过http://www.jsgho.com/help/fwq/configure --prefix=http://www.3lian.com/usr --libdir=http://www.3lian.com/usr/lib --sysconfdir=http://www.3lian.com/etc参数编绎。这样其在默认的目录就能找到该包了。

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

  cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

  cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf

  修改php.ini文件和php-fpm文件中参数,可以手动更改也可以用下面的sed命令更改

  sed -i 's#short_open_tag=Off#short_open_tag=On#g' /usr/local/php/etc/php.ini

  sed -i 's#;pid=run/php-fpm.pid#pid=run/php-fpm.pid#g' /usr/local/php/etc/php-fpm.conf

  sed -i 's#pm.max_children=5#pm.max_children=32#g' /usr/local/php/etc/php-fpm.conf

  sed -i 's#pm.start_servers=2#pm.start_servers=16#g' /usr/local/php/etc/php-fpm.conf

  sed -i 's#pm.min_spare_servers=1#pm.min_spare_servers=8#g' /usr/local/php/etc/php-fpm.conf

  sed -i 's#pm.max_spare_servers=3#pm.max_spare_servers=32#g' /usr/local/php/etc/php-fpm.conf

  sed -i 's#;pm.max_requests=500#pm.max_requests=120#g' /usr/local/php/etc/php-fpm.conf

  php官方也给出了其中所有参数项的解释说明,具体见

  设置开机启动

  chmod 755 /etc/init.d/php-fpm

  chkconfig --add php-fpm

  /etc/init.d/php-fpm start

  至此,php的安装完毕。

  最后可以再安装一些php的扩展包和开户php加速(具体软件包可以视网上的最新版进行安装):

  tar zxvf memcache-2.2.5.tgz

  cd memcache-2.2.5/

  /usr/local/php/bin/phpize

  http://www.jsgho.com/help/fwq/configure --with-php-config=http://www.3lian.com/usr/local/php/bin/php-config

  make

  make install

  cd http://www.jsgho.com/help/

  tar jxvf eaccelerator-0.9.6.1.tar.bz2

  cd eaccelerator-0.9.6.1/

  /usr/local//php/bin/phpize

  http://www.jsgho.com/help/fwq/configure --enable-eaccelerator=shared --with-php-config=http://www.3lian.com/usr/local/php/bin/php-config

  make

  make install

  cd http://www.jsgho.com/help/

  tar zxvf PDO_MYSQL-1.0.2.tgz

  cd PDO_MYSQL-1.0.2/

  /usr/local/php/bin/phpize

  http://www.jsgho.com/help/fwq/configure --with-php-config=http://www.3lian.com/usr/local/php/bin/php-config --with-pdo-mysql=http://www.3lian.com/usr/local/mysql

  make

  make install

  cd http://www.jsgho.com/help/

  tar zxvf ImageMagick.tar.gz

  cd ImageMagick-6.5.1-2/

  http://www.jsgho.com/help/fwq/configure

  make

  make install

  cd http://www.jsgho.com/help/

  tar zxvf imagick-2.3.0.tgz

  cd imagick-2.3.0/

  /usr/local/php/bin/phpize

  http://www.jsgho.com/help/fwq/configure --with-php-config=http://www.3lian.com/usr/local/php/bin/php-config

  make

  make install

  cd http://www.jsgho.com/help/

  修改php.ini文件

  手工修改:查找/usr/local/php/etc/php.ini中的extension_dir="http://www.jsgho.com/help/fwq/"

  修改为extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"

  并在此行后增加以下几行,然后保存:

  extension="memcache.so"

  extension="pdo_mysql.so"

  extension="imagick.so"

  再查找output_buffering=Off

  修改为output_buffering=On

  再查找; cgi.fix_pathinfo=0

  修改为cgi.fix_pathinfo=0,防止Nginx文件类型错误解析漏洞。

  配置eAccelerator加速PHP:

  mkdir -p /opt/webserver/eaccelerator_cache

  vi /usr/local/php/etc/php.ini

  在php.ini配置文件的最末尾,加上以下配置信息:

  [eaccelerator]

  zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"

  eaccelerator.shm_size="64"

  eaccelerator.cache_dir="/opt/webserver/eaccelerator_cache"

  eaccelerator.enable="1"

  eaccelerator.optimizer="1"

  eaccelerator.check_mtime="1"

  eaccelerator.debug="0"

  eaccelerator.filter=""

  eaccelerator.shm_max="0"

  eaccelerator.shm_ttl="3600"

  eaccelerator.shm_prune_period="3600"

  eaccelerator.shm_only="0"

  eaccelerator.compress="1"

  eaccelerator.compress_level="9"

  php的安全性设置:

  找到:;open_basedir=

  修改为:open_basedir=.:/tmp/ #防止php木马跨站,重要!!

  找到:disable_functions=

  修改为:disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,

ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,

dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,

 
 
[ 产品搜索 ]  [ 加入收藏 ]  [ 告诉好友 ]  [ 打印本文 ]  [ 违规举报 ]  [ 关闭窗口 ]

 

 
推荐图文
推荐产品
点击排行
    行业协会  备案信息  可信网站