首先...
我必须说,我对服务器了解不多。我是那种不经常使用命令行的 php 开发人员。我对终端很不习惯。
不过,我正在学习。我不习惯将我的网站放在没有托管主机的专用服务器上。但现在我第一次拥有它,我需要自己安装 Memcache。
一些服务器信息
- 产品:Media Temple 上的专用服务器 (DV)
- Parallels® Plesk Panel 12 或 cPanel® 11
- CentOS 5.7(最终版本)
- Apache 2.2
- PHP 5.4
- YUM 包管理
我做了什么
我已遵循以下指南:https://mediatemple.net/community/products/dv/204644340/installing-pecl-extensions
但当然是用memcache
而不是uploadprogress
。
我已经检查过,Memcache 已安装并正在运行。并且$memcache = new Memcache;
在我的 php 代码中运行正常。但是$memcache->connect('localhost', 11211);
它不起作用。我收到错误消息:
Warning: Memcache::connect(): Can't connect to localhost:11211, Connection refused (111) in /var/www/vhosts/[mydomain]/httpdocs/index.php on line 10 Could not connect to memcache server
我曾尝试更改localhost
服务器的 IP 号码,但没有成功。
我之前在 Google 上搜索了很多,最后找到了关于安装的文章和论坛帖子Memcached
。所以我按照其中一个指南尝试安装它。但收到错误消息,No package memcached available.
因此无法安装。
以下是我之后执行的命令示例:
Nothing to do
[root@mydomain /]# php -i | grep memcache
PHP Warning: Module 'memcache' already loaded in Unknown on line 0
/etc/php.d/memcached.ini,
PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in Unknown on line 0
memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.default_port => 11211 => 11211
memcache.default_timeout_ms => 1000 => 1000
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => standard => standard
memcache.max_failover_attempts => 20 => 20
Registered save handlers => files user memcache
OLDPWD => /memcached-1.4.9
_SERVER["OLDPWD"] => /memcached-1.4.9
[root@mydomain /]# ps aux | grep memcache
root 6434 0.0 0.0 9288 868 pts/0 S+ 02:37 0:00 grep memcache
[root@mydomain /]# getenforce
Disabled
所以...
我忘记做什么了?
答案1
更新!
所以我最终成功了。方法如下:
- 在 Google 上搜索“查看 memcached 是否已在命令行 centos5 中安装”
- 点击第三个结果,最终进入此页面:http://cnedelcu.blogspot.se/2009/09/setting-up-and-using-memcached-memcache.html
- 按照步骤操作
成功安装Memcached,但无法安装Memcache:
[root@mydomain /]# yum install php-pecl-memcache Loaded plugins: fastestmirror, priorities Loading mirror speeds from cached hostfile * base: centos.mirror.nac.net * extras: mirror.atlanticmetro.net * updates: centos.mirror.nac.net base | 1.1 kB 00:00 extras | 2.1 kB 00:00 updates | 1.9 kB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package php-pecl-memcache.x86_64 0:2.2.3-1.el5_2 set to be updated --> Processing Dependency: php-api = 20041225 for package: php-pecl-memcache --> Finished Dependency Resolution php-pecl-memcache-2.2.3-1.el5_2.x86_64 from extras has depsolving problems --> Missing Dependency: php-api = 20041225 is needed by package php-pecl-memcache-2.2.3-1.el5_2.x86_64 (extras) Error: Missing Dependency: php-api = 20041225 is needed by package php-pecl-memcache-2.2.3-1.el5_2.x86_64 (extras) You could try using --skip-broken to work around the problem You could try running: package-cleanup --problems package-cleanup --dupes rpm -Va --nofiles --nodigest The program package-cleanup is found in the yum-utils package.
但是,似乎并不需要成功。Memcache 似乎现在可以正常工作了!