Linux – Enable PHP Short Tags

KB ID 0000886 

Problem

I have a particular web page that uses PHP short tags. Post migration from my old hosting company to a dedicated VPS, this stopped working.

As I know little about Linux, and even less about PHP, I asked the question at Experts Exchange about why It was no longer working. I took no time at all, for someone who knew what they were doing to say, “Your code uses ‘Short tags’, but you do not have short tags enabled”

Solution

How To Enable PHP Short Tags From .htaccess

This would be your approach if you were on a hosted web server, and could not access the servers PHP configuration. In the ‘Root’ of your website should be a file called .htaccess you can simply edit this with any text editor (but make sure it does not save with a file extension!).

Add the following lines to the end;

[box]php_value short_open_tag 1
php_value asp_tags 1[/box]

How to Enable Short Tags in PHP

1. Connect to the server via SSH, (or open a terminal session). The file you need to edit is called php.ini. This server is running CentOS, so you should find that file in the /etc/ folder.

2. By default the line you are looking for is 229 (press CTRL+C to show position). Locate the short_open_tag = Off line.

3. Change the entry to ‘On’, and save the changes (CTRL+X and ‘Y’ to save).

4. Restart the web server.

[box]
service httpd restart[/box]

Related Articles, References, Credits, or External Links

NA

Apache Web Server – Change the Default Page

KB ID 0000882 

Problem

Out of the box, Apache expects your website homepage to be called index, on this site the homepage is called home, here’s how to change it.

Solution

1. Connect to the server via SSH, (or open a terminal session). The file you need to edit is called httpd.conf. This server is running CentOS, so you should find that file in the /etc/httpd/conf folder.

2. I’m going to edit it with nano.

3. Locate the DirectoryIndex section and remove index and any other unwanted filename (i.e. in this example index.var).

4. Add in the one you require and save and exit, (press CTRL+X and Y to save).

5. You nee to restart Apache for the change to take effect.

[box] apachectl -k restart[/box]

 

Related Articles, References, Credits, or External Links

NA