Memcached was installed in Linux for the first time. It was successfully installed due to previous years of linux maintenance experience and completed in just a few minutes. Memcached needs to use the libevent library for socket processing. Therefore, first install libevent: 1. Install libeventcd/usr/local/srcwgethttp: // monkey.org /~ Provos/libevent-1.4.13-stable.t
Memcached was installed in Linux for the first time. It was successfully installed due to previous years of linux maintenance experience and completed in just a few minutes.
Memcached needs to use the libevent library for socket processing. Therefore, first install libevent:
1. Install libevent
Cd/usr/local/src
Wget http://monkey.org /~ Provos/libevent-1.4.13-stable.tar.gz
Tar zxvf libevent-1.4.13-stable.tar.gz
Cd libevent-1.4.13-stable
./Configure
Make & make install
You can see some generated library files under/usr/local/lib.
2. Run ldconfig
3. Install memcached
Cd/usr/local/src
Wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
Tar zxvf memcached-1.4.5.tar.gz
Cd memcached-1.4.5
./Configure
Make & make install
After the installation is complete, the compiled memcached will be put under/usr/local/bin.
4. Run memcached.
#/Usr/local/bin/memcached-d-m 100-u root-l 192.168.1.1-p 11211-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 is 100 MB,
-U is the user who runs Memcache. You can also use adduser to create a user for memcahed.
-L is the IP address of the listening server. The IP address 192.168.1.1 is specified here.
-P is the port for Memcache listening. I have set 11211 here. Because it is the default port, the-p parameter is not specified.
-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 am saving it in/tmp/memcached. pid
5. Run/etc/sysconfig/system-config-securitylevel to open port 11211 on the firewall. You can also execute:
Iptables-a input-p tcp -- dport 11211-j ACCEPT
6. telnet 192.168.1.1 11211 on another machine. After successful connection, enter stats to view the returned status report.
Appendix 1:
Install the PHP extension of 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
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
Appendix 2:
Ldconfig command details
Ldconfig is a dynamic link library management command. To share a dynamic link library with the system, you also need to run the dynamic link library management command-the purpose of the ldconfigldconfig command, it mainly searches for directories (/lib and/usr/lib) by default and dynamic library configuration files/etc/ld. so. find the shared dynamic link library under the directory listed in conf (format as described earlier, lib *. so *) to create a dynamic loader (ld. so) the required connection and cache file. the default cached file is/etc/ld. so. cache. This file stores the list of Dynamic Linked Library names in the sorted order.
Ldconfig is usually run when the system starts. When you install a new dynamic link library, you need to manually run this command.
The ldconfig command line is used as follows:
Ldconfig [-v | -- verbose] [-n] [-N] [-X] [-f CONF] [-c cache] [-r ROOT] [-l] [-p | -- print-cache] [-c FORMAT] [-- format = FORMAT] [-V] [-? | -- Help | -- usage] path...
The options available in ldconfig are described as follows:
(1)-v or -- verbose: When this option is used, ldconfig displays the directory being scanned, The searched dynamic link library, and the name of the connection it created.
(2)-n: When this option is used, ldconfig only scans the directory specified by the command line and does not scan the default directory (/lib,/usr/lib ), nor scan the configuration file/etc/ld. so. conf directory.
(3)-N: This option indicates that ldconfig does not recreate the cache file (/etc/ld. so. cache). If the-X option is not used, ldconfig updates the file connection as usual.
(4)-X: This option indicates that ldconfig does not update the file connection. If the-N option is not used, the cached file will be updated normally.
(5)-f CONF: This option specifies that the configuration file of the dynamic link library is CONF, and the default value is/etc/ld. so. conf.
(6)-c cache: This option specifies that the generated CACHE file is CACHE. The default value is/etc/ld. so. cache. This file stores the list of dynamically linked libraries that can be shared in the sorted order.
(7)-r ROOT: This option changes the ROOT directory of the application to ROOT (implemented by calling the chroot function ). when this option is selected, the system default configuration file/etc/ld. so. conf, which corresponds to ROOT/etc/ld. so. conf. for example, when-r/usr/zzz is used, open the configuration file/etc/ld. so. in conf,/usr/zzz/etc/ld is actually enabled. so. conf file. this option can greatly increase the flexibility of dynamic link library management.
(8)-l: Generally, ldconfig automatically establishes a connection to the dynamic link library when searching for a dynamic link library. when this option is selected, the expert mode is enabled. You need to manually set the connection. this option is not required for general users.
(9)-p or -- print-cache: This option indicates that ldconfig prints the names of all the shared libraries saved in the current cache file.
(10)-c FORMAT or -- format = FORMAT: This option is used to specify the FORMAT used by the cache file. There are three types: old (old format), new (new FORMAT) and compat (compatible format, which is the default format ).
(11)-V: This option prints the version information of ldconfig, and then exits. (12 )-? Or -- help or -- usage: the three options share the same role, so that ldconfig prints the help information and then exits.