Last month began our look at a class of Web-based tools for creating dynamic Web sites. The LAMP-powered tools provide a framework for news and announcements, threaded discussions, weblogs, polls, and dynamic content. This month we'll go through the process of installing and setting up PostNuke, a popular PHP-based system.
Last month began our look at a class of Web-based tools for creating dynamic Web sites. The LAMP-powered tools provide a framework for news and announcements, threaded discussions, weblogs, polls, and dynamic content. This month we’ll go through the process of installing and setting up PostNuke, a popular PHP-based system.
Before we get too far, it’s worth mentioning that you should try out PostNuke on a test server or at least a new virtual server so as not to disrupt your normal Web site operations.
Getting the Code
To get started, in addition to the normal Apache and MySQL setup, make sure you have at least version 4.0.1 pl2 of PHP installed. Then head over to the PostNuke Web site (http://www.postnuke.com/) to download the latest stable version. At the time of this writing it is .703, which comes packaged in a file named PN_703.tar.gz.
Untarring the file with the command tar -zxvf PN_703. tar.gz creates the directory pn703 that contains a README file as well as two subdirectories, sql and html. We’ll use the files in the html directory after preparing the database.
The easiest way to set up MySQL for PostNuke is to create a separate database for the PostNuke site. We’ll create one called nuke:
$ mysqladmin -u root -p create nuke
Then we’ll create a username and password that will have full access to the nuke database (but nothing else). The command sequence is in Figure One.
Figure one: Creating the nuke MySQL user
$ mysql -u root nuke
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21 to server version: 3.23.47-log
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> GRANT ALL PRIVILEGES ON nuke.*
TO nuke@localhost IDENTIFIED BY ‘password‘;
Query OK, 0 rows affected (0.11 sec)
If we don’t create the database in advance, the PostNuke installation script would need to use a MySQL account (such as root) that had privileges to create databases. For security reasons, it’s generally not a good idea to have applications running with administrator access to MySQL.
Post Nuke Setup
With the database work out of the way, it’s time to get the PHP and HTML files in order. It’s probably best to create a new nuke directory underneath the document root. If that’s located at /www, then you’d use the commands:
# mkdir /www/nuke
# cp -r html/* /www/nuke/
Then point your browser at the install.php URL (http://localhost/nuke/install.php) to begin the configuration process. The installation routine walks you through several pages and collects information about your setup.
The first page displays the GPL license and waits for you to click the Next button to continue with the installation process.
The second page will ask you to check the permissions of the PostNuke configuration file, saying something like:
We will first check to see that your CHMOD settings are correct in order for the script to write to the file. If your settings are not correct, this script will not be able to encrypt your data in your config file. Encrypting the SQL data is added security, and is set by this script. You will also not be able to update your preferences from your admin once your site is up and running. Please set your CHMOD on config.php to 666 so this script can write and encrypt the DB data.
While this probably sounds like a Really Bad Idea, the Web server needs to be able to write to config.php and config-old.php to save your settings, and it’ll only be for a short while. So change the file permissions for now:
# chmod 666 /www/nuke/config.php
# chmod 666 /www/nuke/config-old.php
We’ll be sure to set them to something more secure as soon as the configuration is finished. Once the file permissions are changed, click the ReCheck button on that page. It will confirm that the files are writable and present a Continue button to click if everything is set up correctly.
The next page allows you to configure the database connection parameters. We’ll need to verify that the settings are correct for our setup. Figure Two shows what the page should look like with all the correct values.
Figure Two: The PostNuke database settings
DB USER NAME:
After you’ve entered all the information, the next page will allow you to double-check it. Once you’re sure it’s correct, click the New Install button to start installation.
The next page confirms the information once more and then asks if you’d like to create the database. Leave that option unchecked, since we created it earlier. Click the Start button to continue.
The PostNuke installer will create all the necessary tables and tell you that it has done so. Click Continue to move on.
The next page, shown in Figure Three, covers some general PostNuke preferences. You should change the default administrative username (“God“) and password (“Password“) as well as the e-mail address and site URL to whatever is appropriate for your site.
Figure Three: General PostNuke settings
Once that’s completed, the next page will confirm that all the settings were saved properly. If they were, click the Finish button and you’re done. The final page will display credits and a Go to your PostNuke site link which should take you to your new site.
Before we forget, let’s go back and fix those file permissions that we adjusted earlier. Because there is now a username and password stored there, it’s best to tighten security by making sure that only the Web server can read them.
# chmod 600 /www/nuke/config.php
# chmod 600 /www/nuke/config-old.php
# chown www /www/nuke/config.php
# chown www /www/nuke/config-old.php
This doesn’t prevent someone with access to your Web server from writing a CGI or PHP script to grab this configuration data, but it will at least keep out folks who are casually snooping around.
|Figure four: Your New PostNuke Site|
Try it Out
Click on the Go to your PostNuke site link to go to the home page for your PostNuke site (the URL would be http://localhost/nuke/index.php). By default, it should look like Figure Four.
You’ll notice that PostNuke is rather generic right out of the box. That’s because it was built to be customized. The page title, slogan, poll, and even the color scheme can be adjusted easily. You’ll just need to spend some time tinkering with it.
To customize your site, start by entering the administrative username and password and click Login. Once you’re logged in with administrative rights, you’ll see an Administration link on the main menu on the upper-left. That link will take you to the Administration Menu, pictured in Figure Five.
|Figure five: The PostNuke Administration Menu|
The Administration Menu is the starting point for customizing all aspects of the site. It includes 23 different configuration settings that control user and group administration, the modules which appear on the home page, news topics, polls, and other site features.
Plugging in Next Month…
With PostNuke installed and running, you can begin adding content and customizing the site’s appearance. You’ll find that PostNuke is easy to learn and customize, and is also quite extensible. In next month’s column we’ll look at finding, installing, and using PostNuke plugins to enhance the functionality of your site.
Jeremy Zawodny uses Open Source tools in Yahoo! Finance by day and is is writing a MySQL book for O’Reilly & Associates by night. He can be reached at: Jeremy@Zawodny.com.