PHP – Use of undefined constant MCRYPT_BLOWFISH – assumed ‘MCRYPT_BLOWFISH

While your coding session, you encounter this error :

Use of undefined constant MCRYPT_BLOWFISH - assumed 'MCRYPT_BLOWFISH

You think, easy, a module should be missing on my php
So you install it :

sudo apt-get install php5-mcrypt

And restart apache.

But it still doesn’t work. In phpinfo() it seems the module is not installed.

In fact with the new version of PHP, you still need to activate the module

php5enmod -s apache2 mcrypt

The restart apache and the module should work.

apache AH01630: client denied by server configuration – error 403 forbidden

You are seting up a new website and you get an 403 forbidden error and this on apache error log :

AH01630: client denied by server configuration

You don’t understand because you already setup hundred of websites, you check chmod but you still get this error.

Don’t panic, since apache 2.4 you have to change the directory configuration:

<Directory />
  Options Indexed FollowSymLinks
  AllowOverride All
  Require all granted
</Directory>

and restart apache, that should do the trick.

Invalid command ‘Header’, perhaps misspelled or defined by a module not included in the server configuration

You have this error message on your apache logs

/home/www/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration

Check the .htaccess file and there is no Header command…

<FilesMatch "\.(xml|jpg)$">
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</FilesMatch>

In fact, this issue is due to the header apache’s module whose’s missing.
To install it, run

a2enmod headers

And don’t forget to restart apache

service apache2 restart

proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

You are using apache with proxy module, but when you try to get your page, you get a error 500 ?
Check your apache error log, if you get this :

proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

You need to enable proxy module :

a2enmod proxy_http
a2enmod proxy

And restart you apache server.

You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.

After installing Symfony 2 instead of viewing your website, you see this error message :

You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.

It probably means you need to install the sqlite extension for php

apt-get install php5-sqlite

restart apache and that should to the tricks.

Remove index.php from URL .htaccess

How to remove index.php from URL using .htaccess file ?
That is this easy :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.+) $1 [R=301,L]
</IfModule>

Maybe you are using a magento website and you need to keep index.php for the backoffice.
Then add this condition to the .htaccess file

RewriteCond %{REQUEST_URI} !^[^/]*/index\.php/admin.*

and don’t forget to enable rewrite module

a2enmod rewrite

Redirect domain, add www

If you want to redirect your website’s visitors to your www domain name, add this in your apache virtualhost configuration

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^/(.*)$ http://www.domain.com/$1 [R=301,L]

and don’t forget to enable rewrite module

a2enmod rewrite

Redirect http to https

How to automatically redirect all your http request to your https website ?
Simply add this 3 lines in your http VirtualHost configuration

RewriteEngine on
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI}  [L]

Don’t forget to activate your rewrite module

a2enmod rewrite