centos apc 安装_如何在Linux上安装APC

centos apc 安装

How to install APC on Linux
How to install APC on Linux

Installing APC on Linux. About week ago I made post about using APC caching with PHP. As I noticed – this post was pretty popular, I even got several responses to personal email regarding this post. Today I will tell you how to install APC (for PHP) on Linux system.

在Linux上安装APC。 大约一周前,我发表了关于将APC缓存与PHP结合使用的文章 。 正如我所注意到的-这篇文章非常受欢迎,我什至收到了有关该帖子的一些个人电子邮件回复。 今天,我将告诉您如何在Linux系统上安装APC(用于PHP)。

Pay attention – for installing you will need to have root SSH access. This operation usually permitted at hostings like VPS/VDS, but not at shared hostings.

注意-安装时,您将需要具有root SSH访问权限。 此操作通常在VPS / VDS之类的主机上允许,但在共享主机上则不允许。

步骤1 –下载APC (Step 1 – Downloading APC)

Firstly – you need to download APC package from PHP PECL library. I can advice to download APC package to /opt folder at server or in account (but not to ‘www’ folder). Ok, now lets connect to our host via SSH (Putty as example), goto selected folder for APC package (as example /opt), and run next command:

首先–您需要从PHP PECL库下载APC软件包。 我可以建议将APC软件包下载到服务器上或帐户中的/ opt文件夹中(但不下载到'www'文件夹中)。 好的,现在让我们通过SSH(例如Putty)连接到我们的主机,转到APC软件包的选定文件夹(例如/ opt),然后运行下一个命令:


$ wget http://pecl.php.net/get/APC

$ wget http://pecl.php.net/get/APC

This command will download latest version of APC. Nowadays – this is APC-3.1.9.tgz. In result – we will see that this file appear in our folder:

此命令将下载最新版本的APC。 如今-这是APC-3.1.9.tgz。 结果–我们将看到此文件出现在我们的文件夹中:


$ ls -al
total 200
drwxr-xr-x  3 root    root      4096 Aug 27 23:35 .
drwxr-xr-x 20 root    root      4096 Sep 19 12:36 ..
-rw-rw-r--  1 xmusics xmusics 155540 May 14 15:15 APC-3.1.9.tgz

$ ls -al
total 200
drwxr-xr-x  3 root    root      4096 Aug 27 23:35 .
drwxr-xr-x 20 root    root      4096 Sep 19 12:36 ..
-rw-rw-r--  1 xmusics xmusics 155540 May 14 15:15 APC-3.1.9.tgz

步骤2 –提取包 (Step 2 – Extracting package)

Here are easy command for extracting archive:

这是提取存档的简单命令:


$ tar -zxf APC-3.1.9.tgz

$ tar -zxf APC-3.1.9.tgz

In result – new folder ‘APC-3.1.9’ will appear. Lets enter inside

结果–将出现新文件夹“ APC-3.1.9”。 让我们进入里面


$ cd APC-3.1.9

$ cd APC-3.1.9

第3步– phpize (Step 3 – phpize)

Now we need to run ‘phpize’ command:

现在我们需要运行“ phpize”命令:


$ phpize

$ phpize

This command required to prepare a PHP extension for compiling

准备用于编译PHP扩展所需的此命令

步骤5 –配置 (Step 5 – configure)

Now we need to configure our APC (pointing where located our php-config), lets search where we have php-configs:

现在我们需要配置我们的APC(指向我们的php-config所在的位置),让我们搜索我们有php-configs的位置:


$ whereis php-config

$ whereis php-config

In result we can see something like this:

结果,我们可以看到如下所示:


$ whereis php-config
php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz

$ whereis php-config
php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz

First one looks correct path, second one related with ‘man’ (this is short from Manual). So, now lets run next command to configure APC:

第一个看起来正确的路径,第二个看起来与“ man”相关(这是《手册》的缩写)。 因此,现在让我们运行next命令来配置APC:


./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config

./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config

During execution it will show you many different information, different checking, creating etc.

在执行期间,它将向您显示许多不同的信息,不同的检查,创建等。

步骤6 –制作 (Step 6 – make)

Now we need to run ‘make’ command:

现在我们需要运行“ make”命令:


$ make

$ make

In result – it can executed successfully:

结果–它可以成功执行:


$ make
.......
Build complete.

$ make
.......
Build complete.

Or we can get error:

否则我们会得到错误:


$ make
.......
In file included from /opt/APC-3.1.9/apc.c:38:
/usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /opt/APC-3.1.9/apc.c:38:
/usr/include/php/ext/pcre/php_pcre.h:45: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/usr/include/php/ext/pcre/php_pcre.h:46: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/usr/include/php/ext/pcre/php_pcre.h:52: error: expected specifier-qualifier-list before 'pcre'
/opt/APC-3.1.9/apc.c:362: error: expected specifier-qualifier-list before 'pcre'
/opt/APC-3.1.9/apc.c: In function 'apc_regex_compile_array':
/opt/APC-3.1.9/apc.c:419: error: 'apc_regex' has no member named 'preg'
/opt/APC-3.1.9/apc.c:419: error: 'apc_regex' has no member named 'preg'
/opt/APC-3.1.9/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/opt/APC-3.1.9/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/opt/APC-3.1.9/apc.c: In function 'apc_regex_match_array':
/opt/APC-3.1.9/apc.c:452: error: 'apc_regex' has no member named 'preg'
/opt/APC-3.1.9/apc.c:452: error: 'apc_regex' has no member named 'preg'
/opt/APC-3.1.9/apc.c:453: error: 'apc_regex' has no member named 'nreg'
/opt/APC-3.1.9/apc.c:453: error: 'apc_regex' has no member named 'nreg'
make: *** [apc.lo] Error 1

$ make
.......
In file included from /opt/APC-3.1.9/apc.c:38:
/usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /opt/APC-3.1.9/apc.c:38:
/usr/include/php/ext/pcre/php_pcre.h:45: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/usr/include/php/ext/pcre/php_pcre.h:46: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/usr/include/php/ext/pcre/php_pcre.h:52: error: expected specifier-qualifier-list before 'pcre'
/opt/APC-3.1.9/apc.c:362: error: expected specifier-qualifier-list before 'pcre'
/opt/APC-3.1.9/apc.c: In function 'apc_regex_compile_array':
/opt/APC-3.1.9/apc.c:419: error: 'apc_regex' has no member named 'preg'
/opt/APC-3.1.9/apc.c:419: error: 'apc_regex' has no member named 'preg'
/opt/APC-3.1.9/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/opt/APC-3.1.9/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/opt/APC-3.1.9/apc.c: In function 'apc_regex_match_array':
/opt/APC-3.1.9/apc.c:452: error: 'apc_regex' has no member named 'preg'
/opt/APC-3.1.9/apc.c:452: error: 'apc_regex' has no member named 'preg'
/opt/APC-3.1.9/apc.c:453: error: 'apc_regex' has no member named 'nreg'
/opt/APC-3.1.9/apc.c:453: error: 'apc_regex' has no member named 'nreg'
make: *** [apc.lo] Error 1

I very hope that you don`t will get this error and your make will successful, but if not – don`t worry. Lets understand why it happen, As we can see – first error related with: ‘php_pcre.h:29:18: error: pcre.h: No such file or directory’. What it mean, that compiler not find ‘pcre.h’ file, right? This file located (should) in PHP development package (php-devel). So, to solve our problem – we will need to install that extra package ‘php-devel’ with ‘pcre’. To install it, execute next command:

我非常希望您不会遇到此错误,并且可以成功进行制作,但是如果没有,请不要担心。 让我们了解为什么会发生,正如我们所看到的–与以下内容有关的第一个错误:'php_pcre.h:29:18:错误:pcre.h:没有此类文件或目录'。 这是什么意思,那就是编译器找不到'pcre.h'文件,对吗? 该文件位于(应该)在PHP开发包(php-devel)中。 因此,要解决我们的问题–我们将需要使用“ pcre”安装额外的软件包“ php-devel”。 要安装它,执行下一个命令:


$ yum install pcre-devel

$ yum install pcre-devel

Then, lets repeat our ‘make’ command:

然后,让我们重复执行“ make”命令:


$ make

$ make

This time the command should successfully executed

这次命令应该成功执行

步骤7 –安装 (Step 7 – Installing)

Executing next command:

执行下一条命令:


$ make install

$ make install

Here we don`t should have problems like before

在这里我们不应该像以前那样遇到问题

步骤8 –重新启动 (Step 8 – Restarting)

Now we need just restart our server (to apply changes):

现在我们只需要重启服务器(以应用更改)即可:


$ /etc/init.d/httpd restart

$ /etc/init.d/httpd restart

That’s all my friend, we just finished installing APC caching system to our hosting. But how to confirm it? Easy – just execute phpinfo() command and search for ‘APC’ section. This can be like this:

这就是我所有的朋友,我们刚刚完成了将APC缓存系统安装到我们的主机上。 但是如何确认呢? 简单–只需执行phpinfo()命令并搜索“ APC”部分。 可以像这样:

APC

APC

翻译自: https://www.script-tutorials.com/how-to-install-apc-on-linux/

centos apc 安装

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值