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. Remote applications are accessed either through a version control system or through File Transfer Protocol (FTP).
Caution: NetBeans provides basic support for FTP/SFTP, sufficient for a lone developer to work on a simple project. If you are working on a complex project or with multiple developers, you should use a version control system. NetBeans IDE supports a number of version control systems. See our Subversion and Git tutorials, for example. If you must use FTP/SFTP with a complex project, consider using the IDE in combination with a full-featured FTP client, and editing the PHP project in the IDE as a local web site.
JDK 7 + Windows 7/Vista: Windows 7 and Windows Vista firewall blocks some FTP operations that are launched by JDK 7. See NetBeans forum for workaround.
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 for more than a week. So you may fail to apply exactly the same user names, passwords, email addresses, and other credentials from the tutorial.
To follow this tutorial, you need the following software and resources.
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:
On the Run Configurations panel, choose Remote Web Site (FTP, SFTP) from the Run As dropdown list. The hidden area for setting up the configuration displays.
If you are creating a new project with the PHP Application from Remote Server wizard, you do not need to choose from the Run As dropdown list. The wizard automatically takes you to the Remote Connection panel. This panel has only Project URL, Remote Connections and Upload Directory fields.
After you choose the remote connection for your project, select whether to upload your source files on run, on save, or manually.
To manually 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.
When you start to upload files, a dialog opens with a tree view of the source files. In this dialog, you can select individual files to upload or not upload. For more information, see the NetBeans PHP blog entry on the File Upload dialog.
While you upload files, the results of your upload appear in an output tab.
For developers who must work over (S)FTP in multiple developer environments without proper version control, NetBeans IDE provides remote synchronization. Remote synchronization allows you to compare your local copy of project files with the copies on the (S)FTP server. You can upload your local copy to the server or download the server's copy to your local machine. When the copy on the server was updated after you began work on your local copy, NetBeans IDE warns you of a file conflict. When there is a file conflict, NetBeans IDE lets you diff your local version with the version on the server and decide which version to accept on a line-by-line basis.
Warning: Remote synchronization is never 100% reliable because the timestamps on FTP servers are not 100% reliable. Version control is a safer solution.
Caution: Remote synchronization works more reliably when you perform it on an entire project. You can perform remote synchronization on individual files but this has higher risk.
To perform remote synchronization:
The IDE performs the synchronization. You can follow the progress of the synchronization in a window that the IDE opens.
To run a PHP application on a remote server:
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.