1.4-php编译安装--安装顺序在最后
安装PHP阿铭写这本教程时,php当前最新版本为5.5,
相信大多网站还在跑着5.2甚至更老的版本,其实5.2版本的php很经典也很稳定,因为阿铭的公司一直在使用5.2版本,但是考虑到版本太老,难免会有些漏洞,所以建议您使用5.3或者5.4版本,php官方下载地址:
http://www.php.net/downloads.php 当前php5.3的稳定版本为php-5.3.27.
下载php:
# cd /usr/local/src
# wget http://am1.php.net/distributions/php-5.3.27.tar.gz
解压:
# tar zxf php-5.3.27.tar.gz 配置编译参数:
# cd php-5.3.27
# ./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-config-file-path=/usr/local/php/etc\
--with-mysql=/usr/local/mysql \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-bz2 \
--with-openssl \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-sockets \
--enable-exif \
--disable-ipv6
在这一步,阿铭遇到如下错误:
configure: error: xml2-config not found. Please check your libxml2 installation. 解决办法是:
yum install -y libxml2-devel 还有错误:
configure: error: Cannot find OpenSSL's 解决办法是:
yum install -y openssl openssl-devel 错误:
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
解决办法:
yum install -y bzip2 bzip2-devel 错误:
configure: error: png.h not found. 解决办法:
yum install -y libpng libpng-devel 错误:
configure: error: freetype.h not found. 解决办法:
yum install -y freetype freetype-devel 错误:
configure: error: mcrypt.h not found. Please reinstall libmcrypt. 解决办法:
rpm -ivh "http://www.lishiming.net/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"
yum install -ylibmcrypt-devel
因为centos6.x 默认的yum源没有libmcrypt-devel 这个包,只能借助第三方yum源。
编译:
#make 在这一步,您也许还会遇到诸多错误,没有关系,请仔细查看报错信息,解决办法很简单,就是装缺少的库。您可以把错误信息复制到google上搜一下,如果实在是解决不了,请到阿铭论坛(http://www.lishiming.net/forum-40-1.html)发帖请教阿铭吧。
安装:
#make install 拷贝配置文件:
# cp php.ini-production /usr/local/php/etc/php.iniapache结合php
Apache主配置文件为:/usr/local/apache2/conf/httpd.conf
vim /usr/local/apache2/conf/httpd.conf 找到:
AddType application/x-gzip .gz .tgz 在该行下面添加:
AddType application/x-httpd-php .php 找到:
DirectoryIndex index.html
将该行改为:
DirectoryIndex index.html index.php
找到:
#ServerName www.example.com:80 修改为:
ServerName localhost:80测试LAMP是否成功
启动apache之前先检验配置文件是否正确:
/usr/local/apache2/bin/apachectl -t 如果有错误,请继续修改httpd.conf, 如果是正确的则显示为 “Syntax OK”, 启动apache的命令为:
/usr/local/apache2/bin/apachectl start 查看是否启动:
# netstat -lnp |grep httpd
tcp 0 0 :::80 :::* LISTEN 7667/httpd
如果有显示这行,则启动了。 也可以使用curl命令简单测试:
# curl localhost
It works!
只有显示这样才正确。
测试是否正确解析php:
vim /usr/local/apache2/htdocs/1.php 写入:
保存后,继续测试:
curl localhost/1.php 看是否能看到如下信息:
# curl localhost/1.php
php解析正常#
只有显示如阿铭这样才正确。
LAMP环境是搭建好了,这其实仅仅是安装上了软件而已,而具体的配置还是有很多工作要做的呢?也就是说,您虽然搭建出来了环境,但是如果不会配置细节的东西,相当于没有任何工作经验,所以还是多配置配置apache或者php吧,具体参考资料可以到阿铭论坛的相应版本中找到,大多帖子为阿铭工作中所配置过的,阿铭真心希望您能够按照阿铭的帖子配置一下,这样对您有很大的好处。论坛地址:
http://www.lishiming.net/forum.php
阿铭建议您最好再扩展学习一下: http://www.lishiming.net/thread-5441-1-1.html
页:
[1]