[PHP] PHP code showing on the page instead of being executed

Environment :
Ubuntu Server 14.04
PHP 5.5.9

Problem :
PHP code showing on the page instead of being executed

Reason :
The reason that I met this problem is because the PHP file I used begin with (<?) instead of (<?php) which the short tag is deprecated by default.

Solution :
Find php.ini in /etc/php5/apache2, make sure the option short_open_tag=On, if not, change if to On.

Another solution more complete from stack overflow : http://stackoverflow.com/a/5121589/740546

[PHP] Configuration php.ini

As I said in my blog, it is just a place to remind me the technology that I used everyday, there will be nothing so profound but useful in daily work.

This blog will present a simple schema for the configuration of the php.ini. There are several php.ini after installed php, it is very easy to be confused.

Continue reading

[Apache] Install configuration perl and php for apache

To install the configuration of perl and php for apache in Ubuntu, it is sufficient to execute several commands.

For perl : sudo apt-get install apache2

For php : sudo apt-get install php5 libapache2-mod-php5

After doing these commands, if we check whether the modules are avaliable, we just need a short script :

check_mod(){
    mode=$1
    mods_enabled=/etc/apache2/mods-enabled
    mods_available=/etc/apache2/mods-available

    if [ -f "$mods_enabled/$mode" ] ; then
    echo "The module $mode is enabled"
    else  
    if [ -f "$mods_avalable/$mode" ] ; then
        echo "The module $mode is available"
        sudo ln -s $mods_available/$mode $mods_enabled/$mode
    else  
        echo "[KO]The module is not installed[KO]"
    fi
    fi
}

check_mod perl.load
check_mod php5.conf
check_mod php5.load

Ref.
https://help.ubuntu.com/10.04/serverguide/php5.html
http://www.blog.highub.com/perl/install-configure-apache-localhost-perl-on-linux-ubuntu/