首页 > 代码库 > LAMP Ubuntu 12.04 LTS 搭建 ---附带memcache redis安装(源码)
LAMP Ubuntu 12.04 LTS 搭建 ---附带memcache redis安装(源码)
LAMP Ubuntu 12.04 LTS 搭建
基本组件的安装
#!/bin/env bash #update sudo apt-get update echo "********************LAMP*****************************" apt-get install install apache2 php5 mysql-server php5-mysql echo "********************php5-extend gd curl******************************" apt-get install php5-gd curl libcurl3 libcurl3-dev php5-curl测试脚本
位置放在/var/www 中
<?php echo mysql_connect('127.0.0.1', 'root', '输入你安装时候给MYSQL设定的密码') ? "mysql ok" : "数据库连接失败"; phpinfo(); ?>
检索页面GD curl mysql 这些
php5常用扩展
sudo apt-get install php5-gd curl libcurl3 libcurl3-dev php5-curl
mysql remote access
/etc/mysql/my.cnf 把 bind_address= 127.0.0.1 注释掉
安装memcache
sudo apt-get instal memcached
sudo apt-get instal php5-memcache
最好用apt安装
sudo vi /etc/php5/conf.d/memcache.ini
;uncomment the next line to enable the module
extension=memcache.so
[memcache]
memcache.dbpath="/var/lib/memcache"
memcache.maxreclevel=0
memcache.maxfiles=0
memcache.archivememlim=0
memcache.maxfilesize=0
memcache.maxratio=0
源码安装
需要依赖
http://www.monkey.org/~provos/libevent-2.0.13-stable.tar.gz
http://www.danga.com/memcached/dist/memcached-1.4.0.tar.gz
最好切到root /tmp
下载
tar xzvf libevent-2.0.21-stable.tar.gz cd libevent-2.0.21-stable ./configure make install
安装完后可以查看下/usr/lib是否有libevent等文件(ls -al /usr/lib | grep libevent)
tar xzvf memcached-1.4.15.tar.gz cd memcached-1.4.15 ./configure --with-libevent=/usr make make install
ls -al /usr/local/bin/memcached
/usr/local/bin/memcached -d -m 1024 -u root -p 11211
# telnet 127.0.0.1 11211
如果出现: Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is ‘^]‘
安装redis
sudo apt-get install redis-server
注意make test 如果不过 安装 sudo apt-get install tcl8.5
ps -aux|grep redis
redis-cliredis 127.0.0.1:6379>
redis 127.0.0.1:6379> set key1 "hello"
OK
redis 127.0.0.1:6379> get key1"hello"
sudo vi /etc/redis/redis.conf
#取消注释requirepass
requirepass 密码
设置密码
sudo vi /etc/redis/redis.conf #注释bind#bind 127.0.0.1 远程访问
安装扩展
wget https://github.com/nicolasff/phpredis/zipball/master -O php-redis.zip
unzip php-redis.zip
进入目录:cd php-redis
phpize (ps:这个是php-dev下的编译扩展的工具,如果没有的话快点执行 sudo apt-get install php5-dev安装)如果说libssl 缺少 先安他
apt-get install libssl 如果还是安不了
那么就 aptitude install libssl 记住选n y y y 别选错了..
./configuremake
make install
修改php.ini文件(/etc/php5/apache2/php.ini或者/etc/php5/fpm/php.ini)
extension=redis.so
再次回到测试页面 搜索redis
$redis = new Redis(); $redis->connect('127.0.0.1',6379); $redis->set('name','jigsaw'); echo $redis->get('name')
完毕
下面是源码安装redis
cd /tmp wget http://download.redis.io/releases/redis-2.8.8.tar.gz cd redis-2.8.8 make make install
sudo mkdir /etc/redis sudo cp redis.conf /etc/redis/6379.conf cd utils sudo cp redis_init_script /etc/init.d/redis_6379
打开后
redis_6379修改
${REDISPORT}.pid
去掉${REDISPORT}sudo mkdir -p /var/redis/6379
sudo vim /etc/redis/6379.conf
需要修改的项如下:
设置服务为后台程序:daemonize yes
设置日志文件路径:logfile "/var/log/redis_6379.log"
设置数据库文件路径:dir "/var/redis/6379"
sudo service redis_6379 start
redis-cli
>set key “hello”
>OK
>get key
”hello"
去/var/redis/6379/dump.rdb是否存在
查看/var/log/redis_6379.log是否有内容
OK!
<? $redis = new Redis(); $redis->connect(‘127.0.0.1′,6379); $redis->set(‘test’,'hello world!’); echo $redis->get(‘test’); ?>
LAMP Ubuntu 12.04 LTS 搭建 ---附带memcache redis安装(源码)