ptg You’ll have to ask your system administrator, computer consultant, webmaster, or net- work provider whether a web server is available and, if so, what the procedures are for putting up your pages. You’ll learn more about what to ask later in this lesson. Using a Commercial Web Host You may pay for your Internet access through an Internet service provider (ISP), or a commercial online service. Many of these services allow you to publish your web pages, although it may cost you extra. Restrictions might apply as to the kinds of pages you can publish or whether you can run server-side scripts. You can probably find out more about the web hosting options offered by your Internet service provider on the support section of its website. Many companies that specialize in web hosting have popped up. These services, most commonly known as web hosts, usually provide a way for you to transfer your files to their server (usually FTP or secure FTP), as well as the disk space and the actual web server software that provides access to your files. They also have professional systems administrators onsite to make sure the servers are running well at all times. Generally, you’re charged a flat monthly rate, with added charges if you use too much disk space or network bandwidth. Many web hosts provide support for server-side scripts written in PHP and often install some commonly used scripts so that you don’t even have to set them up. Most also enable you to set up your site with your own domain name, and some even provide a facility for registering domain names, too. These features can make using commercial web hosting providers an especially attractive option. 596 LESSON 20: Putting Your Site Online Make sure that when you register your domains, they are regis- tered in your name rather than in the name of the hosting provider or domain registrar who registers them on your behalf. You want to make sure that you own the domain names you register. To get your own domain name, you need to register it with an authorized registrar. The initial cost to register and acquire your domain name can be as low as $8 per year. Thereafter, an annual fee keeps your domain name active. After you have your own domain name, you can set it up at your hosting provider so that you can use it in your URLs and receive email at that domain. Your site will have an address such as http://www.example.com/. Many ISPs and web hosts can assist you in registering your domain name. You can regis- ter your domain directly with an authorized registrar such as Network Solutions CAUTION Download from www.wowebook.com ptg (http://www.networksolutions.com/), Register.com, dotster.com, or godaddy.com. Most of these services also offer domain parking, a service that allows you to host your domain with them temporarily until you choose a hosting provider or set up your own server. The prices vary, so shop around before registering your domain. Setting Up Your Own Server If you’re really courageous and want the ultimate in web publishing, running your own website is the way to go. You can publish as much as you want and include any kind of content you want. You’ll also be able to use forms, scripts, streaming multimedia, and other options that aren’t available to people who don’t have their own servers. Other web hosts might not let you use these kinds of features. However, running a server definitely isn’t for everyone. There are two options here. The first is to set up an actual computer of your own and use it as a server. However, the cost and maintenance time can be daunting, and you need a level of technical expertise that the average user might not possess. Furthermore, you need some way to connect it to the Internet. Many Internet service providers won’t let you run servers over your connection, and putting your server in a hosting facility or get- ting a full-time Internet connection for your server can be costly. However, this might be the right answer if you are setting up a website for internal use at your company or orga- nization. The second option is to lease a virtual server. Applications exist that enable companies to treat a single computer as multiple virtual computers. They then lease those virtual com- puters to people to use for whatever they like. So for a modest price, you can lease a vir- tual server over which you have full control. From your perspective, it is your computer. Companies such as Slicehost (http://slicehost.com) and Linode (http://linode.com) offer virtual servers, as does Amazon.com through their EC2 service. Free Hosting If you can’t afford to pay a web hosting provider to host your website, some free alterna- tives exist. For the most part, free sites do not offer the opportunity to create your own pages by hand and deploy them. Instead, there are services that host particular kinds of content like weblogs (http://www.blogger.com/), journals (http://www.livejournal.com/), or photos (http://www.flickr.com/). These are just some examples. The trade-off is that the pages on these sites have advertisements included on them and that your bandwidth usage is generally sharply limited. There are often other rules regarding the amount of space you can use, too. Free hosting can be a good option for hobbyists, but if you’re serious about your site, you’ll probably want to host it with a commercial service. How to Find Web Hosting 597 20 Download from www.wowebook.com ptg Organizing Your HTML Files for Publishing After you have access to a web server, you can publish the website you’ve labored so hard to create. Before you actually move it into place on your server, however, it’s important to organize your files. Also, you should have a good idea of what goes where to avoid lost files and broken links. Questions to Ask Your Webmaster The webmaster is the person who runs your web server. This person also might be your system administrator, help desk administrator, or network administrator. Before you can publish your site, you should get several facts from the webmaster about how the server is set up. The following list of questions will help you later in this book when you’re ready to figure out what you can and cannot do with your server: n Where on the server will I put my files? In most cases, someone will create a directory on the server where your files will reside. Know where that directory is and how to gain access to it. n What’s the URL of my top-level directory? This URL will usually be different from the actual path to your files. n What’s the name of the system’s default index file? This file is loaded by default when a URL ends with a directory name. Usually it’s index.html or index.htm, but it may be default.htm, or something else. n Can I run PHP, ASP, or other types of scripts? Depending on your server, the answer to this question may be a flat-out “no,” or you might be limited to certain programs and capabilities. n Do you support special plug-ins or file types? If your site will include multime- dia files (Flash, MP3, MP4 or others), your webmaster might need to configure the server to accommodate those file types. Make sure that the server properly handles special types of files before you create them. n Are there limitations on what or how much I can put up? Some servers restrict pages to specific content (for example, only work-related pages) or restrict the amount of storage you can use. Make sure you understand these restrictions before you publish your content. n Is there a limit to the amount of bandwidth that my site can consume? This is somewhat related to the previous question. Most web hosts allow you to transfer only a certain amount of data over their network over a given period of time before 598 LESSON 20: Putting Your Site Online Download from www.wowebook.com ptg they either cut you off or start charging you more money. You should ask what your bandwidth allotment is and make sure that you have enough to cover the traf- fic you anticipate. (The bandwidth allotment from most web hosts is more than enough for all but the most popular sites.) n Do you provide any canned scripts that I can use for my web pages? If you aren’t keen on writing your own scripts to add advanced features to your pages, ask your service provider whether it provides any scripts that might be of assistance. For example, many ISPs provide a script for creating an email contact form. Others might provide access to form-processing scripts, too. Keeping Your Files Organized with Directories Probably the easiest way to organize your site is to include all the files in a single direc- tory. If you have many extra files—images, for example—you can put them in a subdi- rectory under that main directory. Your goal is to contain all your files in a single place rather than scatter them around. You can then set all the links in those files to be relative to that directory. This makes it easier to move the directory around to different servers without breaking the links. Having a Default Index File and Correct Filenames Web servers usually have a default index file that’s loaded when a URL ends with a directory name rather than a filename. One of the questions you should ask your web- master is, “What’s the name of this default file?” For most web servers, this file is called index.html. Your home page, or top-level index, for each site should have this name so that the server knows which page to send as the default page. Each subdirectory should also have a default file if it contains any HTML files. If you use this default filename, the URL to that page will be shorter because you don’t have to include the actual filename. For example, your URL might be http://www.example.com/pages/ rather than http://www.examplecom/pages/index.html. Organizing Your HTML Files for Publishing 599 20 If you don’t put an index file in a directory, many web servers will enable people to browse the contents of the directory. If you don’t want people to snoop around in your files, you should include an index file or use the web server’s access controls to disable direc- tory browsing. Also, each file should have an appropriate extension indicating its type so the server can map it to the appropriate file type. If you’ve been reading this book in sequential order, CAUTION Download from www.wowebook.com ptg all your files should have this special extension already, and you shouldn’t have any problems. Table 20.1 lists the common file extensions that you should be using for your files and multimedia. TABLE 20.1 Common File Types and Extensions Format Extension HTML .html, .htm ASCII Text .txt GIF .gif JPEG .jpg, .jpeg PNG .png Shockwave Flash .swf WAV Audio .wav MPEG Audio .mp3 MPEG Video .mp4 QuickTime Video .mov Portable Document Format .pdf If you’re using multimedia files on your site that aren’t part of this list, you might need to configure your server to handle that file type. You’ll learn more about this issue later in this lesson. Publishing Your Files Got everything organized? Then all that’s left is to move everything to the server. After your files have been uploaded to a directory that the server exposes on the Web, you’re officially published on the Web. That’s all there is to putting your pages online. Where’s the appropriate spot on the server, however? You should ask your webmaster for this information. Also, you should find out how to access that directory on the server, whether it’s just copying files, using FTP to put them on the server, or using some other method. Moving Files Between Systems If you’re using a web server that has been set up by someone else, usually you’ll have to upload your web files from your system to theirs using FTP, SCP (secure copy), or some other method. Although the HTML markup within your files is completely cross- platform, moving the actual files from one type of system to another sometimes has its drawbacks. In particular, be careful to do the following: 600 LESSON 20: Putting Your Site Online Download from www.wowebook.com ptg n Watch out for filename restrictions—If your server is a PC and you’ve been writ- ing your files on some other system, you might have to rename your files and the links to them to follow the correct file naming conventions. (Moving files you’ve created on a PC to some other system usually isn’t a problem.) Also, watch out if you’re moving files from a Macintosh to other systems. Make sure that your filenames don’t have spaces or other funny characters in them. Keep your filenames as short as possible, use only letters and numbers, and you’ll be fine. n Watch out for uppercase or lowercase sensitivity—Filenames on computers run- ning Microsoft Windows are not case-sensitive. On UNIX and Mac OS X systems, they are. If you develop your pages on a computer running Windows and publish them on a server that has case-sensitive filenames, you must make sure that you have entered the URLs in your links properly. If you’re linking to a file named About.html, on your computer running Windows, about.html would work, but on a UNIX server it would not. n Be aware of carriage returns and line feeds—Different systems use different methods for ending a line. The Macintosh uses carriage returns, UNIX uses line feeds, and DOS uses both. When you move files from one system to another, most of the time the end-of-line characters will be converted appropriately, but some- times they won’t. The characters that aren’t converted can cause your file to come out double spaced or all on a single line when it’s moved to another system. Most of the time, this failure to convert doesn’t matter because browsers ignore spurious returns or line feeds in your HTML files. The existence or absence of either one isn’t terribly important. However, it might be an issue in sections of text that you’ve marked up with <pre>; you might find that your well-formatted text that worked so well on one platform doesn’t come out that way after it’s been moved. If you do have end-of-line problems, you have two options. Many text editors enable you to save ASCII files in a format for another platform. If you know the platform to which you’re moving, you can prepare your files for that platform before moving them. Uploading Your Files In the preceding list of tips about moving files, I mentioned FTP. FTP, short for File Transfer Protocol, is one of the ways to move files from your local computer to the server where they will be published, or to download them so that you can work on them, for that matter. Some other protocols that can be used to transfer files include SFTP (secure FTP), and SCP (secure copy). They all work a bit differently; the most important difference is that SCP and SFTP are encrypted, whereas FTP is not. Publishing Your Files 601 20 Download from www.wowebook.com ptg 602 LESSON 20: Putting Your Site Online If your server provides multiple methods for uploading files, you should choose SCP or SFTP rather than FTP. With FTP, your pass- word for the server will be transmitted unencrypted over the Internet. That’s a security risk. It’s preferable to use the encrypted uploading options. A number of clients support FTP, SCP, and SFTP through the same interface. As long as you have the name of the server, your username, password, and the name of the directory where you want to put your files, you can use any of these clients to upload your web content. One option that’s often available is publishing files through your HTML editing tool. Many popular HTML and text editors have built-in support for FTP, SCP, and SFTP. You should definitely check your tool of choice to see whether it enables you to transfer files using FTP from directly within the application. Some popular tools that provide FTP support include Adobe Dreamweaver, Barebones BBEdit, and HTML-Kit. Text editors such as UltraEdit, Textmate, and jEdit support saving files to a server via FTP, too. If your HTML editor doesn’t support FTP, or if you’re transferring images, multimedia files, or even bunches of HTML files simultaneously, you’ll probably want a dedicated FTP client. A list of some popular choices follows: n CuteFTP (Windows)—http://www.globalscape.com/ n FTP Explorer (Windows)—http://www.ftpx.com/ n FileZilla (Windows, OS X, Linux)—http://filezilla-project.org/ n Cyberduck (OS X)—http://www.cyberduck.ch/ n Transmit (OS X)—http://www.panic.com/transmit/ n Fetch (OS X)—http://fetchsoftworks.com/ All the tools listed support FTP, SFTP, and SCP. How the FTP client is used varies depending on which client you choose, but there are some commonalities among all of them that you can count on (more or less). You’ll start out by configuring a site consist- ing of the hostname of the server where you’ll publish the files, your username and pass- word, and perhaps some other settings that you can leave alone if you’re just getting started. TIP Download from www.wowebook.com ptg Troubleshooting 603 20 If you’re sharing a computer with other people, you probably won’t want to store the password for your account on the server in the FTP client. Make sure that the site is configured so that you have to enter your password every time you connect to the remote site. After you’ve set up your FTP client to connect to your server, you can connect to the site. Depending on your FTP client, you should be able to simply drag files onto the win- dow that shows the list of files on your site to upload them, or drag them from the listing on the server to your local computer to download them. Troubleshooting What happens if you upload all your files to the server and try to display your home page in your browser and something goes wrong? Here’s the first place to look. I Can’t Access the Server If your browser can’t even get to your server, this probably isn’t a problem you can fix. Make sure that you have entered the right server name and that it’s a complete hostname (usually ending in .com, .edu, .net, or some other common suffix). Make sure that you haven’t mistyped your URL and that you’re using the right protocol. If your webmaster told you that your URL included a port number, make sure that you’re including that port number in the URL after the hostname. Also make sure that your network connection is working. Can you get to other URLs? Can you get to the top-level home page for the site itself? If none of these ideas solve the problem, perhaps your server is down or not responding. Call your webmaster to find out whether she can help. I Can’t Access Files What if all your files are showing up as Not Found or Forbidden? First, check your URL. If you’re using a URL with a directory name at the end, try using an actual filename at the end. Double-check the path to your files; remember that the path in the URL might be different from the path on the actual disk. Also, keep case sensitivity in mind. If your file is MyFile.html, make sure that you’re not trying myfile.html or Myfile.html. CAUTION Download from www.wowebook.com ptg If the URL appears to be correct, check the file permissions. On UNIX systems, all your directories should be world-executable, and all your files should be world-readable. You can ensure that all the permissions are correct by using the following commands: chmod 755 filename chmod 755 directoryname 604 LESSON 20: Putting Your Site Online Most FTP clients will allow you to modify file and directory permis- sions remotely. I Can’t Access Images You can get to your HTML files just fine, but all your images are coming up as icons or broken icons? First, make sure that the references to your images are correct. If you’ve used relative pathnames, you shouldn’t have this problem. If you’ve used full pathnames or file URLs, the references to your images may have been broken when you moved the files to the server. (I warned you[el].) In some browsers, you get a pop-up menu when you select an image with the right mouse button. (Hold down the button on a Macintosh mouse.) Choose the View This Image menu item to try to load the image directly. This will give you the URL of the image where the browser thinks it’s supposed to be (which might not be where you think it’s supposed to be). You can often track down strange relative pathname problems this way. If you’re using Internet Explorer for Windows, you can also select the Properties option from the menu that appears when you right-click an image to see its address. You can check the address that appears in the Properties dialog box to see whether it points to the appropriate location. If the references all look good and the images work just fine on your local system, the only other place a problem could have occurred is in transferring the files from one sys- tem to another. My Links Don’t Work If your HTML and image files are working just fine but your links don’t work, you most likely used pathnames for those links that applied only to your local system. For exam- ple, you might have used absolute pathnames or file URLs to refer to the files to which you’re linking. As mentioned for images, if you used relative pathnames and avoided file URLs, you shouldn’t have a problem. TIP Download from www.wowebook.com ptg My Files Are Being Displayed Incorrectly Suppose you have an HTML file or a file in some multimedia format that’s displayed correctly or links just fine on your local system. After you upload the file to the server and try to view it, the browser gives you gobbledygook. For example, it displays the HTML code itself instead of the HTML file, or it displays an image or multimedia file as text. This problem can happen in two cases. The first is that you’re not using the right file extensions for your files. Make sure that you’re using one of the correct file extensions with the correct uppercase and lowercase. The second case is that your server is not properly configured to handle your files. If all your HTML files have extensions of .htm, for example, your server might not understand that .htm is an HTML file. (Most modern servers do, but some older ones don’t.) Or you might be using a newer form of media that your server doesn’t understand. In either case, your server might be using some default content type for your files (usually text/plain), which your browser probably can’t handle. This can happen with server- side scripts, too. If you put up .php files on a server that doesn’t support PHP, the server will often send the scripts to the browser as plain text. To fix this problem, you’ll have to configure your server to handle the file extensions for the correct media. If you’re working with someone else’s server, you’ll have to contact your webmaster and have him set up the server correctly. Your webmaster will need two types of information: the file extensions you’re using and the content type you want him to return. Registering and Advertising Your Web Pages To get people to visit your website, you need to promote it. The more visible your site, the more hits it will attract. A hit is a visit to your website. Be aware that although your site may get, say, 50 hits in a day, that doesn’t necessarily mean that it was visited by 50 different people. It’s just a record of the number of times a copy of your web page has been downloaded. There are many ways to promote your site. You can make sure it’s in search engine indexes, promote your site via social media, put the URL on your business cards, and so much more. The following sections describe each approach. Registering and Advertising Your Web Pages 605 20 Download from www.wowebook.com . any problems. Table 20 .1 lists the common file extensions that you should be using for your files and multimedia. TABLE 20 .1 Common File Types and Extensions Format Extension HTML .html, .htm ASCII. some free alterna- tives exist. For the most part, free sites do not offer the opportunity to create your own pages by hand and deploy them. Instead, there are services that host particular kinds. questions you should ask your web- master is, “What’s the name of this default file?” For most web servers, this file is called index .html. Your home page, or top-level index, for each site should