Installing a PHP/MySQL Open Source Application on i
April 20, 2011 Paul Tuohy
I have often used PHP/MySQL open source applications on my PC, but I have never had the opportunity, or need, to use one on the IBM i. That is, not until recently. I was working on a project with three other developers, and we are located in Ireland, Canada, and the U.S. We needed some simple project management software that would work over the Web and did not require in degree in “Gant chart” mechanics. After a quick search I came across a PHP/MySQL open source package, ProjectPier, which seemed to suit our needs. So, in this article, I would like to share what I had to do to get this open source package up and running on i. From start to finish, it took 13 minutes (give or take a few seconds), That includes download and upload times. Remember, I had prior experience of PHP/MySQL on other platforms, which definitely helped in understanding what it was I needed to do. My previous experience with MySQL prompted me to install an extra piece of open source software: Adminer, which was used to administer MySQL databases. These were the installation steps:
Steps one through five above are a one-time process and do not need to be repeated for every open source project you might install. But First Please ensure you have the following software installed on your system:
To perform the following installation and configuration requires a profile with a class of *SECOFR. I was installing on a system running V7R1 (yeah, I know) with Zend Server installed and running. MySQL had not been installed/configured. Although the system I am working on is at V7R1, the following instructions should work on systems from V5R4 on. Zend Server To ensure you have Zend Server installed, enter the following command: GO ZENDSVR/ZSMENU That command will present the screen shown in Figure 1:
To ensure that the Zend Server instance is running, take option 5 (Service Management Menu) and then take options 1 (Start Zend Server Subsystem) and 5 (Start Apache Server Instances) from the resulting menu, shown in Figure 2.
Assuming that you have not changed the default Zend Server installation, pop over to a browser and enter the URL of: http://yourserver:10088/ That URL will take you to the Web page shown in Figure 3:
For the sake of demonstration I am going to install everything in the Zend Server default instance. If you are going to use a different Apache instance, you need to ensure that the configuration file (usually /www/instancename/conf/http.conf) contains the following directive: DirectoryIndex index.php index.html Basically, this means that if you enter a directory name at the end of a URL, the Apache server will look in the directory for a file call index.php or index.html. MySQL From the Zend Server Setup Menu, shown in Figure 1, take option 6 (MySQL Management Menu). If MySQL has not already been installed on your system it will now be automatically installed. The installation process will warn you if you have any missing software or configuration components. From the resulting menu, shown in Figure 4, take options 1 (Start MySQL Subsystem) and 4 (Start MySQL Daemon).
MySQL Administration Profile MySQL utilizes its own security as opposed to using system security. Therefore, in order to create, maintain, and access databases, you need to create at least one MySQL profile. If you have never had the fortune, or misfortune, of using Unix or Linux, the following is going to seem a little strange. But remember, you only have to do it once. From a command line, enter the following command to switch to Unix mode. CALL QP2TERM You now want to start MySQL. Enter the following case-sensitive commands (they are the equivalent of doing a CHGCURLIB and a start command): cd /usr/local/mysql/bin mySQL -u root Your screen should now be similar to the screen shown in Figure 5. Note the mysql> indicator, at the bottom of the list, which shows you are in MySQL.
Now to create the profile and grant the required authorities. You just need to provide the profile name and password, but the following syntax is very important: create user 'paul'@'localhost' identified by 'mybusiness'; grant all on *.* to 'paul'@'localhost'; The important points to note are:
Figure 6 shows you the screen after the profile has been created and authority granted.
All done? Type in the command “quit” to exit MySQL, and then press F3 to return to the familiar command line. Install Adminer Make your way to the Adminer Web site and download Adminer. This is just a small PHP script file and will have a name like adminer-3.1.0.php. On the i, create a new directory in the document root of the Apache instance, copy the downloaded Adminer file to the directory, and rename the file to index.php. In my case, I created a directory named Adminer in /www/zendsvr/htdocs, copied the file adminer-3.1.0.php into that directory and renamed it to index.php. Back in a browser, to get to the Adminer log-on page, enter a URL of: http://yourserver:10088/Adminer Log on with the profile and password you defined in the previous step: In my case that would be paul mybusiness. (You only need to enter the profile and password on the logon screen; the server defaults to localhost). Create the ProjectPier Database In Adminer, take the link to “Create New Database,” enter a name for the database, and click the Save button. Figure 7 shows the database being defined. You are now done with Adminer, so you can log out.
Remember the name of the database; you will need it in a moment. Install ProjectPier Make your way to the ProjectPier Web site and download ProjectPier. This is a ZIP file and will have a name like ‘projectpier-0.8.0.3.zip’. Unzip the downloaded file and you will end up with a directory with the same name (projectpier-0.8.0.3). Rename the directory to a more meaningful name (projectpier) and copy it to the document root of the Apache instance you are using (the directory is approximately 5M). I ended up with: /www/zendsvr/htdocs/projectpier Once you have copied up the directory, ensure that *PUBLIC has *RWX authority to the following files and directories
If your 5250 session is still open, the easiest way to do this is to enter the command: wrklnk '/www/zendsvr/htdocs/projectpier/*' Then use option 9 to set the required authority and option 5 to move down into a directory. Figure 8 shows an example of changing the authority for the /upload directory.
Go back to the Web browser and enter a URL of: http://yourserver:10088/projectpier/public/install This page will guide you through the rest of the installation process for ProjectPier. This consists of five steps. The first two steps are just informative and check that all prerequisites have been met. The second step will show you if you have missed any of the files or directories that require *RWX access. In the third step, shown in Figure 9, you need to identify the database that ProjectPier is to use, along with the profile and password used to access it.
After clicking the Next button, you should get the completion screen shown in Figure 10. Although the heading says “Finish” this is not the last screen. But you are almost there!
Click on the Finish button and you will be presented with the screen where you identify the user ID (yes, another one) and password you will use to access and administer ProjectPier.
Configure ProjectPier Once installed, you should be able to access ProjectPier using the following URL: http://yourserver:10088/projectpier/public/install Then enter the profile and password you defined in Figure 11. I will leave it up to you to play with ProjectPier as and how you see fit. The sequence of events should be to create a company, users and (if required) clients. You can then work your way through Milestones, Tasks, and Task Lists. ProjectPier also has some nice features, such as changing the look and feel of the site. Have a look at the Administration function. Of course, all the documentation for ProjectPier can be found on their Web site. In Conclusion There you have it. Although this reads quite long, it is actually a very quick and easy process. Probably the worst part is the creation of the MySQL administration profile, but that is only a once-off task. With MySQL in place, the installation of an open source application is usually as straightforward as copying up a file or directory and running an installation program. Have fun! Paul Tuohy is CEO of ComCon, an iSeries consulting company, and is one of the co-founders of System i Developer, which hosts the RPG & DB2 Summit conferences. He is an award-winning speaker who also speaks regularly at COMMON conferences, and is the author of “Re-engineering RPG Legacy Applications,” “The Programmers Guide to iSeries Navigator,” and the self-study course called “iSeries Navigator for Programmers.” Send your questions or comments for Paul to Ted Holt via the IT Jungle Contact page.
|