CentOS6.5 PHP5.4.0+Apache2.4.1+MySQL5.5.21 编译安装

一、准备(把所有的源文件放在‘/usr/local/upload’目录下)

下载:http://pan.baidu.com/s/1gdh2zzP

修改防火墙规则:
# vi /etc/sysconfig/iptables
添加:


# Generated by iptables-save v1.4.7 on Mon Aug 12 22:01:59 2013

*filter

:INPUT ACCEPT [1878:2700330]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [1069:63156]

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

COMMIT

# Completed on Mon Aug 12 22:01:59 2013


重启防火墙服务:
# service iptables restart

二、安装 && 测试

1. 安装关联文件
# yum install gcc gcc-c++ glibc glibc-devel gd gd-devel zlib zlib-devel libtool-ltdl-devel flex autoconf automake -y

2.1 安装 apache

2.1.1安装 apr
# cd /usr/local
# chmod -R 777 upload
# cd ./upload
# tar -zvxf apr.tar.gz 
# cd apr-1.4.6/
# ./configure --prefix=/usr/local/apr
# make && make install

2.1.2安装 apr-util
# cd /usr/local/upload
# tar -zvxf apr-util.tar.gz
# cd apr-util-1.4.1/
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make && make install

2.1.3安装 pcre
# cd /usr/local/upload
# unzip pcre.zip 
# cd ./pcre-8.30
# ./configure --prefix=/usr/local/pcre
# make && make install

2.1.4安装 apache
# cd /usr/local/upload
# tar zxf httpd.tar.gz
# cd ./httpd-2.4.1
# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-so --enable-rewrite
# make && make install


2.1.5将apache安装为系统服务
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
然后 vi /etc/rc.d/init.d/httpd 添加(# !/bin/sh下面)
# chkconfig: 2345 50 90
# description: Activates/Deactivates Apache Web Server
保存退出
最后,运行chkconfig把Apache添加到系统的启动服务组里面:
# chkconfig --add httpd
# chkconfig httpd on
# vi /usr/local/apache2/conf/httpd.conf
修改 #ServerName www.example.com:80
为 ServerName localhost:80
然后 
# service httpd start
访问下主机地址 : It works!

2.2 安装 mysql

参照

https://my.oschina.net/u/923838/blog/804349

2.3 安装 php
2.3.1 安装libxml2
#yum -y install libxml2
#yum install libxml2-devel -y

2.3.2 安装libmcrypt
# cd /usr/local/upload
# tar -zvxf libmcrypt-2.5.8.tar.gz
# cd ./libmcrypt-2.5.8
# ./configure --prefix=/usr/local/libmcrypt
# make && make install

2.3.3 安装mhash
# cd /usr/local/upload
# tar -zvxf mhash-0.9.9.9.tar.gz
# cd ./mhash-0.9.9.9
# ./configure --prefix=/usr/local/mhash
# make && make install
安装freetype 
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local/freetype
make && make install
安装php-gd
yum install php-gd -y
2.3.4 安装openssl,bzip2,libcurl
# yum -y install openssl openssl-devel bzip2 bzip2-devel curl curl-devel

2.3.5 安装php
# cd /usr/local/upload
# tar -zvxf php-5.4.0.tar.gz
# cd php-5.4.0
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --enable-fpm --with-mcrypt=/usr/local/libmcrypt --with-zlib --enable-mbstring  --with-openssl  --with-mysql  --with-mysqli  --with-mysql-sock  --with-png-dir --with-jpeg-dir=/usr/local/jpeg8  --with-freetype-dir=/usr/include/freetype2/freetype  --with-gd  --enable-exif  --enable-gd-native-ttf  --enable-inline-optimization --with-ttf  --enable-mbstring  --with-gettext  --enable-gd-jis-conv  --enable-gd-native-ttf --enable-pdo   --with-pdo-mysql --with-gettext --enable-sockets --enable-bcmath --enable-xml --with-bz2 --enable-zip --with-curl=/usr/share/doc/curl-7.19.7 --enable-sockets --enable-bcmath --enable-xml
# make && make install
# cp php.ini-development /usr/local/php/lib/php.ini
# vi /usr/local/apache2/conf/httpd.conf
确保以下字符串是否存在
LoadModule php5_module modules/libphp5.so
如果没有就加上
在AddType application*后面加如下一行
AddType application/x-httpd-php .php .phtml
在DirectoryIndex index.html加上index.php
DirectoryIndex index.php index.html
保存退出
#service httpd restart
若有error发生
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# service httpd restart

2.3.6 测试php
# vi /usr/local/apache2/htdocs/index.php
加入“<?php phpinfo();?>”,保存退出
在浏览器中输入"http://localhost/index.php",查看是否有phpinfo的消息。

2.3.7 测试php-mysql
# vi /usr/local/apache2/htdocs/php_mysql.php
输入
<?php
$link=mysql_connect('localhost','root','111111');
if(!$link) echo "connect error!";
else echo "connected!";
mysql_close();
?> 
在浏览器输入“http://localhost/php_mysql.php”,若显示“connected!”,说明成功了
---------------------------------------------------------------------------------
2.3.8 添加mysql和php环境变量
修改/etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码:
PATH=$PATH:/usr/local/php/bin:/usr/local/mysql/bin
export PATH
最后:执行 命令source /etc/profile或 执行点命令 ./profile使其修改生效,执行完可通过echo $PATH命令查看是否添加成功。

APC
wget -c http://pecl.php.net/get/APC-3.1.13.tgz
/usr/local/php/bin/phpize
./configure --enable-apc --enable-mmap --enable-apc-spinlocks --disable-apc-pthreadmutex --with-php-config=/usr/local/php/bin/php-config
make
sudomake install
extension= "apc.so" ;
;APCsetting
apc.enabled= 1
apc.shm_segments= 1
apc.shm_size= 64M
apc.optimization= 1
apc.num_files_hint= 0
apc.ttl= 0
apc.gc_ttl= 3600
apc.cache_by_default= on

wget http://pecl.php.net/get/uploadprogress-1.0.3.1.tgz
(具体的下载链接请前往:http://pecl.php.net/package/uploadprogress 查看)
tar xvf uploadprogress*
(解压)
cd uploadprogress*
(切换到解压后的文件夹里)
yum install autoconf gcc-c++ make
(安装一些必须的软件,用于编译、配置、安装之类)
/opt/lamp/php/bin/phpize
(这条命令不要照抄,先找到你的phpize路径后再运行)
./configure --with-php-config=/opt/lamp/php/bin/php-config
(配置编译环境,同样,后面的路径请输入实际路际,别照抄)
make&&make install
(编译并安装,最后会出现:Installing shared extensions:  /opt/lamp/php/lib/php/extensions/ 就表示安装成功了!如下图)
  
ImageMagick  imagick  MagickWandForPHP
ImageMagick 【http://www.imagemagick.org/script/download.php】
imagick 【http://pecl.php.net/package/imagick】
MagickWand For PHP 【http://www.magickwand.org/】
tar zxvf ImageMagick-6.7.5-5.tar.gz
cd ImageMagick-6.7.5-5

./configure
make
make install
ldconfig /usr/local/lib</p> <p>
至此安装结束,安装路径默认为 /usr/local下面
=======================================================
Httpd.conf 加入
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
并修改
<Directory />
    AllowOverride none
    Require all denied
</Directory>

<Directory />
    Options Indexes FollowSymLinks
AllowOverride None
</Directory>
==============================================

2)配置pkgconfig相关参数【如果处理则跳过】

代码如下:

ln -s /usr/local/lib/pkgconfig/MagickWand.pc      /usr/lib/pkgconfig/MagickWand.pc  //可以不用
ln -s /usr/local/lib/pkgconfig/ImageMagick.pc /usr/lib/pkgconfig/ImageMagick.pc //可以不用
3)安装 imagick 【此处以最新版本3.1.0 RC1为例】

代码如下:

tarzxvfimagick-3.1.0RC1.tgz
cdimagick-3.1.0RC1
/usr/local/php/bin/phpize
./configure --enable-shared- -enable-static --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/
make
makeinstall
4)安装MagickWandForPHP【此处以最新版本1.0.9为例】

代码如下:

tar zxvfMagickWandForPHP-1.0.9.tar.gz
cdMagickWandForPHP-1.0.9
/usr/local/webserver/php/bin/phpize
./configure--enable-shared--enable-static--with-php-config=/usr/local/webserver/php/bin/php-config--with-magickwand=/usr/local/
make
makeinstall

php eaccelerator 加速
cd eaccelerator*
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
Make && make install
如出现下面错误表示php不支持 换一个版本acceleratorr
-0.9.6.1/eaccelerator.c  -fPIC -DPIC -o .libs/eaccelerator.o
/work/LAMP/eaccelerator-0.9.6.1/eaccelerator.c: 在函数‘eaccelerator_restore’中:
/work/LAMP/eaccelerator-0.9.6.1/eaccelerator.c:878: 警告:赋值丢弃了指针目标类型的限定
/work/LAMP/eaccelerator-0.9.6.1/eaccelerator.c: 在函数‘eaccelerator_compile_file’中:
/work/LAMP/eaccelerator-0.9.6.1/eaccelerator.c:1317: 错误:‘zend_class_entry’没有名为‘line_start’的成员
/work/LAMP/eaccelerator-0.9.6.1/eaccelerator.c: 在文件层:
/work/LAMP/eaccelerator-0.9.6.1/eaccelerator.c:1913: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘eaccelerator_functions’
/work/LAMP/eaccelerator-0.9.6.1/eaccelerator.c:1938: 错误:‘eaccelerator_functions’未声明(不在函数内);


安装php常见问题
第一个问题:configure: error: libjpeg.(a|so) not found
   cp -frp /usr/lib64/libjpeg.* /usr/lib/

第二个问题:configure: error: libjpng.(a|so) not found
cp -frp /usr/lib64/libpng* /usr/lib/      //和上面方法一样

第三个问题:configure: error: Cannot find ldap libraries in /usr/lib.
cp -frp /usr/lib64/libldap* /usr/lib/     //和上面方法一样


另外附一些常见的configure错误列表供参考:
第一个    configure: error: No curses/termcap library found
解决方法:
redhat and centos运行:yum -y install ncurses-devel
debian and ubuntu运行: apt-get install libncurses5-dev

第二个    configure: error: xml2-config not found
yum -y install libxml2-devel
debian:apt-get install libxml2-dev

第三个    configure: error: Cannot find OpenSSL's
yum -y install openssl-devel

第四个     configure: error: libjpeg.(a|so) not found
yum -y install gd
yum -y install gd-devel
debian:apt-get install libjpeg-dev

第五个     configure: error: libpng.(a|so) not found.
apt-get install libpng12-dev

第六个     configure: error: cannot find output from lex; giving up
yum -y install flex

第七个     configure: error: mod_deflate has been requested but can not be   built due to prerequisite failures
yum -y install zlib-devel openssl-devel
debian:apt-get install zlib1g-dev

第八个     configure: error: libXpm.(a|so) not found.
apt-get install libxpm-dev

第九个     configure: error: freetype.h not found.
apt-get install libfreetype6-dev

第十个     configure: error: No recognized SSL/TLS toolkit detected
apt-get install libssl-dev
yum install libssl-dev

第十一个   Configure: error: xml2-config not found. Please check your libxml2 installation.
yum install libxml2 libxml2-devel (For Redhat & Fedora)
aptitude install libxml2-dev (For ubuntu)


第十二个   configure: error: Cannot find OpenSSL’s
yum install openssl openssl-devel
 
第十三个   Configure: error: Please reinstall the BZip2 distribution
yum install bzip2 bzip2-devel

第十四个   Configure: error: Please reinstall the libcurl distribution -easy.h should be in /include/curl/
yum install curl curl-devel (For Redhat & Fedora)
install libcurl4-gnutls-dev (For Ubuntu)
 
第十五个   Configure: error: libjpeg.(also) not found.
yum -y install gd
yum -y install gd-devel
yum install libjpeg libjpeg-devel

第十六个   Configure: error: libpng.(also) not found.
yum install libpng libpng-devel
apt-get install libpng12-dev

第十七个   Configure: error: freetype.h not found.
yum install freetype-devel

第十八个   Configure: error: Unable to locate gmp.h
yum install gmp-devel

第十九个   Configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!
解决方法:
yum install mysql-devel (For Redhat & Fedora)
apt-get install libmysql++-dev (For Ubuntu)

第二十个   Configure: error: Please reinstall the ncurses distribution
yum install ncurses ncurses-devel

第二十一个 Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
方法 :
yum install unixODBC-devel

第二十二个 Configure: error: Cannot find pspell
yum install pspell-devel

第二十三个 configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install libmcrypt libmcrypt-devel (For Redhat & Fedora)
apt-get install libmcrypt-dev

第二十四个 Configure: error: snmp.h not found. Check your SNMP installation.
yum install net-snmp net-snmp-devel

第二十五个 开启LDAP服务还需要
yum -y install openldap-devel openldap-servers openldap-clients

第二十六个 configure: error: No curses/termcap library found
yum -y install ncurses-devel (for redhat)
apt-get install libncurses5-dev(for debian)

第二十七个 configure: error: cannot find output from lex; giving up
yum -y install flex

第二十八个 configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
yum -y install zlib-devel openssl-devel
debian:apt-get install zlib1g-dev

第二十九个 configure: error: libXpm.(a|so) not found.
apt-get install libxpm-dev
yum install libXpm

转载于:https://my.oschina.net/u/923838/blog/804350

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值