linux下安装 PHP5.2.x,配置apache

转自http://blog.sina.com.cn/s/blog_53f023270101rbq3.html

linux下安装 PHP5.2.x
 
1.apache已经安装,并且安装地址为:/usr/local/web/apache2
2.下载PHP 并解压缩: 
下载地址:http://cn2.php.net/get/php-5.2.17.tar.gz/from/a/mirror
将文件上传到linux服务器
# tar zxvf php-5.2.17.tar.gz 
# cd php-5.2.17 
3.设置安装配置信息
查看confiure配置帮助文件
# ./configure --help
根据帮助文件开启需要的模块信息。
# ./configure --prefix=/usr/local/web/php --with-apxs2=/usr/local/web/apache2/bin/apxs  --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --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 --with-bz2 --with-mysql --with-mysqli --with-pdo-mysql --with-xsl

如果提示:xml2-config not found. Please check your libxml2 installation
则安装:libxml2 libxml2-devel
# yum install libxml2
# yum install libxml2-devel -y
安装完之后查找xml2-config文件是否存在
# find / -name "xml2-config"
如果提示:annot find OpenSSL's
安装:openssl-devel
# yum install openssl openssl-devel
如果提示:Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/
安装:curl curl-devel 
# yum install curl curl-devel 
如果提示:error: libjpeg.(a|so) not found
则安装:gd gd-devel
# yum -y install gd
# yum -y install gd-devel
如果提示:error: Cannot find ldap.h
则安装:openldap-devel openldap-servers openldap-clients
# yum -y install openldap-devel openldap-servers openldap-clients
如果提示:error:mcrypt.h not found. Please reinstall libmcrypt
则安装:libmcrypt libmcrypt-devel
# yum install libmcrypt libmcrypt-devel
如果提示:No package libmcrypt available.
则先下载:# rpm -ivh "http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
再重新安装:libmcrypt libmcrypt-devel
如果提示:error:Please reinstall libmhash
则安装:libmhash libmhash-devel
# yum install libmhash libmhash-devel
如果提示: error: Please reinstall the BZip2 distribution
则安装:bzip2 bzip2-devel
# yum install bzip2 bzip2-devel
如果提示: configure: error: Cannot find MySQL header files under yes.
则安装:mysql-devel 
# yum install mysql-devel 
如果提示: error: xslt-config not found.  Please reinstall the libxslt >= 1.1.0 distribution
则安装:libxslt libxslt-devel 
# yum install libxslt libxslt-devel 
重新设置安装配置信息
3.make程序
# make ZEND_EXTRA_LIBS='-liconv' 
 
如果提示错误:
/usr/bin/ld: cannot find -liconv
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
则下载libiconv-1.14.tar.gz 并上传到服务器安装。
下载地址:http://www.gnu.org/software/libiconv/#downloading
安装libiconv:
# tar zxvf libiconv-1.14.tar.gz
# cd libiconv-1.14 
# ./configure --prefix=/usr/local
# make
# make install
cd /home/php/php-5.2.17 
重新make一下
# make distclean(如果想重新config时,先用这个命令,然后config然后再make)
# make ZEND_EXTRA_LIBS='-liconv' 
4.安装php
# make install 
如果报错:
/root/Nginxsource/php-5.2.14/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         #很明显meke  install的时候找不到libiconv.so.2的库文件了
make: *** [install-pear] Error 2                       #貌似这个错误在Centos6.x上面每次编译都会报错!
解决的方法如下:
1.在/etc/ld.so.conf中加一行/usr/local/lib,
2.然后运行ldconfig
这样就ok了它就能找到库文件了
再重新安装一下。
# cp php.ini-dist /usr/local/web/php/lib/php.ini
完成php安装
总结部分内容:
相关关联库安装:
yum -y install libxml2 libxml2-devel openssl openssl-devel curl curl-devel gd gd-devel openldap-devel openldap-servers openldap-clients bzip2 bzip2-devel mysql-devel libxslt libxslt-devel 
rpm -ivh "http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
yum -y install libmcrypt libmcrypt-devel libmhash libmhash-devel
./configure --prefix=/usr/local/web/php --with-apxs2=/usr/local/web/apache2/bin/apxs  --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --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 --with-bz2 --with-mysql --with-mysqli --with-pdo-mysql --with-xsl
配置apache
# vi /usr/local/web/php/lib/php.ini
修改下面的内容为On
    register_globals = On
然后修改httpd.conf文件
    vi /usr/local/web/apache2/conf/httpd.conf
修改为下面的内容:
    #将ServerAdmin
   [email=q3boy@younet.com]q3boy@younet.com[/email]
    一行改为您的邮箱地址
    #DocumentRoot "/usr/local/web/apache2/htdocs" 此处为html文件主目录
    # 同上
    #Options FollowSymLinks MultiViews 为安全起见,去掉"Indexes"
    #
    # DirectoryIndex default.php default.phtml default.php3 default.html default.htm
    #
    #设置apache的默认文件名次序
    #AddType application/x-httpd-php .php .phtml .php3 .inc
    #AddType application/x-httpd-php-source .phps
    #设置php文件后缀
   OK!现在已经完成98%了,下面启动apache服务
   /usr/local/apache/bin/apachectl start
   自己制作一个test.php文件放到主目录中测试apache
   如果成功的话,会显示你的phpinfo界面。
memcachem模块需要单独安装。
可以使用php自带的pecl安装程序
# cd /usr/local/web/php/bin
# ./pecl install memcache
安装完后会有类似这样的提示:
Installing '/usr/local/web/php/lib/php/extensions/no-debug-non-zts-20060613/memcache.so'
install ok: channel://pecl.php.net/memcache-2.2.7
configuration option "php_ini" is not set to php.ini location
You should add "extension=memcache.so" to php.ini
把这个记住,然后修改php.ini,把
extension_dir = "./"
修改为
extension_dir = "/usr/local/web/php/lib/php/extensions/no-debug-non-zts-20060613/"
并添加一行
extension="memcache.so"
点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注