You are on page 1of 34

Drupal 6.x Support on NetBeans 6.

x IDE
--Sujit Nair (March 29, 2008)

Contents :

1. Introduction
2. Installing NetBeans 6.x IDE
3. Installing AMP (Apache HTTP Server, MySQL and PHP) stack
4. Configuring MySQL Database
5. Drupal PHP files - CVS Download
6. Creating Drupal PHP Project
7. Upload and hosting Drupal Application
8. NetBeans – Identifying .module and .install as PHP files
9. Conclusion
10.Appendix A (AMP on Solaris 10/SXDE using CoolStack)
11.Appendix B (AMP on Windows)
12.Appendix C (AMP on Linux)
13.Appendix D (Alternately configuring MySQL Database on Windows)

Introduction

This tutorial will help you install and configure all of the software necessary to develop a
Drupal-based Web site on Solaris/Linux/Windows. At the end of this tutorial, you will be
having a Drupal based Web site up and running, on the top of which you can develop
different modules quite effectively using the PHP editing features provided by NetBeans
IDE. We concentrate on the open sourced integrated development environment (IDE),
NetBeans, because it provides a very effective project file management, an integrated
revision control mechanism, local revision history and PHP editing features.

The prerequisites before installing and configuring the software environment are :
• Operating System (Solaris 10/SXDE/Windows/Linux)
• Java 1.4 or higher version
• An internet connection

The software environment that we refer here consists of NetBeans IDE, MySQL, PHP and
Apache Web Server.

We have taken Solaris Operating System (Solaris 10/SXDE) as the epicenter of the examples.
The screen-shots and steps refer to Solaris based systems. Similar steps are to be followed
for Linux and Windows based operating systems.
Installing NetBeans 6.x (here 6.0) IDE :

By default, the Solaris box would contain an installation of NetBeans (generally in the
location /usr/dist/share/netbeans,v6.0). But, if not present then download and install
following the steps given below.
• Download the release version of NetBeans 6.0 IDE from the following location :
http://download.netbeans.org/netbeans/6.0/final/
• Download the Web and Java EE (~117 MB) or All (~156 MB) of the bundled features.

• Install NetBeans into a local drive (for e.g., /opt/netbeans)


• Both the bundled packs mentioned above contain the plugins required for hosting
Drupal through NetBeans, viz., PHP plugin and CVS plugin.
• If the PHP plugin is not available, then go to Tools – Plugins – Available Plugins, and
install the PHP plugin enlisted in the catalog.
• The Windows and Linux users too can download NetBeans IDE from the same location
by specifying their target operating system.
Installing AMP stack on the Operating System

The steps to install the AMP stack using CoolStack 1.2 on the Solaris 10/SXDE is specified in
Appendix A.

The steps to install the AMP stack from “www.en.wampserver.com” on the Windows
(98/2000/XP/Vista) is specified in Appendix B.

The steps to install the AMP stack on the Linux is specified in Appendix C.
Configuring MySQL Database

We have to create a database and an user to access it in MySQL Database through command
line in the following way.

* Run mysql on command prompt and login as default user, 'root'.

“mysql -u root -p”

By default, there is no password for the user 'root'. So, simply press enter.

* Create a new database for Drupal Application. Use following command.

“create database drupal_db”

* Create a new user for accessing the 'drupal_db'. Use following command.

“create user drupal_user identified by 'password'”

* Grant all privileges to the newly created user for the 'drupal_db'. Use following command.

“grant all on drupal_db.* to 'drupal_user'@'localhost'


identified by 'password'”

Thus, we have created a database and a user with full access to the database. We need to
quote the database and user while configuring the Drupal Application for the first time.

An alternate way to perform the above steps using 'phpMyAdmin' GUI on Windows in
described in Appendix D.
Drupal PHP files - CVS Download

• Run an instance of NetBeans IDE.


• Click on Versioning – CVS – Checkout
• Select the CVS root and enter the password
CVS Root : “:pserver:anonymous@cvs.drupal.org:/cvs/drupal”
Password : anonymous
Set the proxy configurations accordingly
Click Next.

• Select the Module, Branch and the Local Folder to download the sources.
Module : Drupal
Branch : DRUPAL-6
Local Folder : /export/home/<username>/Desktop/Drupal -- (on Solaris)
Click Finish.
• The CVS downloading starts and the status appears in the Output window in
NetBeans.
Thus, we have downloaded the Drupal PHP files, into a local folder, needed to host a
website.
Creating Drupal PHP Project

• Once the Drupal PHP files are downloaded, we will now create a new PHP project
and add the drupal sources to it.
• Click on File – New Project. And create a new PHP project with existing sources.
Click Next.

• Enter the Project Name (say Drupal Application) and Location. Click Next.
• Specify the location of the Drupal Sources. Click Next.
• Configure a Web Server if not pre-configured. Click Manage. We can add web servers
through this wizard.
• Click on Add. And enter the Connection Name in the wizard. Select the Server Type
(Local/Remote Web Server). In our case, as we have installed the AMP stack, so we
select a local Web Server. Click Next.
• Browse to the location of the Apache configuration file (for
e.g., /opt/coolstack/apache2/conf/). Also, choose the host name (in case multiple
hosts are configured). Click Next.
• Enter server name (for e.g., localhost) and the port number (8090). Click Next.
• Enter the Document root for the Web Server. Click Finish.
• The newly configured web server appears gets enlisted into the 'web server' tree.
• Finally, select the newly configured web server and Click Finish. The PHP project
gets created with Drupal sources add to it.
Upload and hosting Drupal Application

• Right click on the newly created Drupal Project. Click on Upload files.

• We can see the status of the upload in the window at the bottom. It lists out how
many files have been uploaded.
• Now, right click on the project and click on 'Run'. The drupal application is loaded
onto the default internet browser.

• Thus the Drupal Application is up and running! Now, if required, we can modify the
files in sources using the PHP editing capabilities provided in the NetBeans IDE and
upload/run the application.

nota bene : While running Drupal application for the first time, we need to provide the
database configuration and site configuration details. Then click on 'Save and Continue'.

Database Configuration :
Database Name : drupal_db
Database UserName : drupal_user
Database Password : password

Site Configuration :
Site e-mail address : administrator@sun.com
Administrator username : drupal_user
Administrator password : drupaL$1
On entering these details, we finally finished the necessary steps for running Drupal
Application. The screen displays as the configuration finished and on clicking on the link to
the site (as shown in the screenshot below), we can use the Drupal Content Management
System.
NetBeans – Identifying .module and .install as PHP files

The current PHP plugin in NetBeans IDE doesn't identify .module and .install files as PHP
files. So, the editing features are not reflected for such files. We can register these files as
PHP files in the following way

• In the NetBeans IDE, click on Tools – Options – Advanced Options. The Advanced
Options button is located at the bottom left corner of the window as shown in the
screenshot below

• In the tree hierarchy on left pane, go to IDE Configuration – System – File Types. Here
, we can see PHP.xml. Now, right click on the file and open. The file gets opened in
the editor in the background. Close the Advanced Options window.
• Add these two lines to the ext type in the code as shown in the screenshot below
<ext name="install"/>
<ext name="module"/>

Now, restart the NetBeans IDE so that these extensions get registered as PHP files and we
can now make use of the editor utilities provided by PHP plugin.
Conclusion

We hope this document helps the users to configure and run Drupal through NetBeans IDE.
As a supplementary to this document, we would also be providing a NetBeans plugin for
easing the work of developing a module in Drupal. The plugin (to be made available in
NetBeans plugin portal, http://plugins.netbeans.org/PluginPortal/) would provide a wizard
to create a module and auto-generate the necessary important files, viz.,
<modulename>.info, <modulename>.install and <modulename>.module along with the
template code.

For further queries, please contact Eric Reid at Eric.Reid@Sun.COM or Sujit Nair
Sujit.Nair@Sun.COM
Appendix A (Installing AMP stack on Solaris 10/SXDE using CoolStack1.2)

We can quite easily download and install the AMP stack for Solaris using Coolstack (v1.2).
Cool Stack is a collection of some of the most commonly used open source applications
optimized for the Sun Solaris OS platform. By using these binaries you will enjoy the best
levels of performance from your system, while also reducing your time-to-service.

For downloading the binaries, visit “http://cooltools.sunsource.net/coolstack/”


and login using Sun Online Account (Register if you don't have, its free of cost!!).

Select the three binaries required for AMP stack installation and working, viz.,
CSKruntime_1.2_<machine_type>.pkg.bz2, CSKphplibsbundle_1.2_<machine_type>.pkg.bz2
and CSKamp_1.2_<machine_type>.pkg.bz2. Refer the screenshot below.
Please download the CoolStack1.2.pdf for guidelines to install the packages available in
Coolstack v1.2. For our purpose, on downloading the three packages, the following steps
need to be done.

Following is a sample installation of CSKamp on a sparc machine, assuming it has been


downloaded to /tmp. Before you install CSKamp, you should install CSKruntime as follows :
# bunzip2 /tmp/CSKruntime_1.2_sparc.pkg.bz2
# pkgadd -d /tmp/CSKruntime_1.2_sparc.pkg
Now we'll install CSKphplibsbundle as follows :
# bunzip2 /tmp/CSKphplibsbundle_1.2_sparc.pkg.bz2
# pkgadd -d /tmp/CSKphplibsbundle_1.2_sparc.pkg
Now we'll install CSKamp as follows :
# bunzip2 /tmp/CSKamp_1.2_sparc.pkg.bz2
# pkgadd -d /tmp/CSKamp_1.2_sparc.pkg
The following packages are available:
1 CSKapache2 Apache httpd
(sparc) Apache 2.2.6
2 CSKmysql32 MySQL
(sparc) MySQL 5.0.45
3 CSKphp5 PHP 5
(sparc) PHP 5.2.4

The applications typically get installed into the directory /opt/coolstack.

With user rights to modify and write into the folders under /opt/coolstack, start the
Apache HTTP server and the MySQL server.

Starting Apache HTTP Server :


Open “httpd.conf” present typically in the location
“/opt/coolstack/apache2/conf” and change the attribute value of
“Listen” to
“0.0.0.0:8090”
Run the following command on command line to start the apache HTTP server
“/opt/coolstack/apache2/bin/apachectl -f /opt/coolstack/apache2/conf/httpd.conf”

Starting MySQL Server :


Run the following in command line
“/opt/coolstack/mysql_32bit/bin/mysqld”
Appendix B (Installing AMP stack on Windows)

• Download the latest AMP (Apache HTTP Server, MySQL and PHP) stack from
http://www.en.wampserver.com/download.php

• It includes Apache HTTP Server, PHP + PECL, MySQL, SQLitemanager and


Phpmyadmin.
• Install it into a location with no spaces in the directory names and having rights for
the current user to write/modify data. (for e.g., F:\Drupal\wamp).
Appendix C (Installing AMP stack on Linux)

Run the 'apt-get install' command to download and install the packages in AMP stack onto
Linux machines. For e.g., for installing AMP stack on Ubuntu machines, run the following
command,
“sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-
server libapache2-mod-auth-mysql php5-mysql”
This installs the Apache, MySQL and PHP onto the system and runs the Apache Web Server
and MySQL Server.
Thus, the AMP stack is up and running on Linux machines.
If you want to restart the Apache or MySQL servers, please run the following command :
$ /etc/init.d/mysql restart (for MySQL server)

$ /etc/init.d/apache2 restart (for Apache Web server)


Appendix D (Alternately configuring MySQL Database on Windows)

• Start the 'WAMP' server. (for e.g., F:\Drupal\wamp\wampmanager.exe)


• An icon appears on the system tray indicating the status of WAMP Server and its
components.
• Now, left click on the icon and click on 'phpMyAdmin' link.

• The 'phpMyAdmin' webpage opens up.

• Click on the databases link on the page and create a new database for drupal (for
e.g., 'drupal_db')
• Create a new user by clicking on 'add a new user' link in privileges.
• Add the user information into the text boxes. (for e.g., 'drupal_user' for user,
'localhost' for host, 'password' for password) and click Create.
• Go to privileges tab for the created database 'drupal_db' and grant all privileges for
the newly created user 'drupal_user'.

You might also like