corner imagecorner image
FeaturesPluginsDocs & SupportCommunityPartners

Deploying a PHP Application on a Remote Web Server Using the NetBeans IDE

Normally, a real-life PHP application is run on a remote server and is accessed through a File Transfer Protocol (FTP). To deploy your PHP application on a remote server, you will need to register an account on a hosting provider. You can also deploy a MySQL database on the remote server where you have a hosting account.

All the user names, passwords, and email addresses are fake and used as examples only. The administration of the hosting blocks an account if the user does not show up on the forum fore more than a week. So you may fail to apply exactly the same user names, passwords, email addresses, and other credentials from the tutorial.

Contents

Content on this page applies to NetBeans IDE 6.5

To follow this tutorial, you need the following software and resources.

Software or Resource Version Required
NetBeans IDE PHP download bundle 6.5
A PHP engine Version 5
A hosting account and
an FTP account on a remote server
For example, x10Hosting
provides free FTP account hosting.
A PHP debugger (optional) XDebug 2.0 or later

Setting Up Run Configuration for PHP Projects to be Hosted Remotely

If you have a hosting account on a remote Web server and an FTP account to transfer your source files to the remote server, you can create and debug your PHP project locally and then deploy it on the remote server. With the concept of Run Configurations, you can switch between these workflows within the same NetBeans PHP project by changing the Run Configuration type from Local Web Site to Remote Web Site.

To enable running a PHP application on a remote web server, you need to set up a run configuration that contains an FTP connection profile.

If you already have a project with a default run configuration and you want to add a new remote run configuration, customize your project:

  1. Click the right mouse button on the project node and choose Properties from the popup menu. The Project Properties panel opens.
  2. From the Categories list, choose Run Configuration. The Run Configurations panel opens.
  3. Choose the run configuration type and specify the FTP connection settings as described in the sections below.
To define a remote run configuration as default for a new project:
  1. Start the IDE, choose File -> New Project. The New Project panel opens.
  2. Choose PHP from the Categories and choose the PHP Application project type. Then click Next. The Name and Location panel opens.
  3. Specify the project name, the location of the application source files, and the location of the project internal files (optional). Click Next. The Run Configuration panel opens.
  4. Choose the run configuration type and specify the FTP connection settings as described in the sections below.

Choosing the Run Configuration Type

On the Run Configurations panel, choose Remote Web Site (FTP) from the Run As dropdown list. The hidden area for setting up the configuration displays.

Specifying the FTP Connection Settings

To create an FTP connection:

  1. Click Manage next to the FTP Connection dropdown list. The Manage Remote Connections dialog box displays.
  2. Click Add. The Create New Connection dialog box opens.
  3. In the Connection Name field, enter the name of the new connection. In this example the connection name is x10hosting. Click OK. The Manage Remote Connections dialog box displays with the name of the new connection in the Connection Name display field.
  4. From the Type dropdown list, choose FTP.
  5. In the Host Name field, enter the FTP Server name as it is written in the FTP account creation confirmation message. In this example, the FTP server is ftp.phpuser.x10hosting.com.
  6. In the Port field, specify 21.
  7. In the User Name field, enter your FTP Username as it is written in the FTP account creation confirmation message. In this example, the FTP username is .
  8. Fill in the Password field. In this example the password is qwerty1234.
  9. In the Initial Directory field, enter the name of your account directory on the FTP server. In this example, no account directory is specified, enter a slash in the field.
    Manage FTP Connections dialogbox.
  10. Click OK. You return to the Run Configuration panel.
  11. In the Upload Directory field, enter the name of the subfolder in the initial directory where the source files will be uploaded. The prompt below the field shows the FTP host URL.
  12. To complete setting up a new project, click Finish.

Uploading the Source Files to a Remote Server

To upload files from your project to your FTP server, right-click the Source Files node of your project and select Upload. Note that you can also download files from your FTP server in the same menu.

Context menu in Project Manager showing Upload option for PHP project Source Files

Running a PHP Application


To run a PHP application on a remote server:
  1. On the Properties panel, make sure that the Remote Web Site is chosen from the Run As dropdown list.
  2. Check the Run Configuration settings.
  3. If the project is set as main, click on the toolbar.
  4. If the project is not set as main, position the cursor on the project node and choose Run from the popup menu.

Using a Remote MySQL Database

Remote hosting services such as x10Hosting.com usually allow you to set up a MySQL database on their servers. You can create databases, manage users, and copy, read, update, or delete (CRUD) data with the tools provided by the remote hosting service.

For example, if you are using x10Hosting.com, you create a MySQL database by logging onto the x10Hosting cPanel and then opening the MySQL Databases panel. You can also create users, assign users to databases, and grant privileges to users in the MySQL Databases panel. You then can use the CRUD tools in the phpMyAdmin panel.

An alternative to working with remote database CRUD tools is to use NetBeans IDE's CRUD features to work with a local database. Then you can copy or dump the local database to the remote database. On x10Hosting.com, you can use their phpMyAdmin panel to upload the local database.


To send comments and suggestions, get support, and keep informed on the latest developments on the NetBeans IDE PHP development features, join the mailing list.

Back to the Learning Trail

Companion
Projects:
MySQL Database Server   GlassFish Community: an Open Source Application Server   Open Solaris  Open JDK: an Open SourceJDK   Mobile & Embedded Community     Sponsored by 
Sponsored by Sun Microsystems