Kurinchi Blogger Scribbles …


Archive for the ‘Apache’ Category

Aug 07
2009

How to find the version of Apache?

Last updated: August 1st, 2009

In ubuntu, it is

$ apache2 -v

In CentOS, it is

$ httpd -v

To find out where apache2 or httpd program is installed you can do the
$ whereis apache2 or,
$ locate httpd

Aug 05
2009

Ubuntu Hardy Heron, CakePHP Setting in Virtual Host Environment

Last updated: July 30th, 2009

If you are to setup CakePHP in a virtual hosting environment, we need to ensure that the DocumentRoot is setup correctly. Based on the experience I have had I thought to list down the virtual host setting and cakephp .htaccess setting files.

root@myserver:/etc/apache2/conf.d# cat vhosts.conf
NameVirtualHost 192.168.1.100:80

<VirtualHost 192.168.1.100:80>
ServerName cakeapp
DocumentRoot /var/www/cakeapp
</VirtualHost>

(Note that there is no ending forward slash after /var/www/cakeapp. If there had been one, it might cause a problem if the /var/www/cakeapp/app/config/routes.php is not configured correctly indicating a never ending loop in resolving domain name)

root@myserver:/etc/apache2/conf.d# cat /var/www/cakeapp/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

Aug 04
2009

Ubuntu, Apache: Virtual Hosting

Last updated: August 4th, 2009

Virtual Hosting in Ubuntu Hardy Heron: Case Example

Consider the case of two domain names mysite1 and site2 to be served on IP Address 192.168.1.100 (port 80)

Before proceeding let us look at how resolv.conf and hosts file are set up …

$ cat /etc/resolv.conf
search kurinchilion.com
nameserver 192.168.1.100

$ cat /etc/hosts
127.0.0.1 localhost
192.168.1.100 myserver.kurinchilion.com myserver

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

(more…)

Aug 03
2009

Apache, Ubuntu, CentOS: Virtual Host Configuration

Last updated: July 30th, 2009

What is Virtual Hosting?

Virtual Hosting is a technique by which web servers can serve more than one domain name on the same server. It can also be a variation of serving different sites on the same IP but on different ports.
(more…)

Jul 09
2009

PHP Image Upload and Security

Last updated: July 9th, 2009

List of steps to take care when using PHP to upload images or documents

i) use is_uploaded() function to check if the file is uploaded before moving the file from temporary location

ii) sanitize the name of the file before moving the file from the temporary location by executing the ‘mv’ system command (use escapeshellargs, escapeshellcmd as needed)

iii) chmod the file setting to 644 if needed

iv) the directory from where the file will be moved and the destination directory should be initialized beforehand in order to prevent users from altering the path where the files could be stored

Jun 22
2009

Linux: How to set the default shell?

Last updated: June 24th, 2009

How to set the default shell?

If you want to set a shell as a the default for all users you can set the SHELL variable

$ sudo vi ~/.bashrc

export SHELL=/bin/bash

To change the default shell for a specific user you can either use the following command
$ usermod -s /path/to/shell user_a

or, set the shell in the /etc/passwd file by changing the last column which represents the default shell for that user

user_a:x:1001:1001::/home/user_a:/bin/sh

Read more about the Linux shell

Jun 04
2009

CakePHP: Beginners installation hurdles – Errors and Solutions

Last updated: June 4th, 2009

I thought to mention a few errors beginners into CakePHP might come across when configuring CakePHP and how to resolve

Notice: this error is being rendered by the app/views/errors/missing_table.thtml view file, a user-customizable error page.

This error occurs when the database is not configured in cakePhp. First create a database in MySQL or the database of your choice. Go to /app/config/ and make a copy of database.php.default and rename it to database.php. Open database.php and give the necessary settings of the new database created with the associated login credentials. Once that is done, refresh the page and see if that error is now resolved.
(more…)

Jun 03
2009

.htaccess purpose considerations

Last updated: June 3rd, 2009

.htaccess – Purpose, Considerations
.htaccess is a hidden file in the web server which comes in handy when the sites are hosted in shared environment.

Considerations:

Slight hit to performance takes place when .htaccess directive is set as Apache checks each directory for its existence before any file access in that directory

Next consideration will be with regards how the site owners manage the setting changes and its security which can be misused.
(more…)

Jun 02
2009

CakePHP: To Check if Mod_rewrite is Disabled

Last updated: June 4th, 2009

How to check if mod_rewrite is disabled in Apache when CakePHP is installed?
Initially when CakePHP is downloaded from sourceforge and is installed in your localhost, you can test if it is working or not by going to the respective directory in your local host http://localhost/cake.

If CSS styling is missing in the display page, then check apache server’s httpd.conf file to see if mod_rewrite module is enabled. Remove the comment symbol to enable mod_rewrite in your localhost and restart Apache server for the change to take effect
(more…)

May 20
2009

PHP Register Globals and Security Vulnerability

Last updated: May 21st, 2009

Register Globals directive is turned OFF from PHP version 4.2.

PHP Global Variables
Environment variables, GET, POST, Server, Cookie variables are knows as Global Variables.

When register_globals directive is turned ON (like what most ISP’s did), you can access/set the global variables like $username, $password instead of $_POST["username"], $_POST["password"].
(more…)


Valid HTML 4.01 Strict  Valid HTML 4.01 Strict