Project Management

Create a news portal site with phpWebLog

Delivering dynamic Web content doesn't have to be a difficult task. With the help of Linux and phpWebLog, you can quickly and easily host a dynamic news portal site for richer, more flexible content.

Gone are the days of delivering static content on the Internet. What started as a means of delivering information that was relatively unchanging has become a system of delivering truly dynamic content based on what the visitor wants to see. Sites are tailored for visitors, giving them new and exciting ways to interact with other visitors, change preferences on sites, and even customize the way a Web site looks so that it is more pleasing to their eyes.

This increased demand for dynamic content drove the popularity of languages like PHP. In turn, because of the ease with which you can develop Web sites based in PHP, an increase in dynamic Web sites has followed. Now, most sites are dynamic in one way or another, and they’re using more than a simple CGI script to allow people to sign a guest book.

What seem to be extremely popular on the Web right now are news sites that deliver users snippets of news based on a particular theme: Linux, gardening, pets, the discussion of hydraulics—you name it. There is an extremely high number of such sites because they are easy to set up, look great, and give users a bulletin board on which to discuss topics that interest them.

The news site has exploded in the last year, and it's due primarily to two great software packages making the chore simple. Today, anyone can have a great-looking news site within an hour, from downloading the source used for the site to configuring and launching the site. The first package to really make this easy was PHP-Nuke, a news site written in the PHP language. However, PHP-Nuke delivers more than a simple news system and can be used for a complete community-based site including news, discussion, links, download sections, and so forth; its bulk was a little much for some people who did not need all of these features and wanted a light and fast alternative. The answer was phpWebLog, and I must say it performs admirably.

Installing phpWebLog
PhpWebLog is a news and portal site written in PHP. You can find the application on the phpWebLog home page (the latest version is 0.5.2). Other updated versions with some bug fixes and new features are available, but the latest stable and official version is 0.5.0.

Download the phpweblog-0.5.0.tar.gz file and save it to your Web root directory. For instance, if the site you want to set up will be using phpWebLog exclusively, you might save the file in /var/www, knowing that Apache will be looking in /var/www/html for the index directory of your Web site. To run phpWebLog, you will need a Web server, like Apache, and the MySQL database server. Work is being done to give phpWebLog a database abstraction layer so that it can work with other SQL databases like PostgreSQL, but the 0.5.0 release only supports MySQL.

Change to your Web root directory and unpack the archive using the following:
cd /var/www
tar xvzf phpweblog-0.5.0.tar.gz

This will create a subdirectory called phpweblog-0.5.0/. If your entire site is going to be based on phpWebLog, you can remove your existing html/ subdirectory and rename phpweblog-0.5.0/ to html/ by using
rm -rf html
mv phpweblog-0.5.0 html

Now, change to your html/include/ directory. In this directory is a file called, which is where you will define some site-specific operating parameters. After the GPL license at the beginning of the file, you will see a few variables. You must set up these variables so that phpWebLog knows what kind of environment it is working in:
  • ·        $G_DB defines the database name in MySQL.
  • ·        $G_HOST defines the hostname, which will typically be localhost unless your MySQL server is located on another system.
  • ·        $G_PORT defines the port the MySQL server listens to, which is 3306 by default.
  • ·        $G_USER defines the MySQL user that has access to the database.
  • ·        $G_PASS defines the MySQL user's MySQL password.
  • ·        $G_PATH defines the path to the base phpWebLog directory. If you have installed phpWebLog in /var/www/html, this is the directory you will include here.
  • ·        $G_URL defines the full URL path to the phpWebLog site, so you would use something like here, depending on the domain name you are using.

That is all you will need to edit in the file. Save your changes and move to the /var/www/html/etc directory, where you will find a script called This script will set up the database settings in MySQL for you. Simply execute the script:

You will be asked a few questions, the answers to which you already defined in The script will ask you for the database to create; use what you defined in $G_DB. It will ask for the username and password to use, which you defined in $G_USER and $G_PASS, respectively. It will ask for the database host ($G_HOST) and the database port ($G_PORT). When you finish filling out these values, the script will create the database and table settings.

If you execute the script as root, you can create the user in MySQL after you execute the script. If you do not run the script as root, you will need to create the user you defined as $G_USER first. The simplest way to do this is to execute (as root):
mysql -u root -p

which will prompt you for your MySQL root user password. Once you are in MySQL, you can execute this.

This assumes that you defined $G_DB as phpweblog, $G_USER as webuser, and $G_PASS as secret. It also assumes you are using the MySQL database located on the same machine as phpWebLog. If you are using a remote MySQL server, you will need to change the @localhost to the fully qualified domain name of the system that phpWebLog is installed on.

And that's it! You should be able to point your Web browser to and receive a password prompt to log into the administrative interface. The default password is password, so enter that into the password field. You will now be in phpWebLog's main configuration and administrative page.

Configuring phpWebLog
The first configuration screen concerns story moderation. Later, when you or your users have submitted news stories to the site, this is where you will see and moderate them. Notice a new box on the side: the Admin menu. It has a number of links for various administrative tasks, the first of which is Moderation. The second link is Site Configuration; click on it now.

The Site Configuration page allows you to define a few site-specific items. The first is the name of the site, followed by the slogan. These two components make up the header of the site, which will be displayed in the browser's title bar. Next, define the site owner and the site e-mail address. (The owner should be you, and the e-mail address should be your own.) Next, define the administrator password. You should immediately change this to something that is difficult to guess.

Following the two password fields is the Unique Key field. This is used by phpWebLog to generate unique cookies for the site. A good key would be something based on your site name. Finally, define the site layout and the site language. The site layout determines the look and feel of the site; leave it as is for now. You’ll want to go into the Layouts administrative menu to look at the different themes before you select one.

Save your changes and click on the Layouts link in the Admin menu. At the top of the page, you’ll see a pull-down list, which includes a number of different themes. Go through the list and click on View/Load to check each one out. Each layout provides different values for the rest of the configurable options on the page. Once you have found a layout that you like, you can further configure the site with the options listed. Here, you’ll change things like colors for text and links; you can also define your site logo, page width, block alignment, and so forth. At the bottom of the page, you can even interchange parts of different themes, for a custom-looking site. Once you have made the changes, go back to the top of the page and use the Add/Update button to save the changes to the theme.

You might prefer to give the newly created definition a new name. Instead of changing the default theme itself, you could create a new name, which you define in the input field at the top of the page. For instance, if you decide you like the newsforge layout but make some substantial changes to it, you can change the input box from newsforge to mysite. Then click on Add/Update and you have a new layout called mysite, while leaving the original newsforge layout intact.

To begin using your new layout, go back to the Site Configuration menu, select mysite from the layout list, and save your changes. Once the page has refreshed, it will display the site with your new layout definitions.

Next, click on Story Control in the Admin menu. Here, you’ll define a number of options related directly to story-posting on your site. Define whether or not users can contribute stories to the site at all, and then select whether or not those stories should be moderated. If you want to use moderation, I suggest using the Yes/Notify option because phpWebLog will e-mail the site e-mail address every time a new story is posted.

Define how many stories will be displayed per page. If you define the value 10 here, it means that each page will display 10 summaries. If the site has more than 10 summaries, a link at the bottom of the page will indicate that there are more stories.

You can define whether or not users can post comments to the stories, and you can also define how those comments are sorted. Decide whether or not you want to allow anonymous comments to stories and also define whether or not comments posted on a story will be mailed to the original story poster.

Choose whether or not you will allow users to save their information in cookies so that they will not need to re-enter the information each time they post a story. To save your users some typing, I recommend you enable this option.

The next definition is for how HTML is parsed. PhpWebLog can handle HTML tags in stories and comments in various ways. It can allow full HTML, which means that the user can insert any HTML code they want and it will be interpreted. For security reasons, this isn't a very good idea. I find that using the Reduced HTML setting is adequate. It will allow users to apply styles like bold, italics, and so on to their story, but it will not allow them to write href tags. Instead, users can write a URL and prefix it with http://; phpWebLog will then do in-line parsing, which means it will turn all links prefixed with the http:// into clickable links.

Finally, you can export stories to an RDF file in your /backend directory so other phpWebLog sites can import and display the headlines of your site in a box on their site. You can also define a mailing list to which stories posted on your site will be sent. This only mails the story itself, not any user comments.

Once you have decided how you want stories controlled on your site, click on the Save Changes button and then proceed to Extended Control in the Admin menu. Here, you’ll define a few other options for the site. Define whether or not you want an older stories block on your site, a Top 5 stories block, and a Hot 5 stories (the five most-read stories) block. You can also turn on the Mail-Story-To-Friend feature as well as the Print-Friendly Page feature. You can also define whether or not anyone can add links to the links section of the site, whether or not statistics on the site will be enabled, and whether or not story archives will be enabled.

You can define some extended story options as well. You can define an index name for story links. For instance, you may define an Index Name of Related Links; when people add new stories to the site, they can add the link to where the story was originally featured, where the software a story is about is available for download, etc. The information will show up in a Related Link: field when the story is displayed.

The Polls page lets you define voting booth questions for your site. The Expiration field defines how long a cookie for the site will last. This means that a user will only be able to vote once every seven days (or whatever time period you select). You can also decide whether you want to display the voting question on the left or right side of the page.

The Topics page lets you define new topics for the site. Here, you’ll define the topic name, an image for the topic, and rules for the topic (whether or not users can post under that topic or make comments to stories posted under that topic).

The Blocks/Pages page lets you define blocks and pages in the site. A block is the box that is displayed on the right or left side of the page. You can define the sort order for blocks, the content of the block, or whether you want to import an RDF/RSS file, which is the format most news sites typically export their headlines into. This means you can import the headlines of another news site as a block on your own. You can also define full pages of text here for feature pages on your site, like a download page or image gallery. On feature pages, you can also define whether or not users can post comments on that page.

PhpWebLog is a high-powered, full-features package with a very small footprint. Those who want a quality news site based on an exceptional engine should seriously consider phpWebLog. It takes about an hour to configure, and maintaining the site is a snap. In fact, I've been using phpWebLog myself for a few sites, most notably Freezer Burn, and that’s a testament to the kind of beating a phpWebLog site can take.

If you want a streamlined and efficient news or portal site, phpWebLog is for you. The alternative, PHP-Nuke, which I will take a look at in another Daily Drill Down, is more powerful than phpWebLog, but it is also a lot slower, due to more bloat. If you don't need any of the extras that PHP-Nuke provides, then phpWebLog is the optimal choice.

About Vincent Danen

Vincent Danen works on the Red Hat Security Response Team and lives in Canada. He has been writing about and developing on Linux for over 10 years and is a veteran Mac user.

Editor's Picks

Free Newsletters, In your Inbox