Enabling mod rewrite and htaccess files on Apache

By default, Ubuntu’s Apache will ignore the directives in your .htaccess files.

To enable mod rewrite use a2enmod rewrite on ubuntu.

Now, If you do have access to the main configuration file, You probably should NOT use htacccess files. Having said that, its still always good to learn how to do so.

the enable the htaccess files usage, we need to go to the /etc/apache2/sites-available/default file, and change the AllowOverride directive from none to All.

You then have to restart your server (apache2ctl  restart) for the changes to take place.

Now you can use an htaccess file to check that you task is complete. I have written a simple htaccess file accompanied by two other files, index.html and index.php. The normal Apache behavior is to use the html first. So, you can put these files in a folder and see what you get when you enter the folder.

Then, you can change the file order in the htaccess file, which should change the file you are getting when you enter that directory.


Resolving drupal ftp error when installing modules

When installing a new drupal site under Linux, you may get this annoying error when trying to install a module:

So what? install an FTP server? NO.

This is clearly a permission error, however, setting folder permissions to 777 (or 666 😉 ) just won’t do it.

The thing is, the user log into Apache needs to be the owner of this folder.

So, to remedy this, use:
chown -R  www-data /var/www/dp7/sites/default

assuming you installed under /var/www/ which is the default in ubuntu.

Configuring php.ini for upload

Well – sometimes you need to upload files bigger then the default 2M.

In php, you have to tweak the php.ini to get this done. The first parameter is upload_max_filesize. This one is usually 2M, and set the lower limit (at this point). However, changing this will not give you the option for, let say 100M. for that to happen, you’ll need yet another parameter. You see, the upload size is one thing, which is part of another thing – the maximum post size, or in php.ini lingo – post_max_size. This one default to 8M, so if you change the first to anything bigger then 8M, you will still have a limit of 8M.

You should probably set the post maximum to a higher value then the upload limit, php does this for a reason, which is that files can be a part from a bigger form with additional data/ files.

Yet another point to remember: you might want to check the memory limit option, in case your site is under a lot of memory intensive actions.

Changing time zone in php.ini

In order to get rid of the pesky warning in php about time zone, you can so one of two things: add call to the date_default_timezone_set on every file header, or, define it in your php.ini  like this: date.timezone = US/Central, where the actual values relates to the server time zone.

Looking for you own time zone? not a problem. here are the php time zones.

And you can still use the date_default_timezone_set if you need to stray from the default timezone.