Archive for April, 2007

Developing a CMS solution on Mediatemple with the Seagull PHP Framework, including Google Maps

Friday, April 20th, 2007

Having just completed the Atalink site, I would like to highlight some of my experiences, frustrations and lessons which I have learnt over the past few months.

Background

I developed the site using the Seagull php framework, using the publisher module (which has recently been superseded by the CMS module).

The publisher module requires a bit of hacking to make it run effectively, especially if the site requires content pages which have different layouts. But, overall the site works well and looks pretty good, even if I say so myself ;).

I have still had a number of difficulties, so for those of you who are planning on building a similar site, here are some of the things which I have learnt:

This is especially relevant if you are going to be using some of the following:

Lessons learned

Tips for using the Seagull publisher module:

If you have various site sections which need to have different layouts, the best way of handling this is to create different content types for each different layout which is required.

Then create a different publisher template for that content type and specify the styling which you want for that particular section.

If you have any exceptions, then use a handler like this:

{if:isEqual(29,articleID)}

{end:}
{if:isEqual(30,articleID)}

{end:}
{if:isEqual(34,articleID)}

{end:}

I will endeavour to write a more in depth tutorial for this and put it on the Seagull wiki. Once I have done so, I will update this post.

Server Issues

The first issue which I encountered was trying to do an installation on a staging sub-domain on a Media Temple Dedicated Virtual Server, where php safe mode was turned on. I have written a post which is a guide on how to successfully remove these restrictions.

Browser Issues

As always, I encountered problems with cross browser compatibility. I discovered huge differences between IE6, IE7 and Firefox. The site looks best in Firefox, Safari and in IE6, but there are a few small differences on IE7.

I used this basic conditional block to include an IE hacks file for when a user views the site using IE.

< !--[if IE] >< style type="text/css" >@import “http://www.atalink.com/ themes/atalink/css/hacks/ie.css”;< /style >< ![endif]-- > (Remove spaces)

Google Maps

Although this is not that difficult to implement, I found quite a useful site called:

Google Maps latitude, longitude Popup , which gives you the latitudes and longitude values for a specific location, which you use in the Google supplied javascript

Design

Although a designer may do a really good job and a client signs off a design, one has to be flexible enough to deal with client requests for changing of the layouts. Often the changes requested are quite valid and one should consider each request before just disagreeing.

Content

Again, I have been reminded about how important it is to have content ready and signed off, before beginning with development. It is amazing how much time can be wasted when you are waiting for pieces of content. Details about content should be agreed upon during initial agreements and no matter how difficult it may be, these agreements should be adhered to.

Conclusion

I have enjoyed working on this site and I have learnt a lot, in terms of development and in terms of communicating with clients.

How to turn off PHP safe mode and remove open_basedir restrictions to install the Seagull PHP framework on a Media Temple sub domain

Tuesday, April 3rd, 2007

Problem

I wanted to run an installation script on a sub-domain of a Dedicated-Virtual server hosted by Media Temple with a Plesk 7.5.4, but received the following php error message when I ran the script:

Warning: file_exists(): open_basedir restriction in effect.

Reason why the error occurs

The reason for this error is because, php safe mode is turned on and because the open_basedir is set for each sub-domain. After quite a lot of searching on the web, I eventually tried a few tutorials, but none of them were comprehensive enough to describe exactly how to solve the actual problem.

Solution

Follow these steps and you should solve the problem:

  1. SSH into your server using the root login information
  2. Once you have logged in, edit the php.ini file located /etc/ folder with a text editor. The line you are looking for is:
    a. Change this line safe_mode = on to safe_mode = off
    b. Or you can cut and paste this one-liner:
    perl -p -i -e ’s/^safe_mode\s*=\s*on/safe_mode = off/i;’ /etc/php.ini
  3. Make sure that the open_basedir in the php.ini file looks like this:

    ; open_basedir, if set, limits all file operations to the defined
    directory
    ; and below. This directive makes most sense if used in a per-
    directory
    ; or per-virtualhost web server configuration file. This directive is
    ; *NOT* affected by whether Safe Mode is turned On or Off.
    open_basedir = none

  4. Then you need to edit the virtual hosts for the domain and for each sub-domain in the http.inc file, which is located in the /var/www/vhosts/$domain/conf folder.
    Add the following section of code to the domain Virtual Host, as well as to each sub-domain Virtual Host


    < IfModule sapi_apache2.c >
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    < /IfModule >

    < IfModule mod_php5.c >
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    < /IfModule >

  5. To complete the process, one needs to type the following two commands:
  6. a. /etc/init.d/httpd stop
    b. /etc/init.d/httpd start

    Hit “Enter� after each command and you should be given an [ OK ] status in the command line.

    Conclusion

    This should solve your problem and if you have any comments, suggestions or improvements, please submit them.