LAMP Ubuntu 12.04 LTS Build---Comes with memcache redis installation (source code)

Source: Internet
Author: User
Tags install redis
LAMP Ubuntu 12.04 LTS build basic components installation
#! / 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
Test script
Place in / var / www
<? php
echo mysql_connect ('127.0.0.1', 'root', 'Enter the password you set for MySQL during installation')? "mysql ok": "Database connection failed";

phpinfo ();

 ?>

Retrieve page GD curl mysql these
PHP5 commonly used extensions
sudo apt-get install php5-gd curl libcurl3 libcurl3-dev php5-curl

mysql remote access

/etc/mysql/my.cnf comment out bind_address = 127.0.0.1

Install memcache
sudo apt-get instal memcached

sudo apt-get instal php5-memcache

Best to install with 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

Continue to open the previous test page to retrieve the memcache source code installation
Need to rely on

http://www.monkey.org/~provos/libevent-2.0.13-stable.tar.gz

http://www.danga.com/memcached/dist/memcached-1.4.0.tar.gz

Best cut to root / tmp

download

tar xzvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure
make install

After installation, you can check if there are files such as libevent in / usr / lib (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
If it appears: Trying 127.0.0.1 ...
   Connected to 127.0.0.1.
   Escape character is ‘^]‘

OK install redis
sudo apt-get install redis-server

Note that make test does not install 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
#Uncomment requirepass
requirepass password

set password

sudo vi /etc/redis/redis.conf #note bind # bind 127.0.0.1 remote access


Install extension
wget https://github.com/nicolasff/phpredis/zipball/master -O php-redis.zip
unzip php-redis.zip
Go to the directory: cd php-redis
phpize (ps: this is a tool for compiling extensions under php-dev, if not, run sudo apt-get install php5-dev to install)
If libssl is missing
apt-get install libssl

Then aptitude install libssl remember to choose n y y y and don't choose wrong ...

./configure
make
make install

Modify the php.ini file (/etc/php5/apache2/php.ini or /etc/php5/fpm/php.ini)
extension = redis.so

Restart apache
Return to the test page again and search for redis
$ redis = new Redis ();
$ redis-> connect ('127.0.0.1', 6379);
$ redis-> set ('name', 'jigsaw');
echo $ redis-> get ('name')

Finish
Here is the source code to install 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

After opening
redis_6379
Modify
$ {REDISPORT} .pid

Remove $ {REDISPORT}
sudo mkdir -p / var / redis / 6379
sudo vim /etc/redis/6379.conf
The items that need to be modified are as follows:

Set the service as a daemon: daemonize yes
Set the log file path: logfile "/var/log/redis_6379.log"
Set the database file path: dir "/ var / redis / 6379"

sudo service redis_6379 start
redis-cli
> set key "hello"
> OK
> get key
"Hello"

Go to /var/redis/6379/dump.rdb if it exists
Check if /var/log/redis_6379.log has content
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 build --- with memcache redis installation (source code)

============== ↑ Article display ↑ ==============
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.