Memcached and PHP extensions are installed under CentOS
- 2021-01-14 07:39:11
- OfStack
In this article, we mentioned how to install memcached on windows. In this article, we discussed how to install Memcached and the PHP extension on Centos
Memcached I. Installation
1. Install the dependency package libevent
Memcached relies on the libevent library, so it may need to be executed before installation
yum install libevent-devel
2. Install memcached
Download the latest source version from http:// memcached. org/ at (1.4.23)
tar -xzvf memcached-1.4.23.tar.gz
cd memcached-1.4.23
./configure --prefix=/usr/local/memcache
make && make install
3. Configure memcached bootstrap
Copy the source directory scripts/memcached sysv to/etc/init d/memcached, need to modify/etc/init d/memcached line is as follows:
chown $USER /usr/local/memcache/bin/memcached
daemon /usr/local/memcache/bin/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached.pid $OPTIONS
Change the path memcached is in.
Then execute the following command:
chmod 755 memcached
chkconfig --add memcached
Use the following directives to start the service
service memcached start
II. Install the PHP extension
pecl.php.net has two extensions to memcache:
memcache memcached extension memcached PHP extension for interfacing with memcached via libmemcached libraryThe version of memcached is relatively new and uses the libmemcached library. The libmemcached is considered to be better optimized and should have higher performance than the php only version of the memcache. php5.4 is installed in /usr/local/php.
1. Install the dependent libraries
https://launchpad.net/libmemcached/1.0/1.0.4/+download/libmemcached-1.0.4.tar.gz
tar -xzvf libmemcached-1.0.4.tar.gz
cd libmemcached-1.0.4
./configure
make
make install
2. Install memcached
http: / / pecl. php. net get/memcached - 2.0.1. tgz download, use the following instructions:
tar vxzf memcached-2.0.1.tgz
cd memcache-2.0.1
phpize
./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config
make
make install
After installation is complete, according to the last display
Installing shared extensions: /usr/local/***
Directory path indicated, where find the generated memcached.so and copy it to the directory pointed to by extension_dir of php.ini. Modify php.ini to add rows
extension = memcached.so
Restart apache and go back to the phpinfo information page to see if the memcached extension was installed successfully.
Of course, we can also write a small test code to see if the memcached is running properly. For details, please refer to how to install memcached on windows system 1 article
conclusion