Linux + memcache Installation and configuration __linux

Source: Internet
Author: User
Tags bz2 install php memcached phpinfo
Basic Personal Information:


Memcache definition Memcache is an open source project for Danga.com, a high-performance distributed memory object caching system that can be used to store data in various formats by maintaining a large, unified Hash table in memory. At present, many people around the world use this cache project to build their own heavy load of the site to share the pressure of the database.
It can handle any number of connections and use Non-blocking network IO. Since its working mechanism is to open up a space in memory and then create a HashTable, Memcached How to manage these HashTable why there are Memcache and Memcached two kinds of names.
In fact Memcache is the name of this project, and memcached is its server-side main program file name, know what I mean put ~ ~ ~ ~ ~ One is the project name, one is the main program file name, on the internet to see a lot of people do not understand, so mixed use.


1, call Settings_init () set initialization parameters
2, from the Start command to read the parameters to set the setting value
3. Set Limit parameters
4, start the network socket listening (if not socketpath exist) (after 1.2 support UDP mode)
5. Check user identity (memcached does not allow root to start)
6, if there are socketpath, open Unix local connection (sock pipeline)
7. If you start in-D, create a daemon (such as the daemon function on the call)
8. Initialize item, event, status information, hash, connection, slab
9, such as the managed in the settings, create bucket array
10, check if you need to lock the memory page
11. Initialize signal, connect, delete queue
12, if daemon mode, process ID
13, the event begins, the start process is over, the main function into the loop. Installing the Memcache Environment installation Memcache requires the following two files

1> memcached-1.4.5.tar.gz

2> libevent-1.4.11-stable.tar.gz

Description: Libevent is the only prerequisite for installing memcached. It is the asynchronous event notification library that memcached relies on. You can find the source file on the monkey.org on the Libevent

memcached installation 1. Download memcached and libevent separately 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 zxvflibevent-1.2.tar.gz

#cd libevent-1.2

#./configure–-prefix=/usr

#make

#make Install 3. Test whether the Libevent is installed successfully

#ls-al/usr/lib|greplibevent

lrwxrwxrwx 1root root 2111?? 17:38 libevent-1.2.so.1-> libevent-1.2.so.1.0.3

-rwxr-xr-x 1rootroot263546 11?? 17:38 libevent-1.2.so.1.0.3

-rw-r–r–1 rootroot454156 11?? 17:38libevent.a

-rwxr-xr-x 1rootroot 81111?? 17:38 libevent.la

lrwxrwxrwx 1root root 2111?? 17:38 libevent.so-> libevent-1.2.so.1.0.3 4. Install memcached and require the installation location of the specified libevent in the installation:

#cd/tmp

#tar zxvfmemcached-1.2.0.tar.gz

#cd memcached-1.2.0

#./configure–-with-libevent=/usr

#make

#make Install 5. Test for successful installation of memcached:

#ls-al/usr/local/bin/mem*

-rwxr-xr-x 1rootroot137986 11?? 17:39/usr/local/bin/memcached

Basic Settings for memcached:

Start Memcache Server

#/usr/local/bin/memcached-d-M 100-u root-l 192.168.204.30-p12000-c 64-p/tmp/memcached.pid

Parameter description:

The-D option is to start a daemon,
-M is the amount of memory allocated to Memcache, in megabytes, I am 10MB here,
-U is the user running memcache, I am here root,
-L is a listening server IP address, if there are more than one address, I specify the IP address of the server 192.168.204.30,
-P is the port that sets the memcache listening, I set 12000 here, preferably 1024 or more ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set 64 here, according to the load of your server to set,
-P is set to save the Memcache pid file, which I am saving here in/tmp/memcached.pid

Memcache Status Description

Pid

Memcache The process ID of the server

Uptime

Number of seconds the server has been running

Time

Server's current UNIX timestamp

Version

Memcache version

Pointer_size

The current operating system pointer size (32-bit system is typically 32bit)

Rusage_user

Cumulative user time for the process

Rusage_system

Cumulative system time of the process

Curr_items

The number of items currently stored by the server

Total_items

Total number of items stored since server startup

bytes

The number of bytes consumed by the current server storage items

Curr_connections

The number of connections currently open

Total_connections

Number of connections that have been opened since the server was started

Connection_structures

Number of connection constructs that the server assigns

Cmd_get

Get command (gets) the total number of requests

Cmd_set

Set command (save) number of total requests

Get_hits

Total Hit Count

Get_misses

Total missed Hits

Evictions

Number of items deleted to get free memory (the space allocated to memcache needs to be removed from the old items to get space allocated to new items)

Bytes_read

Total Read bytes (number of bytes requested)

Bytes_written

Total Bytes sent (result bytes)

Limit_maxbytes

Size of memory allocated to Memcache (bytes)

Threads

Current number of threads

To view the startup status:

Local cmd Open the command window, telnet192.168.204.3012000 connected to the Memcache, and then directly enter the stats can see the status of the current memcache, the status of the note for details.

To view the startup status:

View Memcache Process number: Psaux |grepmemcached kill Process: kill-9 ' process number ' (or # kill ' Cat/tmp/memcached.pid ') reboot:/usr/local/bin/ Memcached-d-M 100-u root-l 10.1.35.100-p12000-c 64-p/tmp/memcached.pid installation Memcache PHP extension (does not affect Mecache test) 1. Select the Memcache version that you want to download in Http://pecl.php.net/package/memcache. 2. Install php memcache extension (Please install PHP for details)

Install PHP (download php-5.2.0.tar.bz2 from http://php.net/releases/index.php)
# cd/usr/local
# tar-jxvfphp-5.2.0.tar.bz2
# CD php-5.2.0

####./configure--prefix=[php installation directory]--with-config-file-path=[php installation directory]--with-apxs2=[apache installation directory]/bin/apxs###
#./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php--with-apxs2=/usr/local/apache/bin/ Apxs

#make
# make Install

---------------------------------------------------------------------------------

mv/home/loveme23/apache_1.3.20.tar.gz/usr/local/
mv/home/loveme23/php-4.4.6.tar.gz/usr/local/
Next decompression:
Tar-zxvfphp-4.4.6.tar.gz
Tar-zxvfapache_1.3.20.tar.gz
Down is more important, first compile and install Apache:
./configure--prefix=/usr/local/apache--enable-module=so
Make;makeinstall
Then compile and install PHP:
./configure--prefix=/usr/local/php--with-apxs=/usr/local/apache/bin/apxs--with-config-file-path=/usr/local/ Lib--with-php-config=/usr/local/php/bin/php-config
Make;makeinstall
OK, now that you've finished 50%, it's time to modify httpd.conf and php.ini files.
First we use the command:
Cp/usr/local/php-4.4.6/php.ini-dist/usr/local/lib/php.ini
Vi/usr/local/lib/php.ini
Modify the following as on
Register-golbals =on
Then modify the httpd.conf file
Vi/usr/local/apache/conf/httpd.conf
Modify to the following:
#将ServerAdminq3boy @younet. com line to your mailbox address #documentroot "/home/httpd/html/" Here is the HTML file home directory

#同上

#OptionsFollowSymLinksMultiViews为安全起见, get rid of "Indexes."

#
# DirectoryIndexdefault.phpdefault.phtml Default.php3 default.html default.htm
#
#设置apache的默认文件名次序 (Note: The following two parts can not be commented out, otherwise invalid)

addtypeapplication/x-httpd-php. php. Phtml.php3. Inc
Addtypeapplication/x-httpd-php-source.phps
#设置php文件后缀

Ok! has now completed 98%, the Apache service is launched below

/usr/local/apache/bin/apachectlstart
Make a test.php file and put it in the home directory to test Apache
?
Phpinfo ();
?>
See it. If successful, it will show you the Phpinfo interface tar vxzf memcache-2.2.3.tgz
CD memcache-2.2.3
/usr/local/php/bin/phpize

./configure--prefix=/usr/local/php--with-apxs=/usr/local/apache/bin/apxs--with-config-file-path=/usr/local/ lib--with-php-config=/

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.