Remote Php Project

Do I need to do this?

The answer is most likely no. If you are content with your own personal system, you do not need external access to another. Even if you do use an external system, you do not need this so long as you can access it through a graphical interface, like Remote Desktop.

Description

A Php web project on a server can be accessed and used remotely from any client with NetBeans installed. The remote connection can be either via FTP or SFTP. The official NetBeans tutorial document is this:
http://netbeans.org/kb/docs/php/remote-hosting-and-ftp-account.html
In our example we will be using an SFTP connection to the Computer Science student taz server.

Taz login

Personalize this document by keying in your
taz login:

Software

Even though the project is on a remote server, it is managed through a local copy, and so you still need the NetBeans Php plugin installation. If you don't already have it:
  1. Select Tools ⇾ Plugins from the menus
  2. Click the Available Plugins tab, scroll down and check Php. Then click the Install button.
Additionally, you will need to use a Secure Transfer Client and possibly a Secure Shell Client. Possibilities include:

Server key file

The NetBeans remote SFTP connection needs a file in which to store the taz server key. If you're on a UNIX-like system, it is likely that the file NetBeans would like to use is already present:
~/.ssh/known_hosts
On Windows or other systems which do not have this file present, you will need to create file because NetBeans will not do so. For example, on Windows, create the empty file, say:
My Documents\known_hosts.txt
The name and location is unimportant. The only thing important is that the file exists.

Installation and Execution

The project, with at least one file, needs to exist on the server prior to installation. As a demonstration, we will use a the RemoteTest project. You will need to transfer this project into the public_html directory of your taz account.
  1. Download the source archive RemoteTest.zip. The folder RemoteTest contains, as a starter, the single file, index.php.
  2. Somehow get the RemoteTest folder into the ~/public_html folder on taz, e.g.:
    1. Extract the archive locally and transfer the entire folder directly into public_html of your home directory on taz.
    2. Transfer the RemoteTest.zip archive to your taz home directory (one level above public_html). Access taz via secure shell and extract the archive using unzip, e.g.,
      $ unzip RemoteTest.zip -d public_html/
      
  3. Open NetBeans and, within the Php category, create a New ⇾ Php Application from Remote Server with the following initial settings, then click Next.
    Project Name:    RemoteTest
    Sources Folder:  PATH-TO/NetBeansProjects/RemoteTest
    PHP Version:      (at least)
    
  4. In the Remote Configuration window, a key step is to establish the remote server connection. Click the Manage button. Fill in the Create New Connection window, then click OK:
    Connection Name:  taz 
    Connection Type:  SFTP
    
    You only need to do this server setup once for each server that you use.
  5. Fill in the fields:
    Host Name:          taz.cs.wcupa.edu
    User Name:          LOGIN
    Password:           YOUR-TAZ-PASSWORD
    Private Key File:   ignore this unless you know what you're doing
    Known Hosts File:   if not filled in (on Windows), Browse to the "known hosts" file you created
    Initial Directory:  /home/LOGIN/public_html
    
  6. Click the Test Connection button to confirm that all is OK. Then OK to leave this window.
  7. Now back to the window which sets up the application itself. Fill in, or confirm, these fields:
    Project URL:        http://taz.cs.wcupa.edu/~LOGIN/RemoteTest
    Remote Connection:  taz
    Upload Directory:   /RemoteTest
    
    You should see this below the last field:
    sftp://taz.cs.wcupa.edu/home/LOGIN/public_html/RemoteTest
    Then click Next to complete the setup.
  8. A Confirmation window presents you with a list of the files to download from the remote server. Click Finish to download the project files to your local system.
To run, click the Green Run button (or run through the right-click popup menu). Running will bring up the default window manager browser running the Project URL.

Verify the validity of how this project works by creating a file linkme.php, adding some content and testing the link from index.php.

Synchronization with remote server

The NetBeans Remote Project works best through a single dedicated client. However, you can make changes to the project in some other way, e.g., via secure shell to taz, and then synchronize the changes onto your dedicated client.

By right-clicking on Source Files, you get a menu with these choices:
Download
Upload
Synchronize
The last of these options, Synchronize, invokes a dialog whereby differences in the local and remote copies can be managed. You can verify its effectiveness by doing:

Not version control

It is noted in the online document describing Remote NetBeans Projects, that this synchronization feature is based on file timestamps and is not at all like version control systems (like Subversion, Git, or Mercurial) which one would use for managing a shared software project on multiple clients.

Project Deletion

If you delete a remote project on NetBeans, it only deletes the local copy, not the copy on the server.


© Robert M. Kline