大家好,又见面了,我是你们的朋友全栈君。
All the files above are locate in /home/davidhhuan/Software
1. Install the libevent-2.0.10-stable.tar.gz
/
home
/
davidhhuan
/
Software
tar zxf libevent
–
2.0
.
10
–
stable.tar.gz
cd libevent
–
2.0
.
10
–
stable
.
/
configure
sudo make
sudo make instsall
2. Install memcached-1.4.5.tar.gz
/
home
/
davidhhuan
/
Software
tar zxf memcached
–
1.4
.
5
.tar.gz
cd memcached
–
1.4
.
5
.
/
configure
sudo make
sudo make install
3. Install memcache-2.2.6.tgz
/
home
/
davidhhuan
/
Software
tar zxf memcache
–
2.2
.
6
.tgz
cd memcache
–
2.2
.
6
/
opt
/
lampp
/
bin
/
phpize
Ok, here i got these error:
代码
/
opt
/
lampp
/
include
/
php
/
main
/
php.h: No such file or directory
grep:
/
opt
/
lampp
/
include
/
php
/
Zend
/
zend_modules.h: No such file or directory
grep:
/
opt
/
lampp
/
include
/
php
/
Zend
/
zend_extensions.h: No such file or directory
Configuring
for
:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
That is because i am using xampp, and xampp does NOT provide these files which only exist in php directory! Thought I don’t want to install another php in my host, but i still have to compile it to get the files, please follow the step 4.
4. Compile php5
/
home
/
davidhhuan
/
Software
tar zxf php
–
5.3
.
4
.tar.bz2
cd php
–
5.3
.
4
.
/
configure
Too bad, when i try to compile the php5, that said i don’t have the libxml2! ok, see the step 5
5. Install libxml2-2.7.2.tar.gz
/
home
/
davidhhuan
/
Software
tar zxf libxml2
–
2.7
.
2
.tar.gz
cd libxml2
–
2.7
.
2
.
/
configure
sudo make
sudo make install
6. Install php-5.3.4 again
/
home
/
davidhhuan
/
php
–
5.3
.
4
.
/
configure
sudo make
sudo make install
7. Move the php files to xampp
After step 6, the included php files are located in /usr/local/include, follow it
–
rf
/
usr
/
local
/
include
/
php
/
opt
/
lampp
/
include
/
php
8. Install memcache-2.2.6 again
/
home
/
davidhhuan
/
Software
/
memcache
–
2.2
.
6
/
opt
/
lampp
/
bin
/
phpize
OMG, i still met some errors:
代码
20041225
Zend Module Api No:
20060613
Zend Extension Api No:
220060519
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF
environment variable is set correctly and then rerun this script.
so, i have to install autoconf, see step 9
9. Install autoconf
代码
/
usr
/
src
sudo wget http:
//
ftp.gnu.org
/
gnu
/
m4
/
m4
–
1.4
.
9
.tar.gz
sudo tar
–
zvxf m4
–
1.4
.
9
.tar.gz
cd m4
–
1.4
.
9
/
.
/
configure
sudo make
sudo make install
cd ..
/
sudo wget http:
//
ftp.gnu.org
/
gnu
/
autoconf
/
autoconf
–
2.62
.tar.gz
sudo tar
–
zvxf autoconf
–
2.62
.tar.gz
cd autoconf
–
2.62
/
.
/
configure
sudo make
sudo make install
10. Install memcache-2.2.6 again again!
/
home
/
davidhhuan
/
Software
/
memcache
–
2.2
.
6
/
opt
/
lampp
/
bin
/
phpize
.
/
configure
-_-! I met errors:
代码
for
the location of ZLIB… no
checking
for
the location of zlib… configure: error: memcache support requires ZLIB. Use
—
with
–
zlib
–
dir
=
<DIR
>
to specify prefix where ZLIB include and library are located
No problem, just install zlib
Go, go, go, step 11 can help you! :)
11. Install zlib-1.2.5.tar.gz
/
home
/
davidhhuan
/
Software
tar zxf zlib
–
1.2
.
5
.tar.gz
cd zlib
–
1.2
.
5
.
/
configure
sudo make
sudo make install
12. Install memcache-2.2.6 again again again!
/
home
/
davidhhuan
/
Software
/
memcache
–
2.2
.
6
.
/
configure
sudo make
sudo make install
/
usr
/
local
/
lib
/
php
/
extensions
/
no
–
debug
–
non
–
zts
–
20090626
/
13. Copy the memcache.so to xampp
/
usr
/
local
/
lib
/
php
/
extensions
/
no
–
debug
–
non
–
zts
–
20090626
/
memcache.so
/
opt
/
lampp
/
lib
/
php
/
extensions
/
no
–
debug
–
non
–
zts
–
20090626
/
memcache.so
14. Configure the php.ini
=
memcache.so
15. Configure the service of memcache
a. start the memcache server.
usr
/
bin
/
memcached
–
d
–
m
100
–
u davidhhuan
–
l
127.0
.
0.1
–
p
11211
–
c
256
–
P
/
tmp
/
memcached.pid
-d: set to daemon
-m: max running memory, units:MB
-u: the user of memcached
-l: the server IP
-p: the port
-c: The maximum number of simultaneous connections running, default is 1024
-P: the file to save the memcache
b. stop the server.
/
tmp
/
memcached.pid’
You can also start multi thread to run the server, the port must be different.
c. Restart the apache.
/
opt
/
lampp
/
lampp restart
Example:
php
$mem
=
new
Memcache;
$mem
->
connect(
“
127.0.0.1
“
,
11211
);
$mem
->
set(
“
key
“
,
“
This is a test!
“
,
0
,
60
);
$val
=
$mem
->
get(
“
key
“
);
echo
$val
;
?>
Hope this article will help you to install the memcache!
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/139402.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...