您的位置:首页 > 运维架构 > Apache

centos5.6下 PHP5.4.0 安装笔记--整合apache 与php

2012-08-17 14:22 519 查看
2.编译安装PHP 5.4.0所需的支持库 

tar zxvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure

make

make install

cd ../

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8/

./configure

make

make install

/sbin/ldconfig

cd libltdl/

./configure --enable-ltdl-install

make

make install

cd ../../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8

ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a

ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la

ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so

ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

/sbin/ldconfig

./configure

make

make install

cd ../ 

3.安装mysql

4.编译php 

 安装依赖包

yum install ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel

tar xvzf php-5.4.0.tar.gz

cd php-5.4.0

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

./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql/ --with-iconv-dir=/usr/local --enable-fpm
 --disable-phar --with-fpm-user=www-data --with-fpm-group=www-data --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --with-curl --enable-dba --with-libxml-dir --enable-ftp --with-mhash --enable-mbstring --with-mcrypt  --enable-pcntl  --enable-xml
--disable-rpath  --enable-shmop --enable-sockets --enable-zip --enable-bcmath  --disable-ipv6

make ZEND_EXTRA_LIBS='-liconv'

make test ==> error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

make install 

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

cd ../

5.编译安装PHP5扩展模块 

 

tar zxvf memcache-3.0.6.tgz

cd memcache-3.0.6

/usr/local/php5/bin/phpize

./configure --with-php-config=/usr/local/php5/bin/php-config

make

make install

cd ../

 

tar xvzf memcached-1.4.13.tar.gz

cd memcached-1.4.13

/usr/local/php5/bin/phpize  # If it's already installed, specify its path using --with-libevent=/dir/

./configure --with-php-config=/usr/local/php5/bin/php-config

make

make install

cd ../

 

tar zxvf ImageMagick-6.7.6-5.tar.gz

cd ImageMagick-6.7.6-5

./configure

make

make install

cd ../

 

tar zxvf imagick-3.1.0RC1.tgz

cd imagick-3.1.0RC1

/usr/local/php5/bin/phpize

./configure --with-php-config=/usr/local/php5/bin/php-config

make    #error

make install

6.修改配置 

 

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

 

最后增加:

;change for hugwww

extension_dir = /usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/

 

extension = "memcache.so"

extension = "memcached.so"

;extension = "imagick.so"

 

修改为:

cgi.fix_pathinfo=0

open_basedir = /tmp:/www/web

expose_php = Off

allow_url_fopen = Off

disable_functions =phpinfo,passthru,ini_restore,eval  #not found

cp /usr/local/php5/etc/php.ini /etc/php.ini

完成!

7、整合apache 与php

# vi /usr/local/apache2/conf/httpd.conf

在最后一行加上:

AddType application/x-httpd-php .php

查找:(设置 WEB 默认文件)

DirectoryIndex index.html

替换为:

DirectoryIndex index.php index.html index.htm //在 WEB 目录不到默认文件,httpd 就会执行 /var/www/error/noindex.html

找到这一段:

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be “All”, “None”, or any combination of the keywords:

# Options FileInfo AuthConfig Limit

#

AllowOverride none

更改为AllowOverride all

允许apache rewrite

# 监听443端口,支持https连接

#取消注释 httpd.conf 中的 Include conf/extra/httpd-ssl.conf

保存httpd.conf,退出。

# /usr/local/apache2/bin/apachectl restart //重启 Apache

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

./configure –build=i686-RedHat-linux-gnu –host=i686-redhat-linux-gnu \

–target=i686-RedHat-linux-gnu –with-apxs2=/usr/sbin/apxs \

–prefix=/usr/local –exec-prefix=/usr/local –with-exec-dir=/usr/local/bin \

–sysconfdir=/etc –libdir=/usr/local/lib/php –with-libdir=lib \

–sbindir=/usr/local/sbin –sharedstatedir=/usr/com –datadir=/usr/local/share \

–includedir=/usr/local/include –libexecdir=/usr/local/libexec \

–localstatedir=/var –cache-file=../config.cache \

–mandir=/usr/local/share/man –infodir=/usr/local/share/info \

–with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d \

–with-pic –with-curl=shared –with-freetype-dir –with-png-dir \

–with-gettext –with-gmp –with-iconv –with-jpeg-dir –with-png-dir \

–with-openssl –with-layout=GNU –with-libxml-dir \

–with-pcre-regex=/usr \

–with-mcrypt=shared –with-mhash –with-zlib –with-bz2=shared \

–with-pdo-mysql –with-mysql –with-mysql-sock=/var/lib/mysql/mysql.sock \

–with-pgsql –with-pdo-pgsql –with-sqlite=shared –with-pdo-sqlite=shared \

–enable-sqlite-utf8 –with-kerberos –with-imap –with-imap-ssl \

–with-pear –with-gd –enable-gd-native-ttf –enable-calendar=shared \

–enable-exif –enable-ftp –enable-sockets –enable-bcmath \

–enable-sysvsem –enable-sysvshm –enable-sysvmsg –enable-intl \

–enable-mbstring –enable-zend-multibyte –enable-zip \

–without-unixODBC –disable-tokenizer \

非RHEL/CentOS系统可以省略 –build,–host,–target 参数,程序会自动判断(LINUX一般为i686-pc-linux-gnu)。如果没安装pgsql或者不需要pgsql的支持可以删除相关参数(共2个)。 bz2, calendar, curl, mcrypt, pdo_sqlite, sqlite 这些模块采用动态编译,可采用下面将会提到的方法加载。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息