Monday, March 24, 2014

Post installation tasks on CentOS regarding Apache web server

This is a short troubleshooting guide for system administrators. Almost all tasks described in this post should be done as root. You need to be familiar with basic Linux commands / editors such as cat, vi, chmod and chown.

To enable mod_rewrite

a2enmod rewrite
service httpd restart

If mod_rewrite is enabled and your CMS or MVC framework still doesn't work do this on CentOS:
vi /etc/httpd/conf/httpd.conf

Change AllowOverride None to AllowOverride All inside the DocumentRoot Directory Directive and add DirectoryIndex index.php.
Here's how the portion of httpd.conf file should look like on CentOS after changes:


<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    DirectoryIndex index.php
    Order allow,deny
    Allow from all
</Directory>

This lets you put anything you want in .htaccess file in webroot or it's subfolders.
Don't forget to restart httpd service:

# service httpd restart
Stopping httpd:   [  OK  ]
Starting httpd:   [  OK  ]

Optionaly you may need to set anywhere in /etc/httpd/conf/httpd.conf
ServerName localhost

Just in case check /etc/hosts file. It should at least contain this:
cat /etc/hosts
127.0.0.1 localhost

File permisions for scripts and static files:
# cd /var/www/
# chmod -R 750 html
# chown -R user_name:apache html

File permissions for folder that is used for upload of binary files. This enables Apache to upload/delete the files:
# cd /var/www/html
# chmod -R 770 upload
# chown -R user_name:apache upload



Install Java JDK


Yellow highlighted is Java version. You should use latest one.

As root
#yum install java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel.x86_64
#export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64

as user
#vim $HOME/.bashrc

Add at bottom of file:
export JAVA_HOME="/usr/lib/jvm/jre-1.7.0-openjdk.x86_64"


Test Java and get version
# java -version
java version "1.7.0_xx"
OpenJDK Runtime Environment (rhel-2.4.4.1.el6_5-x86_64 u51-b02)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)


Install Aptana for Linux


unpack aptana zip archive to /tmp and then:
#mv /tmp/Aptana_Studio_3 /opt
#ln -s /opt/Aptana_Studio_3/AptanaStudio3 /usr/local/bin/aptanas3

fix file permissions
# cd /opt/Aptana_Studio_3
# ls -la
total 1528
drwxrwxr-x.  9 user_name user_name   4096 Apr  1 21:36 .
drwxr-xr-x.  4 root   root     4096 Apr  1 20:49 ..
drwxrwxr-x.  2 user_name user_name   4096 Aug  9  2013 about_files
-rw-rw-r--.  1 user_name user_name    577 Aug  9  2013 about.html
-rwxr-xr-x.  1 user_name user_name  71023 Aug  9  2013 AptanaStudio3
-rw-rw-r--.  1 user_name user_name    383 Aug  9  2013 AptanaStudio3.ini
-rw-rw-r--.  1 user_name user_name     53 Jul 12  2013 AptanaStudio3.sh
-rw-rw-r--.  1 user_name user_name  75964 Aug  9  2013 artifacts.xml
drwxrwxr-x.  9 user_name user_name   4096 Apr  1 21:36 configuration
drwxrwxr-x.  2 user_name user_name   4096 Aug  9  2013 dropins
-rw-rw-r--.  1 user_name user_name     59 Feb  8  2012 .eclipseproduct
-rw-rw-r--.  1 user_name user_name  16536 Feb  8  2012 epl-v10.html
drwxrwxr-x. 17 user_name user_name   4096 Aug  9  2013 features
-rw-rw-r--.  1 user_name user_name    321 Jul 12  2013 full_uninstall.txt
-rw-rw-r--.  1 user_name user_name 949436 Aug  9  2013 icon.xpm
-rwxr-xr-x.  1 user_name user_name 335360 Aug  9  2013 libcairo-swt.so
-rw-rw-r--.  1 user_name user_name   8951 Feb  8  2012 notice.html
drwxrwxr-x.  5 user_name user_name   4096 Apr  1 21:35 p2
drwxrwxr-x. 38 user_name user_name  32768 Aug  9  2013 plugins
drwxrwxr-x.  2 user_name user_name   4096 Aug  9  2013 readme
-rw-rw-r--.  1 user_name user_name     62 Aug  9  2013 version.txt
# chmod 775 configuration/org.eclipse.osgi/bundles -R

Run aptana from command line
#/opt/Aptana_Studio_3/AptanaStudio3

Then create launcher as on picture:




Test memcached extension

File permissions:
# ls -la | grep 'test_mem'
-rw-rw-r-- 1 user_name user_name 242 аpr 5 12:42 test_memcached1.php
-rw-rw-r-- 1 user_name user_name  98 аpr 5 03:36 test_memcached2.php

File:test_memcached1.php
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);

$m->set('my_array', array('testing memcached for 5 seconds', 'test starts now'), time() + 5);

var_dump($m->get('my_array'));
?>
<br> <a href="test_memcached2.php" >click me</a>

File:test_memcached2.php
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);

var_dump($m->get('my_array'));
?>



Test memcache extension

File permissions:
-rw-rw-r--   1 user_name user_name  580 Apr  5 03:10 test_memcache1.php
-rw-rw-r--   1 user_name user_name  138 Apr  5 03:09 test_memcache2.php

File: test_memcache1.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 = 'testing cache for 5 seconds';

$memcache->set('key', $tmp_object, false, 5) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 5 seconds)<br/>\n";

$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";

var_dump($get_result);
?>
<br> <a href="test_memcache2.php">click me</a>

File: test_memcache2.php
<?php
$memcache = new Memcache();
$memcache->connect('localhost', 11211) or die ("Could not connect");

var_dump($memcache->get('key'));
?>

No comments:

Post a Comment