手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

在Amazon EC2主机上部署LAMP环境

[日期:2013-11-30] 来源:Linux社区  作者:phenixikki [字体:大 中 小]

三、编译安装php-5.4.22
1、安装PHP所依赖的软件包
<1> RPM安装mcrypt
$ cd /usr/src/lamp
$ sudo wget ftp://ftp.muug.mb.ca/mirror/Fedora/epel/beta/6/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm
$ sudo wget http://www.gymglish.com/opensource/rpms/CentOS6-rpms/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
$ sudo rpm -ivh lib*

<2> Yum安装libxml和bzip2的devel包
$ sudo yum install libxml2-devel.x86_64
$ sudo yum install bzip2-devel.x86_64

2、编译安装php-5.4.22

$ cd /usr/src/lamp
$ sudo wget http://au1.php.net/distributions/php-5.4.22.tar.bz2
$ sudo tar xf php-5.4.22.tar.bz2
$ cd php-5.4.22
$ sudo ./configure --prefix=/usr/local/php --with-MySQL=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc/ --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
$ sudo make
$ sudo make install

为php提供配置文件:

$ sudo cp php.ini-production /etc/php.ini

3、编辑httpd配置文件,使其支持php及默认主页

$ sudo vim /etc/httpd/httpd.conf

# 添加以下内容:
AddType application/x-httpd-php  .php
AddType application/x-httpd-php-source  .phps
# 修改以下内容:
DirectoryIndex  index.php  index.html

4、编辑httpd配置文件,新建虚拟主机

$ sudo vim /etc/httpd/httpd.conf
Include /etc/httpd/extra/vhosts.conf

1234567891011 $ sudo vim /etc/httpd/extra/vhosts.conf
<VirtualHost *:80>
  DocumentRoot "/mydata/web"
  ServerName cominggo.com
  ServerAlias www.cominggo.com
  <Directory "/mydata/web">
    Options none
    AllowOverride none
    Require all granted
  </Directory>
</VirtualHost>

5、重启httpd服务并测试

$ sudo servcie httpd configtest
$ sudo service httpd restart

四、安装PHP加速器XCache(可选)
1、编译安装xcache-3.0.4

$ cd /usr/src/lamp
$ sudo wget http://xcache.lighttpd.net/pub/Releases/3.0.4/xcache-3.0.4.tar.gz
$ sudo tar xf xcache-3.0.4.tar.gz
$ cd xcache-3.0.4
$ /usr/local/php/bin/phpize
$ sudo /usr/local/php/bin/phpize
$ sudo ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
$ sudo make
$ sudo make install
# 安装结果如下:
Installing shared extensions:    /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

2、编辑xcache配置文件,整合PHP和XCache

$ sudo mkdir /etc/php.d
$ sudo cp xcache.ini /etc/php.d/

$ sudo vim /etc/php.d/xcache.ini
# 修改以下内容:
extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

注:xcache自3.0版本开始不再支持使用zend_extension加载xcache

3、重启httpd服务并测试

$ sudo service httpd restart

linux
相关资讯       lamp  Amazon EC2 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款