Chapter 2: Using File Transfer Protocol

In This Chapter

arrow.png Discovering FTP

arrow.png Understanding file transfer

arrow.png Exploring easy-to-use FTP clients

arrow.png Making sense of FTP terminology

arrow.png Editing files by using FTP

arrow.png Changing file permissions

Throughout this entire book, you run into the term FTP. FTP (File Transfer Protocol) is a network protocol used to copy files from one host to another over the Internet. With FTP, you can perform various tasks, including uploading and downloading WordPress files, editing files, and changing permissions on files.

Read this chapter to familiarize yourself with FTP, understand what it is and how to use it, and discover some free, easy-to-use FTP clients or programs that make your life as a WordPress website owner much easier. If you run across sections in this book that ask you to perform certain tasks by using FTP, you can refer to this chapter to refresh your memory on how to do it, if needed.

Understanding FTP Concepts

This section introduces you to the basic elements of File Transfer Protocol (FTP). The ability to use FTP with your hosting account is a given for almost every web host on the market today. FTP offers ways of moving files from one place to another:

check Uploading: Transferring files from your local computer to your web server

check Downloading: Transferring files from your web server to your local computer

You can do several other things with FTP, including the following, which I discuss later in this chapter:

check View files: After you log in via FTP, you can see all the files that are located on your web server.

check View Date Modified: You can see the date a file was last modified, which can sometimes be helpful when trying to troubleshoot problems.

check View file size: You can see the size of each file on your web server, which is helpful if you need to manage the disk space on your account.

check Edit files: Almost all FTP clients allow you to open and edit files through the client interface, which is a convenient way to get the job done.

check Change permissions: Commonly referred to as CHMOD, the command that controls what type of read/write/execute permissions the files on your web server have.

FTP is a convenient utility that gives you access to the files located on your web server, which makes managing your WordPress website a bit easier.

tip.eps SFTP (Secret File Transfer Protocol) is also a method of FTP. SFTP provides an additional layer of security as it uses SSH (Secure Shell) and encrypts sensitive information, data, and passwords from being clearly transferred within the hosting network. Encrypting the data ensures that anyone monitoring the network is not able to read the data freely — and therefore, cannot obtain information that should be secured, such as passwords and usernames. I highly recommend using SFTP over FTP if it is available with your hosting provider.

Setting Up FTP on Your Hosting Account

Many web hosts today offer FTP as part of their hosting packages, so just confirm that your hosting provider makes FTP available to you for your account. In Book II, Chapter 1, I mention the hosting account management interface called cPanel. cPanel is by far the most popular hosting account management software used by hosts on the web, eclipsing other popular tools, such as Plesk and NetAdmin. It’s cPanel, or your hosting account management interface, that allows you to set up an FTP account for your website.

tip.eps In this chapter, I use cPanel as the example. If your hosting provider gives you a different interface to work with, the concepts are still the same, but you’ll need to refer to your hosting provider for the specifics to adapt these directions to your specific environment.

Mostly, the FTP for your hosting account is set up automatically. Figure 2-1 shows you the FTP Accounts page in cPanel — follow these steps to get to this page and set up your FTP account:

1. Log in to the cPanel for your hosting account.

Typically, you'll browse to http://yourdomain.com/cpanel to bring up the login screen for your cPanel. Enter your specific hosting account username and password in the login fields and click OK.

2. Browse to the FTP Accounts page.

Click the FTP Accounts link or icon in your cPanel to open the FTP Accounts page shown in Figure 2-1.

3. View the existing FTP account.

If your hosting provider automatically sets you up with an FTP account, you will see it listed in the Account Management section. Ninety-nine percent of the time, the default FTP account uses the same username and password combination as your hosting account or the login information you used to log in to your cPanel in Step 1.

9781118383339-fg020201.tif

Figure 2-1: The FTP Accounts page within cPanel.

If the FTP Accounts page doesn’t display a default FTP user in the Account Management section, you can create one easily in the Add FTP Account section:

1. Type your desired username in the Login field.

This creates the username of username@yourdomain.com (where username is the desired username you typed and yourdomain.com is your specific domain name).

2. Type your desired password in the Password field.

You can choose to type in your own password or click the Password Generator button to have the server generate a secure password for you. Retype the password in the Password (Again) field to validate it.

3. Check the Strength indicator.

The server tells you if your password is Very Weak, Weak, Good, Strong, or Very Strong. (Refer to Figure 2-1.) You want to have a very strong password for your FTP account that’s very hard for hackers and malicious Internet users to guess and crack.

4. (Optional) Type the directory access for this FTP user.

Leaving this field blank gives this new FTP user access to the root level of your hosting account, which, as the site owner, you want. So leave this field blank. (In the future, if you set up FTP accounts for other users, you can lock down their access to your hosting directory by indicating which directory the FTP user has access to.)

5. Indicate the space limitations in the Quota field.

Because you’re the site owner, leave the radio button selection set to Unlimited. (In the future, if you add a new FTP user, you can limit the amount of space, in megabytes [MB], by selecting the radio button to the left of the text field and typing the numeric amount in the text box; for example, 50MB.)

6. Click the Create FTP Account button.

A new screen with a message that the account was created successfully appears. Additionally, the settings for this new FTP account appear, which you should copy and paste into a blank text editor window (such as Notepad for PC, or TextMate for Mac users). The settings for the FTP account are the connection details you need to connect to your web server via FTP.

7. Save the following settings:

FTP Username, Password, and FTP Server are specific to your domain and the information you entered in the preceding steps.

• FTP Username: username@yourdomain.com

• Password: yourpassword

• FTP Server: ftp.yourdomain.com

• FTP Server Port: 21

• Quota: Unlimited MB

tip.eps Ninety-nine point nine percent of the time, the FTP Server Port will be 21. Be sure to double-check your FTP settings to make sure that this is the case.

remember.eps At any time, you can revisit the FTP Accounts page to delete the FTP accounts you’ve created, change the quota, change the password, and find the connection details specific to that account.

Finding and Using Free and Easy FTP Programs

FTP programs are referred to as FTP clients or FTP client software. Whatever you decide to call it, an FTP client is software that you use to connect to your web server to view, open, edit, and transfer files to and from your web server.

Using FTP to transfer files requires an FTP client. Many FTP clients are available for download. Here are some good (and free) ones:

check SmartFTP (PC): www.smartftp.com/download

check FileZilla (PC or Mac): http://sourceforge.net/projects/filezilla

check Cyberduck (PC or Mac): http://cyberduck.ch

check FTP Explorer (PC): www.ftpx.com

In Book II, Chapter 1, you discover how to obtain a hosting account, and in the previous section of this chapter, you discover how to create an FTP account on your web server. By following the steps in the previous section, you also have the FTP username, password, server, and port information you need to connect your FTP client to your web server so you can begin transferring files. In the next section, you discover how to connect to your web hosting account via FTP.

Connecting to the web server via FTP

For the purposes of this chapter, I use the FileZilla FTP client (http://sourceforge.net/projects/filezilla) because it's very easy to use, and the cost is free ninety-nine (that's open source geek-speak for free!).

Figure 2-2 shows a FileZilla client that’s not connected to a server. By default, the left side of the window displays a directory of files and folders on the local computer.

The right side of the window displays content when the FileZilla client is connected to a web server; specifically, it shows directories of the web server’s folders and files.

remember.eps If you use a different FTP client software than FileZilla, the steps and look of the software will differ, and you will need to adapt your steps and practice for the specific FTP client software you’re using.

Connecting to a web server is an easy process. Remember the FTP settings you saved from Step 7 in the previous section? As a reminder, here they are again (these are also the same settings you’ll see in your cPanel FTP Settings page if your FTP was set up automatically for you):

9781118383339-fg020202.tif

Figure 2-2: Mozilla FileZilla FTP client software.

FTP Username: username@yourdomain.com

Password: yourpassword

FTP Server: ftp.yourdomain.com

FTP Server Port: 21

Quota: Unlimited MB

This is where you need that information. To connect to your web server via the FileZilla FTP client, follow these few steps:

1. Open the FTP client software on your local computer.

Locate the program on your computer and click (or double-click) the program icon to launch the program.

2. Choose FileSite Manager to open the Site Manager utility.

The Site Manger utility appears, as shown in Figure 2-3.

9781118383339-fg020203.tif

Figure 2-3: The Site Manager utility in the FileZilla FTP client software.

3. Click the New Site button.

4. Type a name for your site that helps you identify the site.

This site name can be anything you want it to be because it isn’t part of the connection data you add in the next steps. (In Figure 2-4, you see My Site — original, I know.)

5. Enter the FTP server in the Host field.

Host is the same as the FTP server information provided to you when you set up the FTP account on your web server. In the example, the FTP server is ftp.yourdomain.com, so that's entered in the Host field, as shown in Figure 2-4.

6. Enter the FTP port in the Port field.

Typically, in most hosting environments, FTP uses port 21, and this never changes. However, double-check your port number and enter it in the Port field, as shown in Figure 2-4.

7. Select the server type.

FileZilla asks you to select a server type (as do most FTP clients). Choose FTP - File Transfer Protocol from the Protocol drop-down menu, as shown in Figure 2-4.

9781118383339-fg020204.tif

Figure 2-4: FileZilla Site Manager utility with FTP account information filled in.

8. Select the logon type.

FileZilla gives you several different logon types to choose from (as do most FTP clients). Choose Normal from the Logon Type drop-down menu.

9. Enter your username in the Username field.

This is the username given to you in the FTP settings.

10. Type your password in the Password field.

This is the password given to you in the FTP settings.

11. Click the Connect button.

This step connects your computer to your web server. The directory of folders and files from your local computer display on the left side of the FileZilla FTP client window, and the directory of folders and files on your web server display on the right side, as shown in Figure 2-5.

Now you can take advantage of all the tools and features FTP has to offer you!

Transferring files from point A to point B

Now that your local computer is connected to your web server, transferring files between the two couldn’t be easier. Within the FTP client software, you can browse the directories and folders on your local computer on the left side and browse the directories and folders on your web server on the right side.

9781118383339-fg020205.tif

Figure 2-5: FileZilla displays local files on the left and server files on the right.

FTP clients make it easy to transfer files from your computer to your hosting account by using a drag-and-drop method. Two methods of transferring files are

check Uploading: Generally, transferring files from your local computer to your web server. To upload a file from your computer to your web server, click the file you want to transfer from your local computer and drag and drop it onto the right side (the web server side).

check Downloading: Transferring files from your web server to your local computer. To download a file from your web server to your local computer, click the file you want to transfer from your web server and drag and drop it onto to the left side (the local computer side).

tip.eps Downloading files from your web server is a very efficient, easy, and smart way of backing up files to your local computer. It’s always a good idea to keep your files safe, especially things like theme files and plugins, which Books VI and VII cover.

Editing files by using FTP

You will run into situations where you need to edit certain files that live on your web server. You can use the methods described in the preceding section to download a file, open it, edit it, save it, and then upload it back to your web server. That is one way to do it. Another way is to use the built-in edit feature that exists in most FTP client software, by following these steps:

1. Connect the FTP client to your web server.

2. Locate the file you want to edit.

3. Open the file by using the internal FTP editor.

Right-click the file with your mouse and choose View/Edit. (Remember I’m using FileZilla; your FTP client may use different labels, such as Open or Edit.) FileZilla, like most FTP clients, uses a program (such as Notepad for a PC or TextMate for Mac) designated for text editing that already exists on your computer. In some rare cases, your FTP client software may have its own internal text editor.

4. Edit the file to your liking.

5. Save the changes you made to the file.

Click the Save icon or choose File⇒Save.

6. Upload the file to your web server.

After you save the file, FileZilla alerts you that the file has changed and asks whether you want to upload the file to the server. Click the Yes button; the newly edited file replaces the old one.

That’s all there is to it. Use the FTP edit feature to edit, save, and upload files as you need to.

warning_bomb.eps When you edit files by using the FTP edit feature, you’re editing files in a “live” environment, meaning that when you save the changes and upload the file, the changes take effect immediately and affect your live website. For this reason, I strongly recommend downloading a copy of the original file to your local computer before making changes. That way, if you happen to make a typo on the saved file and your website goes haywire, you have a copy of the original to upload to restore it to its original state.

Changing file permissions

Every file and folder on your web server has a set of assigned attributions, called permissions, that tells the web server three things about the folder or file. On a very simplistic level, these permissions include:

check Read: This setting determines whether the file/folder is readable by the web server.

check Write: This setting determines whether the file/folder is writable by the web server.

check Execute: This setting determines whether the file/folder is executable by the web server.

Each set of permissions has a numeric code assigned to it, identifying what type of permissions are assigned to that file or folder. There are a lot of them, so here are the most common ones that you run into when running a WordPress website:

check 644: Files with permissions set to 644 are readable by everyone and writable only by the file/folder owner.

check 755: Files with permissions set to 755 are readable and executable by everyone, but they’re writable only by the file/folder owner.

check 777: Files with permissions set to 777 are readable, writable, and executable by everyone. For security reasons, you should not use this set of permissions on your web server unless absolutely necessary.

Typically, folders and files within your web server are assigned permissions of either 644 or 755. Usually, you'll see PHP files, or files that end with the .php extension, with permissions set to 644 if the web server is configured to use PHP Safe Mode.

tip.eps This is a very basic look at file permissions because, usually, you will not need to mess with file permissions on your web server. In case you do need to dig further, you can find a great reference on file permissions from Elated.com at www.elated.com/articles/understanding-permissions.

You may run across a situation where you’re asked to edit and change the file permissions on a particular file on your web server. With WordPress sites, this usually happens when dealing with plugins or theme files that require files or folders to be writable by the web server. This practice is referred to as CHMOD, an acronym for Change Mode. When someone says, “You need to CHMOD that file to 755,” you’ll know what they are talking about.

Here are some easy steps for using your FTP program to CHMOD a file, or edit its permissions on your web server:

1. Connect the FTP client to your web server.

2. Locate the file you want to CHMOD.

3. Open the file attributes for the file.

Right-click the file on your web server and choose File Permissions. (Your FTP client, if not FileZilla, may use different terminology.)

The Change File Attributes window appears, as shown in Figure 2-6.

4. Type the correct file permissions number in the Numeric Value field.

This is the number assigned to the permissions you want to give the file. Most often, the plugin or theme developer tells you which permissions number to assign to the file or folder; typically, it will be either 644 or 755. (The permissions in Figure 2-6 are assigned the value of 644.)

5. Click OK to save the file.

9781118383339-fg020206.tif

Figure 2-6: The Change File Attributes window in FileZilla.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.82.78