Install the Memcache server in Linux. In linux, memcache server installation server is mainly to install memcache server, the latest version is memcached-1.3.0. Download: install the memcache server in www. danga. commemcacheddistme linux.
The server is mainly installed on the memcache server, the latest version is memcached-1.3.0.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, memcache uses the libevent library for socket processing, so you also need to install libevent, the latest version of libevent is the libevent-1.3. (If your system has already installed libevent, you do not need to install it)
Official website: http://www.monkey.org /~ Provos/libevent/
Download: http://www.monkey.org /~ Provos/libevent-1.3.tar.gz
Use the wget command to directly download these two items.
1. install libevent first. During configuration, you need to specify an installation path, that is,./configure-prefix =/usr; then make install;
2. install memcached again. you only need to specify the installation path of libevent during configuration, that is,./configure-with-libevent =/usr; then make install;
This completes the installation of the memcache server in linux. The detailed method is as follows:
1. download memcached and libevent respectively and put them in the/tmp Directory:
# Cd/tmp
# Wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz
# Wget http://www.monkey.org /~ Provos/libevent-1.2.tar.gz
2. install libevent first:
# Tar zxvf libevent-1.2.tar.gz
# Cd libevent-1.2
#./Configure-prefix =/usr
# Make
# Make install
(Note: an error occurs during execution here:
1, no acceptable c compiler found in $ path
Because gcc is not installed on centos by default, yum is used for installation.
# Yum install gcc * make *
)
3. test whether the libevent is successfully installed:
# Ls-al/usr/lib | grep libevent
Lrwxrwxrwx 1 root 21 11 ?? Libevent-1.2.so.1> libevent-1.2.so.1.0.3
-Rwxr-xr-x 1 root 263546 11 ?? Libevent-1.2.so.1.0.3
-Rw-r-1 root 454156 11 ?? 12 libevent.
-Rwxr-xr-x 1 root 811 11 ?? Libevent. la
Lrwxrwxrwx 1 root 21 11 ?? 12 libevent. so-> libevent-1.2.so.1.0.3
Not bad. they all have been installed.
4. install memcached and specify the libevent installation location during installation:
# Cd/tmp
# Tar zxvf memcached-1.2.0.tar.gz
# Cd memcached-1.2.0
#./Configure-with-libevent =/usr
# Make
# Make install
If an error is reported in the middle, check the error information carefully and configure or add the corresponding library or path according to the error information.
(Note: an error occurs during installation:
1 linux warning: a clock error is detected. Your creation may be incomplete
Solution:
Modify Current time:
[Root] # date-s '2017/5 8:01:00'
Write the current system time to cmos
# Clock-w
)
After the installation is complete, the memcached will be placed in/usr/local/bin/memcached,
5. test whether memcached is successfully installed:
# Ls-al/usr/local/bin/mem *
-Rwxr-xr-x 1 root 137986 11 ?? 12 :39/usr/local/bin/memcached
-Rwxr-xr-x 1 root 140179 11 ?? 12 :39/usr/local/bin/memcached-debug
Php Tutorial extension for installing memcache
1. select the desired memcache version in the http://pecl.php.net/package/memcache.
2. install memcache extension for php
Tar vxzf memcache-2.2.1.tgz
Cd memcache-2.2.1
/Usr/local/php/bin/phpize
./Configure-enable-memcache-with-php-config =/usr/local/php/bin/php-config-with-zlib-dir
Make
Make install
(Note:
1 phpize not found
Solution:
By default, centos does not install php-devel.
Yum install php-devel
2 make: *** [memcache. lo] error 1
Zlib not installed
Yum install zlib-devel
3. change the configuration command to./configure -- enable-memcache -- with-php-config =/usr/bin/php-config -- with-zlib-dir.
Here, enable and with are preceded by two --
)
3. a message similar to this will appear after the above installation:
Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/
4. modify extension_dir = "./" in php. ini
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx /"
5. add a row to load the memcache extension: extension = memcache. so
Basic settings of memcached:
1. start the memcache server:
#/Usr/local/bin/memcached-d-m 10-u root-l 192.168.0.200-p 12000-c 256-p/tmp/memcached. pid
-D option is to start a daemon,
-M indicates the amount of memory allocated to memcache. the unit is mb. here I am 10 mb,
-U is the user who runs memcache. here I am root,
-L is the IP address of the listening server. if there are multiple IP addresses, I have specified the IP address 192.168.0.200,
-P is the port for memcache listening. I have set Port 12000 here, preferably port 1024 or above,
-The "c" option is the maximum number of concurrent connections. the default value is 1024. I have set 256 here, which is based on the load of your server,
-P is the pid file for saving memcache. here I save it in/tmp/memcached. pid,
(Note:
1
An error occurred:/usr/local/bin/memcached: error while loading shared libraries: libevent-1.3.so.1: cannot open shared object file: no such file or directory
Set link directly
# Ln-s/usr/local/libevent/lib/libevent-1.3.so.1/lib64/libevent-1.3.so.1
)
2. to end the memcache process, run:
# Kill 'cat/tmp/memcached. Pi'
You can also start multiple daemon processes, but the ports cannot be repeated.
3. restart apache and service httpd restart
Test the memcache environment:
Run the following php file. if this is a test! is output !, Indicates that the environment is successfully set up. Start to appreciate the charm of memcache!
<? Php
$ Mem = new memcache;
$ Mem-> connect ("192.168.0.200", 12000 );
$ Mem-> set ('key', 'This is a test! ', 0, 60 );
$ Val = $ mem-> get ('key ');
Echo $ val;
?>
The slave server is mainly installed on the memcache server, and the latest version is memcached-1.3.0. Download: http://www.danga.com/memcached/dist/me...