Eclipse simplifies the process of deploying your site to a web server. You can even use Ant, traditionally thought of as a Java tool, to help you in the deployment. This article, the first of two parts, explains how. It is excerpted from PHPEclipse: A User Guide, written by Shu-Wai Chow (Packt Publishing, 2006; ISBN: 1904811442).
Deploying your Site with phpEclipse (Page 1 of 4 )
Deploying Your Site
We've walked through the complete process of web development using Eclipse, from development to code storage. The final part would be to deploy your site to a web server. Once again, Eclipse simplifies our work by including several tools that aid us in this process.
The key to deployment in Eclipse is the export function. Eclipse gives us many options in exporting our site. First, we will look at FTP, an old and common method of moving files. WebDAV is an interesting way to upload files using a web server. Secure FTP (SFTP), a protocol similar to FTP, but encrypted, is enjoying immense popularity in this security-conscious age. FTP and WebDAV exports are provided through plug-ins as part of the PHPEclipse package. The Klomp plug-in gives us SFTP export capabilities, and comes bundled with PHPEclipse.
Finally, we will see how Ant, traditionally regarded as a Java tool, can help us in PHP deployment.
Setting Up a Test FTP Server
A server running FTP, SFTP, or WebDAV processes is a fairly common thing. However, if you do not have a server available for experimentation with Eclipse, you can easily set up these services. However, as of Eclipse 3.0/3.1, these clients do not work when connecting to a local server. You will have to set up a second machine on your local network to run these services. To help you, we will touch on how to quickly set up an FTP server.
Again, a word of caution—these instructions are designed to give us a crude but effective file server. It will neither be very secure nor optimized for performance. If you need a production FTP server, consult other resources on configuring your machine and security best practices.
To start off, decide on an upload area. This directory could be anywhere, but be sure you have read and write permissions to that directory.
On the Windows platform, you can place a copy of the XAMPP package on your server. XAMPP includes FileZilla, an easy-to-manage, open source FTP client and server package. First, make sure the FTP server is running by checking the XAMPP Control Panel. The status for FileZilla should be set to Running. Inside the main xampp directory there will be a FileZillaFTP directory.
In here, you'll find an executable named FileZilla Server Interface. This program provides a GUI front-end to any FileZilla FTP server, local, or remote. Launch this application. You'll be presented with a dialog box to choose your FTP server:
This application automatically lets you administer your local instance of FileZilla. Click on the OK button to accept the default options.
You'll be taken to the main administration screen, which is essentially a console for the FTP server. We need to add ourselves as an FTP user to this system, so click on Edit | Users to pull up the main Users administration screen.
Under the Users listing, click on the Add button. Specify a login name. When we approve the addition, we'll be taken back to the Users administration screen. At this time, it would be prudent to add a password to our account in the Account Settings section. Next, we need to specify the home directory of our account. Make sure the newly added account is selected on the Users listing, and then select the Shared folders listing on the right, under Page.
In the Shared folders area, click on the Add button. Browse to a directory that you selected as your publishing directory. This should be the same directory as your Apache document root. If this is the first directory that you added through the FileZilla Server Interface, it will automatically receive an H icon next to the name in the Shared folders box. This designates that the directory is the home directory for the user, and at every logon, the user will automatically be re-routed to that directory after login. Before you click the OK button, make sure all the permissions checkboxes are checked for the publishing directory. FTP services run on TCP port 21, and FileZilla will open that port for use. If you are using Windows XP, a system dialog box might appear, asking whether you are sure you wish to unblock the port. Click the OK button to allow the unblocking.
Mac OS X includes an FTP/SFTP server built in. The server is also preconfigured for our needs, using the users and groups of the local machine. We won't have to do any extra setup. However, it is turned off by default. To turn on the server, go to System Preferences | Sharing. Make sure the checkbox next to FTP Access is checked.
An FTP daemon is a basic component of a Linux server, and your distribution should have one installed or available to install. Unfortunately, it may not always be started and configured on your Linux distribution. Also, how you start and configure differs greatly by distribution. The GUI clients will differ if you are using Gnome or KDE desktops. Some distributions include a GUI client to administer FTP services, while others need to be administered by manually editing configuration text files and stopped and started via the command line. Consult your distribution's documentation for instructions.