apache+php+postgres的web服务器搭建

一、         环境要求

1、          系统平台:centos6.0

2、          编译软件:gccmake

3、          依赖程序:libeventbuild-essentiallibtoolautoconf

4、          辅助程序:unzipwget

二、         安装apache+php+postgres

1、          下载bitnami-lappstack-5.4.34-0-linux-x64-installer.run(该程序包含apache+php+postgres

1)    进入/opt/userfile(如果没有userfile文件夹,执行mkdir /opt/userfile)在终端执行如下命令:

cd /opt/userfile

2)    下载,(使用wget进行下载,如果wget无法运行,那么安装wget,在超级用户模式下运行yum install wget) 在终端root用户下执行如下命令:

wget http://downloads.bitnami.com/files/stacks/lappstack/5.4.34-0/bitnami-lappstack-5.4.34-0-linux-x64-installer.run

3)    修改权限

chmod u+x /opt/userfile/   bitnami-lappstack-5.4.34-0-linux-x64-installer.run

2、          安装bitnami-lappstack-5.4.34-0-linux-x64-installer.run

1)执行如下命令

/opt/userfile/   bitnami-lappstack-5.4.34-0-linux-x64-installer.run

2)接着出现如下:

095145_PR1Q_1999122.png


等一系列选择,全部输入
Y之后回车即可。

4)当输入完以上选项后出现

100224_iCCW_1999122.png

直接回车即可。

5)上一步回车之后出现:

100443_6n2Z_1999122.png

输入需要设置的postgres 数据库密码,我这里输入postgres 之后回车,输入后再次输入postgres 再次回车。

6)执行完上一步骤之后出现:

100656_aX6Q_1999122.png

输入Y然后回车即可。

然后就出现:

100833_RqWm_1999122.png

请耐心等待几分钟,当进度条前进到100%的时候就快安装完成了。

7)当进度条到100%,出现如下所示,

100904_KVEm_1999122.png

输入Y回车,运行程序。

8)打开防火墙端口80,5432

#打开805432端口

/sbin/iptables -I INPUT -p tcp --dport 80   -j ACCEPT

/sbin/iptables -I INPUT -p tcp --dport 5432 -j ACCEPT

#保存更改

/etc/rc.d/init.d/iptables   save

#重启防火墙

/etc/init.d/iptables restart

9)测试是否安装成功。

首先执行如下命令:

cp /opt/lappstack-5.4.34-0/docs/phpinfo.php /opt/lappstack-5.4.34-0/apache2/htdocs/

然后打开浏览器,在地址栏输入:192.168.10.97/phpinfo.php (IP地址根据实际情况填写:可以在CENTOS 终端下运行ifconfig

查看IP);当出现如下界面的时候代表安装成功:

101722_JAW2_1999122.png9)至此php+postgres+apache安装完成。


三、         安装memcached

1、          安装gccmake,在终端的root模式下运行如下命令:

yum install make gcc

2、          安装libevent, 在终端的root模式下运行如下命令:

yum install libevent-devel

3、          下载memcached

3.1、进入/opt/userfile文件夹然后用wget下载,命令如下:

cd /opt/userfile

wget http://www.memcached.org/files/memcached-1.4.16.tar.gz


4、          解压memcached-1.4.16.tar.gz

tar -zxvf   memcached-1.4.16.tar.gz

cd memcached-1.4.16


5、          编译安装(以下命令建议全部在root模式下,运行,特别是make install)

5.1 生成makefile文件,执行如下命令

./configure

5.2 编译源文件,执行如下命令

make

5.3 测试编译是否成功

make test

5.4 安装

make   install

6、          打开memcached使用的11211端口

#打开11211端口

/sbin/iptables -I INPUT -p tcp --dport 11211 -j ACCEPT

#保存更改

/etc/rc.d/init.d/iptables save

#重启防火墙

/etc/init.d/iptables restart

7、          启动memcached,命令如下:

memcached   -d -m 1024 -u root -l 0.0.0.0 -p 11211 -c 1024 -P /tmp/memcached.pid

参数说明: 
-d
启动为守护进程 
-m <num>
分配给Memcached使用的内存数量,单位是MB,默认为64MB 
-u <username>
运行Memcached的用户,仅当作为root运行时 
-l <ip_addr>
监听的服务器IP地址,默认为环境变量INDRR_ANY的值 
-p <num>
设置Memcached监听的端口,最好是1024以上的端口 
-c <num>
设置最大并发连接数,默认为1024 
-P <file>
设置保存Memcachedpid文件,与-d选择同时使用 

8、          停止memcached

kill `cat /tmp/memcached.pid`

9、          至此memcached安装完成了!


四、         安装memcache

1、          安装依赖包及辅助程序:命令如下

yum install build-essential libtool   autoconf unzip

2、          下载memcache压缩包

cd /opt/userfile

wget   http://pecl.php.net/get/memcache-2.2.4.tgz

3、          解压

tar -zxf   memcache-2.2.4.tgz

4、          配置PHP环境变量

export   PHP_AUTOCONF=/usr/bin/autoconf

export   PHP_PREFIX=/opt/lappstack-5.4.34-0/php

5、          进入/opt/userfile/memcache-2.2.4目录

cd /opt/userfile/memcache-2.2.4

6、          生成配置文件,如果不进行该步骤,则没有configure文件

/opt/lappstack-5.4.34-0/php/bin/phpize

7、对软件进行配置,坚持当前环境是否满足安装要求

./configure --enable-memcached --with-zlib-dir=/opt/lappstack-5.4.34-0/common  --with-php-config=/opt/lappstack-5.4.34-0/php/bin/php-config


8、          编译
make

 

9、          检测编译是否成功

make test

当显示如下内容的时候表示编译成功:


10、          安装

make install

 

11、          修改php.ini文件

cd /opt/lappstack-5.4.34-0/php/etc

vi php.ini

查找 ;extension=memcache.so

去掉前面的分号即可。

12、          重启lappstack

cd /opt/lappstack-5.4.34-0/

./ctlscript.sh restart

 

       13.在浏览器中输入192.168.10.97/phpinfo.php (IP地址根据实际情况填写:然后在界面中查找memcache,当界面中有如下内容是代表安装成功。

14、至此安装完成。


转载于:https://my.oschina.net/vitofarm/blog/339157

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值