標籤:
LAMP Ubuntu 12.04 LTS 搭建基本組件的安裝
#!/bin/env bash#updatesudo apt-get updateecho "********************LAMP*****************************"apt-get install install apache2 php5 mysql-server php5-mysqlecho "********************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
繼續開啟上個測試頁面檢索memcache源碼安裝
需要依賴
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.gzcd libevent-2.0.21-stable./configure make install
安裝完後可以查看下/usr/lib是否有libevent等檔案(ls -al /usr/lib | grep libevent)
tar xzvf memcached-1.4.15.tar.gzcd memcached-1.4.15./configure --with-libevent=/usrmakemake 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 ‘^]‘
OK安裝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 別選錯了..
./configure
make
make install
修改php.ini檔案(/etc/php5/apache2/php.ini或者/etc/php5/fpm/php.ini)
extension=redis.so
重啟apache
再次回到測試頁面 搜尋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安裝(源碼)