当前位置:首页 > 美丽人生 > 学习成长 > 正文内容

Centos Install MemCached, Apcu and OpCache

RonWang3年前 (2021-11-15)学习成长711

This section provides instructions to install memcached on CentOS and Ubuntu. For additional information, consult the memcached

To install memcached on CentOS, perform the following tasks as a user with root privileges: 

modren-architecture

Install memcached and its dependencies:

yum -y update
yum install -y libevent libevent-devel
yum install -y memcached
yum install -y php-pecl-memcache

Change the memcached configuration setting for CACHESIZE and OPTIONS:

Open /etc/sysconfig/memcached in a text editor.

Locate the value for CACHESIZE and change it to at least 1GB

For example

CACHESIZE="1GB"
Service memcached restart

Restart your web server.

systemctl restart nginx

Install Apcu

These section we will install APCu (Alternative PHP Cache) on CentOS 7. APCu provided both opcode caching (opcache) and object caching APCu is the replacement for the outdated APC extension. It's very easy to install. Just follow these steps:

1. Install APCu . Before installing APCu, if your server doesn't have Remi Repository, install that first using this command:

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Now run this command to install APCu:

sudo yum install php-pecl-apcu

2. Dependency Packages for APCu , By entering this command, you can install dependency packages for APCu:

sudo yum install php-pear php-devel httpd-devel pcre-devel gcc make

3. Restart Web Server

sudo systemctl restart nginx php-fpm

Now check your phpinfo(); script to see APCu is installed or not:

apcu

4. APCu Admin Page

This is an optional step. I’m sharing a PHP file. You need to keep this file to your domain’s public html folder to see APCu admin page. Download this file from GitHub: Now open the file from browser (http://example.com/apcu.php):

apuc-admin-page.png

The default username and password is: admin, admin. You can change this from the apcu.php file:

#0 or 1. 0 for disable user and pass 

defaults('USE_AUTHENTICATION',0); 

defaults('ADMIN_USERNAME','admin'); 

defaults('ADMIN_PASSWORD','admin');

5. Config APCu

We can easily configure APCu. Open /etc/php.ini file and add value like this:

#Enable/Disable 

apc.enabled=1 

# Memory Segments 

apc.shm_size=512M 

## PHP file cache 1 hour## 

apc.ttl=3600 

## User cache 2 hour ## 

apc.user_ttl=7200 

## Garbage collection 1 hour ##  

apc.gc_ttl=3600

6. Store and Fetch Data

Create a file named cache.php and paste this code:

Now visit the cache.php to see the output.

Install OpCache

sudo yum install php-opcache -y

Now we can set our own config like:

nano /etc/php.d/10-opcache.ini
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1

版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://parentscn.com/?id=147

标签: 服务器

相关文章

阿里云服务器的环境搭建与调试

阿里云服务器的环境搭建与调试

从阿里云产品发布开始便一直在使用ECM云服务器,但是之前多使用的是Windows系统,后来摸索开始挑战自己使用CentOS系统,靠着几行程序和网上各位大咖的教程和分享,竟然让使用CentOS服务器近1...

CentOS 7.9 64位 搭建 LNMP环境

CentOS 7.9 64位 搭建 LNMP环境

运维网站及APP程序等,我们经常要使用云服务器,无论是阿里云,腾讯云,还是国外的亚马逊云,购置纯系统的服务器之后,需要自己安装和搭建环境LAMP。今天,我就带大家一起实战下CentOS 7.9 64b...

Centos 安装 MariaDB Ver 10.8.6

Centos 安装 MariaDB Ver 10.8.6

Install MariaDB 10.8 on CentOS 8 These are the ideal steps you’ll go through when installing MariaDB...

Centos服务器PHP7.X版本的安装与更新

Centos服务器PHP7.X版本的安装与更新

运行服务器WEB时,有些系统对PHP的版本要求比较新,所有本文将特别介绍如何升级和安装新版本的PHP系统。Centos服务器的Nginx,MySQL(MariaDB)的部分参照《CentOS 7.9...

Centos Install OSCommerce 4.0

Centos Install OSCommerce 4.0

osCommerce is a Free shopping cart and open source Ecommerce software. You can choose to host you...

 PrestaShop的1.7版本安装

PrestaShop的1.7版本安装

现在很多国内的公司为了拓展对外业务,开始采用更先进的电子商务软件,如美国的Amazon,加拿大的Shopify,法国的PrestaShop等都有很多用户在使用,对于商业初期的低成本尝试,开源软件Pre...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。