Personal Project

Sunday, February 7, 2016

Install Apache, PHP, and Memcached on CentOS

Install Apache 

# yum install update 

Setup Apache


# vim /etc/httpd/conf/httpd.conf

<Directory "/var/www/html">
   AllowOverride all
#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>

Install PHP


# yum install php

# yum install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
curl-d

Check PHP

# vim /var/www/html/info.php
<?php
phpinfo();
?>

// Test Link
http://Server`s IP/info.php

Install Memcached

#yum install memcached

Start Memcached


# chkconfig --level 235 memcached on
# /etc/init.d/memcaached start
# /etc/init.d/memcached sratus

Install Memcached Perl Library

Install perl library for Memcached.
# yum install perl-Cache-Memcached

Install Memcached Python Library

Install python library for Memcached.
# yum install python-memcached

Restart Apache

Restart the Apache service to reflect changes.
# /etc/init.d/httpd restart
OR
# service httpd restart

Check Memcache


# vim /var/www/html/memtest.php

<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";
$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";
var_dump($get_result);
?>

// Test Link
http://Server`s IP/memtest.php


Restrat Apache

# /etc/init.d/httpd restart


No comments:

Post a Comment