Article

eZ publish: PHP's Killer App - Parts 1-3

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Next

Should we be virtuous?

As you saw at the start of this article when we looked at the online demo of eZ publish, there were two separate URLs: one for the main site and another for the back end admin interface:

http://publishdemo.ez.no/ and
http://admin.publishdemo.ez.no/

This is accomplished by some clever tricks with Apache's virtual host features, described in Chapter 2 of INSTALL.pdf. Trying to install eZ publish this way can be extremely complex -- if not impossible -- on a typical Web host, which is why we're taking the alternative option where no Apache configuration is required. Having said that, installation by the easier path will change slightly the way eZ publish behaves:

  • http://www.yourdomain.com/index.php is your main page
  • http://www.yourdomain.com/index_admin.php is your admin interface

Also, where eZ publish URLs usually look like:

  • http://www.yourdomain.com/article/articleview/3/

using the easier approach, the URLs will look like:

  • http://www.yourdomain.com/index.php/article/articleview/3/

That's the trade-off, but it's minor compared to the pain you'll experience if you take the Virtual Hosts route for your first eZ publish installation.

Image Magick

The other piece of software we need is Image Magick, a powerful set of command line image manipulation tools that come in very handy when our PHP scripts need a little extra "oomph" in the graphics arena. eZ publish uses Image Magick to control image sizes, to allow them to be rendered consistently.

The file we need to install Image Magick can be found at ftp://ftp.nluug.nl/pub/ImageMagick/binaries/ (or one of the mirrors). The file you're looking for will be called ImageMagick-5.4.9-xp.exe, or something similar. Once you've downloaded and run the executable, install Image Magick to the directory C:\Imagemagick\.

Ready for Action

You'll need to take the following steps to get eZ publish up and running.

  1. Copy the file htaccess-nVH from [eZ publish_root]\installation to [eZ publish_root]\, rename the current file named .htaccess to htaccess_old and rename htaccess-nVH to .htaccess (note that, depending on your version, Windows Explorer may complain about beginning a file with a full stop (or "period"). In that case, you'll need to rename the file using the DOS command line (see Kev's Command Prompt Cheat Sheet).

    Change the eZ publish root directory and use rename htaccess-nVH .btaccess to rename the file. This step ensures the eZ publish installation is secure, and that site visitors can only access index.php.

  2. Now head over to your MySQL database (I'm assuming you've got phpMyAdmin -- if you've got phpdev5 running, it's available at http://localhost/phpmyadmin) and create a database called "publish".
  3. You now need to import the MySQL database for eZ publish. In phpMyAdmin (version 2.3.0+) you need to click on the SQL tab when viewing the publish database, and use the file upload box "Location of the textfile:" to select the file. The file you need is [eZ publish_root]\sql\publish_mysql.sql, which builds the eZ publish database structure. We also want some sample data to play with, so load the file [eZ publish_root]\sql\data_mysql.sql, which will populate the database.
  4. Rename the file [eZ publish_root]\site.ini to [eZ publish_root]\site.ini.php and edit it with your favorite editor. The reason for doing this is -- again -- security (files with a .php extension, apart from index.php, will be unavailable to visitors).
  5. Now, in site.ini.php, you need to change the following settings to match your environment:

    [site]    
    SiteURL=localhost/public/ezpublish_2_2_6    
    AdminSiteURL=localhost/public/ezpublish_2_2_6    
    UserSiteURL=localhost/public/ezpublish_2_2_6    
    ...    
    SiteTitle=phpPoint    
    ...    
    SiteTmpDir=C:/Windows/temp    
    ...    
    # Database settings set DatabaseImplementation to    
    mysql|postgresql|informix.    
    DatabaseImplementation=mysql    
    Server=localhost    
    Database=publish    
    User=MySql_User    
    Password=MySql_User_Password    
    ...    
    ImageConversionProgram=C:\Imagemagick\convert.exe

    Save the file.

  6. Edit the file sitedir.ini in eZ publish root and set the following variable:
  7. $siteDir = "C:/phpdev5/www/public/ezpublish_2_2_6/";

  8. Next, you need to create the directories eZ publish uses to cache pages (getting a good feeling about eZ publish yet?). Download the file at make_cache.zip. This contains a batch file make_cache.bat that will create the directories for you. Extract this to your eZ publish root and with a DOS command line, from the eZ publish root directory type make_cache. All the cache directories should now be created, such as [eZ publish_root]\classes\cache. Make sure you delete make_cache.bat when you're finished.
  9. Finally, we need to make sure our php.ini settings are correct. Open the php.ini file (from your C:\Windows\ directory) and check the following settings:

    • short_open_tag = On eZ publish often uses the <? echo($variable); ?> syntax rather than <?php echo($variable); ?>, hopefully something they'll correct in version 3.x, to help with portability.
    • allow_call_time_pass_reference = On
    • Passing variables by reference is a "bad practice" used commonly in XML parsing scripts -- another item we hope they'll get time to fix in eZ publish 3.x
    • error_reporting = E_ALL & ~E_NOTICE
    • register_globals = On
    • Development of eZ publish 2.x began before the announcement that register globals would be switched off by default from PHP 4.2. As Kevin Yank warned us in Write Secure Scripts with PHP 4.2!, leaving register globals on is asking for trouble. Again, we hope this will be resolved in eZ publish version 3.x
    • magic_quotes_gpc = Off
    • Magic quotes are evil! magic_quotes_runtime = Off should also be set.

    Those are the important settings. Save your php.ini and restart Apache.

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links