Before doing anything else, you need to get the development environment in place. If you already have Apache and PHP installed, feel free to skip ahead to Configuring Apache.
Start by installing PHP, including the free mod_php module, which extends the Apache Web server so it can execute PHP scripts efficiently. The following steps assume you are installing on Windows, but the process is essentially the same for other platforms:
- Download the zip file distribution (see Prerequisites). This tutorial was tested with php-5.1.2-Win32.zip.
- Extract the zip file into your destination directory, such as C:\php5. (Feel free to choose another directory, but just make sure it doesn't have spaces in it and modify the following directions accordingly.)
- Make a copy of C:\php5\php.ini-dist and rename it C:\php5\php.ini.
- Edit C:\php5\php.ini. Search for doc_root and change it to "C:\public_html". (Again, you may substitute accordingly.) Don't forget the quotes.
- Create a directory for your HTML files called C:\public_html, where you will put the files you want to publish on the Web.
Next, install the Web server.
Apache will act as a Web server for the PHP files and as a proxy for the OpenLaszlo applications. Download the Apache installer and run it (see Prerequisites).
In the Apache HTTP Server V2.0 Installation Wizard screen, set the following values:
Listing 1. Setting the values for Apache HTTP Server V2.0
Network Domain: localhost Server Name: localhost Administrator's Email Address: admin@localhost Install Apache HTTP Server 2.0 programs and shortcuts: for All Users, on Port 80, as a Service - Recommended.
Don't configure Apache to use port 8080 because that's the one OpenLaszlo is going to use. If you're running IIS or another Web server on port 80, you'll have to disable it or configure PHP to run with that Web server, instead of Apache.
Select the setup type "Typical" and install Apache HTTP Server V2.0 to the folder: C:\. Note that the installer always makes a subdirectory called Apache2, so if the installation directory is C:\, Apache will be installed in C:\Apache2. You can install it anywhere you like, but it's a good idea never to install PHP or Apache under a directory with spaces in its name (avoid C:\Program Files, for example).
Before installing OpenLaszlo, you need to make a few changes to the Apache configuration to enable it to run PHP more efficiently, as well as to act as a proxy so users who can't access the OpenLaszlo application on port 8080 can access it through Apache on port 80:
- Make a backup copy and edit the file C:\Apache2\conf\httpd.conf.
- Search for
DocumentRootand change it to the name of your HTML directory, C:\public_html.
- Search for
LoadModuleand uncomment the following lines (by deleting the leading pound sign) to enable the following modules:
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule rewrite_module modules/mod_rewrite.so
- Configure the rewrite rules by adding the following lines to the end of the httpd.conf file:
RewriteEngine on RewriteRule ^/lzxnet(.*)$ http://localhost:8080/lps-3.1.1$1 [p] RewriteRule ^/lps-3\.1\.1(.*)$ http://localhost:8080/lps-3.1.1$1 [p]
RewriteEnginecommand enables the rewrite rules. The first
RewriteRulecommand proxies all requests for localhost://lzxnet/* to localhost:8080//lps-3.1.1/*. The second
RewriteRulecommand proxies all requests for localhost://lps-3.1.1/* to localhost:8080//lps-3.1.1/*. These two rewrite rules are required to support OpenLaszlo development with Tomcat on port 8080, and they should be updated to reflect the version of LPS you have installed and the socket Tomcat is listening on.
- To load and configure mod_php, add the following lines to the end of the httpd.conf file:
LoadModule php5_module "C:/php5/php5apache2.dll"
AddType application/x-httpd-php .php PHPIniDir "C:/php5"
LoadModulecommand loads mod_php. The
AddTypecommand configures files ending with ".php" to be handled by mod_php. The
PHPIniDircommand tells mod_php where to find its configuration file. Save the file.
- Restart Apache. Look for the Apache Service Monitor icon on the right side of the taskbar (it looks like a red feather). If it's not there, you can start it with the Start menu > All Programs > Apache HTTP Server > Configure Apache Server > Monitor Apache Servers. Open the Apache Monitor window and click Restart to restart Apache with the new configuration.
Now let's test the PHP integration.
To test the actual Apache configuration, open your browser to http://localhost. Depending on how you have security configured and what files are present, you will see the Test Page for Apache Installation or a Forbidden 403 error. Don't panic because it means the server is running.
To test PHP, create a file, save it as C:\public_html\testphp.php, and add the following line:
<? print phpinfo(); ?>
Open the URL http://localhost/testphp.php. It should display the PHP information page, describing the PHP version and configuration.
Figure 1. PHP test page
OpenLaszlo is available as a binary installer, as a source code archive, or from the Subversion repository. You will use the binary installer, which includes everything you need, including demos, documentation, examples, libraries, and the Tomcat Web server, which hosts the OpenLaszlo server.
Double-click the installer to start it and install OpenLaszlo into C:\openlaszlo. After the installer finishes, it will start the OpenLaszlo server, which you'll see in a command window. You can start and stop the OpenLaszlo server later with Start menu > All Programs > OpenLaszlo Server > Start OpenLaszlo Server and Stop OpenLaszlo Server.
The installer should also open your browser to a demo page. If it doesn't, point your browser to http://localhost/lzxnet to browse the index of Laszlo documentation and demos. The Laszlo Explorer is an interactive introduction that demonstrates what OpenLaszlo can do, including a hands-on tutorial called "Laszlo in 10 Minutes." You can run it by opening http://localhost/lzxnet/laszlo-explorer.
Figure 2. OpenLaszlo Explorer