码迷,mamicode.com
首页 > Web开发 > 详细

[LAMP环境搭建三]PHP安装

时间:2014-06-28 20:23:05      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:http   get   使用   文件   os   art   


****说明:先全部看一遍,再开始安装****

获取PHP源码包 http://cn2.php.net/get/php-5.5.10.tar.gz/from/this/mirror
wget

安装libxml2:wget ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz
./configure --prefix=/usr/local/libxml2
# yum -y install python-devel

安装zlib:wget http://zlib.net/zlib-1.2.8.tar.gz
./configure --prefix=/usr/local/zlib
/*
安装 libpng: wget http://sourceforge.net/projects/libpng/files/libpng16/1.6.10/libpng-1.6.10.tar.gz/download
tar
cd
cp scripts/makefile.linux makefile
make
make install
注意:这里的 makefile 不是用 ./configure 生成的 , 而是直接从 script/ 目录里拷一个,这一步结束时, libpng 被安装在 /usr/local/lib 下
*/
./configure --prefix=/usr/local/libpng (我采用这个配置 上面的忽略)
不然下面安装gd库会找不到文件

安装  freetype
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz
tar
./configure --prefix=/usr/local/freetype
make
make install

安装 jpeg6
建立目录
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/man
mkdir /usr/local/jpeg6/man/man1
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install
如果make出错:
./libtool --mode=compile gcc -O2 -I. -c ./jcapimin.c
make: ./libtool:命令未找到
make: *** [jcapimin.lo] 错误 127
则:
[root@bogon jpeg-6b]# cp /usr/share/libtool/config/config.sub .
[root@bogon jpeg-6b]# cp /usr/share/libtool/config/config.guess .
然后进入jpeg-6b的源码目录,也就是把 libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件,make clean 再重新configure

安装gd库 2.1.0
找到libgd2.1.0包位置
tar
cd
[root@bogon libgd-2.1.0]# ./configure --prefix=/usr/local/gd --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/jpeg6
make
make install

编译安装php
tar
cd
[root@bogon php-5.5.10]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php/etc --with-libxml-dir=/usr/local/libxml2 --with-zlib-dir=/usr/local/zlib --with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl --enable-gd-native-ttf --enable-mbstring --enable-ftp --enable-bcmath --enable-sockets --enable-zip --enable-soap --enable-calendar --with-curl --with-pdo-mysql --enable-xml --with-iconv --enable-maintainer-zts --without-pear

问题一:
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
解决
[root@bogon php-5.5.10]# yum -y install curl-devel

问题二:
/usr/local/src/php-5.5.10/ext/gd/gd.c:57:22: error: X11/xpm.h: No such file or directory
make: *** [ext/gd/gd.lo] Error 1
问题说明:这是提示gd库不支持xpm
解决方法:
1.安装libxpm
yum install libXpm-devel.x86_64
2.然后重新安装gd库

问题三:
如果编译过程中遇到下列信息:PEAR package PHP_Archive not installed: generated phar will require PHP¨s phar extension be enabled.
这说明没有安装PEAR,解决方案有两种:

1、./configure时附加--without-pear

2、从http://pear.php.net/go-pear下列未打包的pear安装包并执行,步骤如下:

# wget http://pear.php.net/go-pear.phar

# /usr/local/webserver/php/bin/php go-pear.phar
我选了第一种方案

make
make install
/************************
复制配置文件
[root@bogon php-5.5.10]# mkdir /usr/local/php/etc
[root@bogon php-5.5.10]# cp php.ini-production /usr/local/php/etc/php.ini
/**********************
修改apache配置文件
vi /usr/local/apache/conf/httpd.conf
可以修改DocumentRoot目录

在这写入
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
在<IfModule mime_module>中添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddDefaultCharset utf8 (这句使 apache 默认支持 utf8 字符集)

重启apache服务,使配置生效
[root@bogon etc]# /usr/local/apache/bin/apachectl restart

编辑 php.ini 文件,找到
;default_charset="iso-8859-1"
增加一行: default_charset="utf8",可以选也可以不用的哈

然后就可以测试了!
/*********************
多站点配置
将apache配置文件中
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
启用apache的虚拟主机功能
#Include conf/extra/httpd-vhosts.conf
从conf/extra/httpd-vhosts.conf这个文件导入虚拟主机配置
注释去掉
然后 [root@bogon conf]# vi extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin 1787817119@qq.com
DocumentRoot "/mnt/hgfs/win2linux/test"
ServerName turtle.com
ServerAlias www.turtle.com
ErrorLog "logs/turtle-error_log"
CustomLog "logs/turtle-access_log" common
</VirtualHost>
<Directory "/mnt/hgfs/win2linux/test">
Options Indexes FollowSymLinks
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
然后 [root@bogon conf]# vi /etc/hosts
127.0.0.1 turtle.com
到这里虚拟机中就可以访问了,但在主机中还不能,要设置下主机的hosts
加入 192.168.3.130 turtle.com
然后就好了
/******************
配置完成后,可以通过apachectl -t检查配置文件格式是否有误:
# /usr/local/webserver/apache2.2.21/bin/apachectl -t
Syntax OK
如无问题,启动apache服务 service apache restart

/**************************************
扩展
/********************
PHP安装扩展mcrypt以及相关依赖项【PHP安装PECL扩展的方法】
下载Libmcrypt,mhash,mcrypt安装包

Libmcrypt:
wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
tar
cd
./configure
make
make install
说明:libmcript默认安装在/usr/local 安装完后重启机器

再安装mhash
wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download
tar
cd
./configure
make
make install

最后安装mcrypt
wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
tar
cd
[root@bogon mcrypt-2.6.8]# LD_LIBRARY_PATH=/usr/local/lib ./configure
make
make install

出现错误提示:
/bin/rm: cannot remove `libtoolT’: No such file or directory
编辑configure文件,搜索这一行:
$RM "$cfgfile"
然后在这一行开头加个#号当成注释,再保存,编译就没问题了

安装PHP的Pecl扩展mcrypt
注意mcrypt是PHP自带的Pecl扩展,所以只要去PHP的解压缩目录去找mcrypt包即可。

#cd /usr/php-5.5.10/ext/mcrypt
#/usr/local/php/bin/phpize
#./configure --with-php-config=/usr/local/php/bin/php-config
#make && make install
给你的php.ini添加一条extension=mcrypt.so
重启apache
# service apache restart
查看phpinfo(),mcrypt已经安装好
/******************
先看看安装了libevent了没有 ls -la
没有要先安装
[root@bogon libevent-2.0.21-stable]# wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
./configure --prefix=/usr/local/libevent
make
make install
然后安装memcached
wget http://www.memcached.org/files/memcached-1.4.17.tar.gz
tar
cd
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
make
make install
/****************
启动
[root@bogon bin]# ./memcached -d -m 100 -u root -l 127.0.0.1 -p 11211 -c 1024 -P /usr/local/memcached/memcached.pid
查看详情
#ps aux|grep mem
输出pid
#cat /usr/local/memcached/memcached.pid
查看内存使用
#top -n 1 |grep Mem

php的memcache扩展

memcache
wget http://pecl.php.net/get/memcache-2.2.7.tgz
tar
cd
/usr/local/php/bin/phpize
[root@bogon memcache-2.2.7]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir=/usr
make
make install

上述安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/
把php.ini中的extension_dir = “./”修改为
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/”
在配置文件中加入
extension=memcache.so

/*********
memcached
先安装libmemcached
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar
cd
./configure --prefix=/usr/local/libmemcached -with-memcached
make
make install

然后安装memcached
wget http://pecl.php.net/get/memcached-2.1.0.tgz
tar
cd
/usr/local/php/bin/phpize
[root@bogon memcached-2.1.0]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached/
make
make install
修改配置文件 加入
extension=memcached.so

memcached开机启动还没解决!!!!
/****************************
开启错误显示
display_errors=On
error_reporting=E_ALL

[LAMP环境搭建三]PHP安装,布布扣,bubuko.com

[LAMP环境搭建三]PHP安装

标签:http   get   使用   文件   os   art   

原文地址:http://www.cnblogs.com/turtle1991/p/3794711.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!