SlideShare uma empresa Scribd logo
1 de 8
Installing Memcache and Memcached on linux servers
SSH to server as root.
Install the required packages.
root@jijo [~]# cd /usr/src
root@jijo [/usr/src]# yum install libevent libevent-devel -y
Now we need to download the latest memcached source
root@jijo [/usr/src]# wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
root@jijo [/usr/src]# tar xvf memcached-*
root@jijo [/usr/src]# cd memcached-*
root@jijo [/usr/src/memcached-1.4.15]# ./configure
root@jijo [/usr/src/memcached-1.4.15]# make
root@jijo [/usr/src/memcached-1.4.15]# make install
Now we need to create a memcached configuration file
root@jijo [/usr/src/memcached-1.4.15]# touch /etc/memcached.conf
root@jijo [/usr/src/memcached-1.4.15]# vi /etc/memcached.conf
add the following lines to it
----------------------------
#Memory a user
-m 16
# default port
-p 11211
# user to run daemon nobody/apache/www-data
-u nobody
# only listen locally
-l 127.0.0.1
now we need to create a startup script for memcached
root@jijo [/usr/src/memcached-1.4.15]# touch /etc/init.d/memcached
root@jijo [/usr/src/memcached-1.4.15]# vi /etc/init.d/memcached
add the following lines to it
-----------------------------
#!/bin/bash
# config: /etc/memcached.conf
# Source function library.
. /etc/rc.d/init.d/functions
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/memcached
DAEMONBOOTSTRAP=/usr/local/bin/start-memcached
DAEMONCONF=/etc/memcached.conf
NAME=memcached
DESC=memcached
PIDFILE=/var/run/$NAME.pid
[ -x $DAEMON ] || exit 0
[ -x $DAEMONBOOTSTRAP ] || exit 0
RETVAL=0
start() {
echo -n $"Starting $DESC: "
daemon $DAEMONBOOTSTRAP $DAEMONCONF
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $PIDFILE
echo
return $RETVAL
}
stop() {
echo -n $"Shutting down $DESC: "
killproc $NAME
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $PIDFILE
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
-----------------------------
root@jijo [/usr/src/memcached-1.4.15]# chmod +x /etc/init.d/memcached
root@jijo [/usr/src/memcached-1.4.15]# touch /usr/local/bin/start-memcached
root@jijo [/usr/src/memcached-1.4.15]# vi /usr/local/bin/start-memcached
add the following lines to it
-----------------------------
#!/usr/bin/perl -w
# start-memcached
use strict;
if ($> != 0 and $< != 0) {
print STDERR "Only root wants to run start-memcached.n";
exit;
}
my $etcfile = shift || "/etc/memcached.conf";
my $params = [];
my $etchandle;
# This script assumes that memcached is located at /usr/bin/memcached, and
# that the pidfile is writable at /var/run/memcached.pid
my $memcached = "/usr/local/bin/memcached";
my $pidfile = "/var/run/memcached.pid";
my $fd_reopened = "/dev/null";
sub handle_logfile {
my ($logfile) = @_;
$fd_reopened = $logfile;
}
sub reopen_logfile {
my ($logfile) = @_;
open *STDERR, ">>$logfile";
open *STDOUT, ">>$logfile";
open *STDIN, ">>/dev/null";
$fd_reopened = $logfile;
}
# This is set up in place here to support other non -[a-z] directives
my $conf_directives = {
"logfile" => &handle_logfile
};
if (open $etchandle, $etcfile) {
foreach my $line (<$etchandle>) {
$line =~ s/#.*//go;
$line = join ' ', split ' ', $line;
next unless $line;
next if $line =~ /^-[dh]/o;
if ($line =~ /^[^-]/o) {
my ($directive, $arg) = $line =~ /^(.*?)s+(.*)/;
$conf_directives->{$directive}->($arg);
next;
}
push @$params, $line;
}
}
unshift @$params, "-u root" unless (grep $_ eq '-u', @$params);
$params = join " ", @$params;
if (-e $pidfile) {
open PIDHANDLE, "$pidfile";
my $localpid = <PIDHANDLE>;
close PIDHANDLE;
chomp $localpid;
if (-d "/proc/$localpid") {
print STDERR "memcached is already running.n";
exit;
} else {
`rm -f $localpid`;
}
}
my $pid = fork();
if ($pid == 0) {
reopen_logfile($fd_reopened);
exec "$memcached $params";
exit(0);
} elsif (open PIDHANDLE,">$pidfile") {
print PIDHANDLE $pid;
close PIDHANDLE;
} else {
print STDERR "Can't write pidfile to $pidfile.n";
}
-----------------------------
root@jijo [/usr/src/memcached-1.4.15]# chmod +x /usr/local/bin/start-memcached
start memcached
root@jijo [/usr/src/memcached-1.4.15]# /etc/init.d/memcached start
Starting memcached: [ OK ]
install memcache on server now
root@jijo [/usr/src]# wget http://pecl.php.net/get/memcache-2.2.7.tgz
root@jijo [/usr/src]# tar xvf memcache-*
root@jijo [/usr/src]# cd memcache-*
root@jijo [/usr/src/memcache-2.2.7]# phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
root@jijo [/usr/src/memcache-2.2.7]# ./configure
root@jijo [/usr/src/memcache-2.2.7]# make
root@jijo [/usr/src/memcache-2.2.7]# make install
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
add extension in php.ini
root@jijo [/usr/src/memcache-2.2.7]# php -i |grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini
root@jijo [/usr/src/memcache-2.2.7]# vi /usr/local/lib/php.ini
add 'extension=memcache.so' under Dynamic Extensions and restart apache
root@jijo [/usr/src/memcache-2.2.7]# /etc/init.d/httpd restart
create a phpinfo page to check memcache support.
Install memcache  and memcached on linux servers

Mais conteúdo relacionado

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Destaque

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destaque (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Install memcache and memcached on linux servers

  • 1. Installing Memcache and Memcached on linux servers SSH to server as root. Install the required packages. root@jijo [~]# cd /usr/src root@jijo [/usr/src]# yum install libevent libevent-devel -y Now we need to download the latest memcached source root@jijo [/usr/src]# wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz root@jijo [/usr/src]# tar xvf memcached-* root@jijo [/usr/src]# cd memcached-* root@jijo [/usr/src/memcached-1.4.15]# ./configure root@jijo [/usr/src/memcached-1.4.15]# make root@jijo [/usr/src/memcached-1.4.15]# make install Now we need to create a memcached configuration file root@jijo [/usr/src/memcached-1.4.15]# touch /etc/memcached.conf root@jijo [/usr/src/memcached-1.4.15]# vi /etc/memcached.conf add the following lines to it ---------------------------- #Memory a user -m 16 # default port -p 11211 # user to run daemon nobody/apache/www-data -u nobody # only listen locally -l 127.0.0.1 now we need to create a startup script for memcached
  • 2. root@jijo [/usr/src/memcached-1.4.15]# touch /etc/init.d/memcached root@jijo [/usr/src/memcached-1.4.15]# vi /etc/init.d/memcached add the following lines to it ----------------------------- #!/bin/bash # config: /etc/memcached.conf # Source function library. . /etc/rc.d/init.d/functions PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/bin/memcached DAEMONBOOTSTRAP=/usr/local/bin/start-memcached DAEMONCONF=/etc/memcached.conf NAME=memcached DESC=memcached PIDFILE=/var/run/$NAME.pid [ -x $DAEMON ] || exit 0 [ -x $DAEMONBOOTSTRAP ] || exit 0 RETVAL=0 start() { echo -n $"Starting $DESC: " daemon $DAEMONBOOTSTRAP $DAEMONCONF RETVAL=$? [ $RETVAL -eq 0 ] && touch $PIDFILE echo return $RETVAL
  • 3. } stop() { echo -n $"Shutting down $DESC: " killproc $NAME RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $PIDFILE return $RETVAL } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart|reload) stop start RETVAL=$? ;; status) status $prog RETVAL=$? ;;
  • 4. *) echo $"Usage: $0 {start|stop|restart|status}" exit 1 esac exit $RETVAL ----------------------------- root@jijo [/usr/src/memcached-1.4.15]# chmod +x /etc/init.d/memcached root@jijo [/usr/src/memcached-1.4.15]# touch /usr/local/bin/start-memcached root@jijo [/usr/src/memcached-1.4.15]# vi /usr/local/bin/start-memcached add the following lines to it ----------------------------- #!/usr/bin/perl -w # start-memcached use strict; if ($> != 0 and $< != 0) { print STDERR "Only root wants to run start-memcached.n"; exit; } my $etcfile = shift || "/etc/memcached.conf"; my $params = []; my $etchandle; # This script assumes that memcached is located at /usr/bin/memcached, and # that the pidfile is writable at /var/run/memcached.pid my $memcached = "/usr/local/bin/memcached"; my $pidfile = "/var/run/memcached.pid"; my $fd_reopened = "/dev/null"; sub handle_logfile { my ($logfile) = @_;
  • 5. $fd_reopened = $logfile; } sub reopen_logfile { my ($logfile) = @_; open *STDERR, ">>$logfile"; open *STDOUT, ">>$logfile"; open *STDIN, ">>/dev/null"; $fd_reopened = $logfile; } # This is set up in place here to support other non -[a-z] directives my $conf_directives = { "logfile" => &handle_logfile }; if (open $etchandle, $etcfile) { foreach my $line (<$etchandle>) { $line =~ s/#.*//go; $line = join ' ', split ' ', $line; next unless $line; next if $line =~ /^-[dh]/o; if ($line =~ /^[^-]/o) { my ($directive, $arg) = $line =~ /^(.*?)s+(.*)/; $conf_directives->{$directive}->($arg); next; } push @$params, $line; }
  • 6. } unshift @$params, "-u root" unless (grep $_ eq '-u', @$params); $params = join " ", @$params; if (-e $pidfile) { open PIDHANDLE, "$pidfile"; my $localpid = <PIDHANDLE>; close PIDHANDLE; chomp $localpid; if (-d "/proc/$localpid") { print STDERR "memcached is already running.n"; exit; } else { `rm -f $localpid`; } } my $pid = fork(); if ($pid == 0) { reopen_logfile($fd_reopened); exec "$memcached $params"; exit(0); } elsif (open PIDHANDLE,">$pidfile") { print PIDHANDLE $pid; close PIDHANDLE; } else { print STDERR "Can't write pidfile to $pidfile.n"; }
  • 7. ----------------------------- root@jijo [/usr/src/memcached-1.4.15]# chmod +x /usr/local/bin/start-memcached start memcached root@jijo [/usr/src/memcached-1.4.15]# /etc/init.d/memcached start Starting memcached: [ OK ] install memcache on server now root@jijo [/usr/src]# wget http://pecl.php.net/get/memcache-2.2.7.tgz root@jijo [/usr/src]# tar xvf memcache-* root@jijo [/usr/src]# cd memcache-* root@jijo [/usr/src/memcache-2.2.7]# phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 root@jijo [/usr/src/memcache-2.2.7]# ./configure root@jijo [/usr/src/memcache-2.2.7]# make root@jijo [/usr/src/memcache-2.2.7]# make install Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/ add extension in php.ini root@jijo [/usr/src/memcache-2.2.7]# php -i |grep php.ini Configuration File (php.ini) Path => /usr/local/lib Loaded Configuration File => /usr/local/lib/php.ini root@jijo [/usr/src/memcache-2.2.7]# vi /usr/local/lib/php.ini add 'extension=memcache.so' under Dynamic Extensions and restart apache root@jijo [/usr/src/memcache-2.2.7]# /etc/init.d/httpd restart create a phpinfo page to check memcache support.