United States (change)
Shortcuts: Downloads Fedora Red Hat Network
Issue #22 August 2006
It seems like everybody's blogging and sharing digital photos online. This booming hobby (and business) sends many people to paid hosting companies to share their thoughts and images. Though many companies are reliable and inexpensive, with a little work and some relatively cheap hardware you can host your own files, save some money, and have complete control over what services are available and how your content is displayed.
You will need a high-speed connection capable of bringing information to your home (downloading) and sending information out to the Internet (uploading). Most DSL and cable connections allow this, but some limit the amount of information that users are allowed to upload. Check with your local provider to see if they have such limits.
The next thing you should think about is a domain name. Your domain name is the name people will use to look up your web pages or to send you email. You will want to register this domain name. There are several services that can help do that. If you're using a dsl connection or a cable modem, you may not have a static network address, so you should look at services from sites like dyndns.org, no-ip.com, or zoneedit.com. Some of these services can also help with domain registration.
Once you have an internet connection and have set up your domain name, the next step is to purchase and set up a home router. This piece of equipment will allow you to share your network connection with several computers. And, importantly, it will also serve as a first line of defense for your home web server. Any good electronics store will have a selection of routers.
Make sure that the model you select fits the following profile:
The last piece of hardware you will need is the actual computer. There a few requirements for the machine:
Now for the details:
Once all the pieces have been assembled, it's time to begin installation.
/boot 100MB / 10240MB swap 2048MB (this should be twice the system memory) /tmp 5120MB /var 133120MB (this is where the majority of your web content will be stored) /var/log 10240MB
manual settings.configure eth0.configure using DHCP.activate on boot.Set SELinux to warn until the installation is complete and all applications have been installed.An "everything" install is not required or recommended for this type of application. You should perform a custom installation, making sure to select the editors, web server, and MySQL (this is the database often used by blogging and photo-sharing applications) packages.
Continue clicking through until the install finishes. The installer should then eject your install disk and automatically reboot your computer.
Once the computer reboots, login with your root password. Now would be a good time to check for updates to your operating system. You can set up a service like RHN to get automatic updates for Red Hat Enterprise Linux, or download Fedora Core package updates from any number of mirrors.
Once updated and rebooted, it's time to configure your services:
system-config-serviceshttpd and mysqld are started and selected to start on boot, then save the service configuration.http://localhost/ (which always points to the web server on your computer). You should see the test page for apache, the web server application.Your web server comes with a basic configuration, but some customization is suggested for optimal performance. Open a terminal window and:
cd /etc/httpd/conf cp httpd.conf httpd.conf.bak
You've made a backup of the stock httpd.conf file. Now edit it with the text editor of your choosing. Make the following changes:
ServerAdmin <add an email address not on this machine> ServerName www.<your domain name>
Save and close the editor. Issue the command:
service httpd restart
This will restart the web server with your changes.
If your Internet provider uses dynamic addresses, then you will need to install an application to track and update your information with your domain provider. This is usually a matter of installing and configuring the application. Doing this will add your router login information as well as your provider login information to the configuration file.
Ddclient is a popular choice for this and works with Dynamic Network Services. You can get the RPM for ddclient via yum. To configure ddclient:
/etc/ddclient/ddclient.conf file and uncomment the section for your routerAs an example:
server=members.dyndns.org login=mylogin password=mypassword myhost.dyndns.org
Finally make sure that the ddclient service is configure to run at start time by issuing the command:
chkconfig --add ddclient 345
/etc/sysconfig/iptables:
-A INPUT -s 192.168.0.0/255.255.255.0 -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT (this line allows only machines on your local network to access the server) -A INPUT -m state --state ESTABLISHED -j ACCEPT (these lines allows existing connections to remain open while changing your firewall rules) -A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p tcp -m tcp --dport 25 -j DROP (this line blocks unauthorized mail connections) -A FORWARD -j RH-Firewall-1-INPUT -A RH-Firewall-1-INPUT -i lo -j ACCEPT (this line allows local network in) -A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type 255 -j ACCEPT -A RH-Firewall-1-INPUT -p esp -j ACCEPT -A RH-Firewall-1-INPUT -p ah -j ACCEPT (these rules allow ipsec connections) -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT (this line allows website traffic to pass) -A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited (this line blocks all other port connection to your computer) COMMIT
The above example assumes your network is on the 192.168 range. If yours is not, adjust the numbers according to your network information. Remember to restart your iptable service afterwards for the change to take effect.
You are finished with your server's installation and configuration. Now it is time to add your content. Perhaps this a photo gallery program, a blog application, or even some simple static web pages. Anything that is going to be available online should be stored in /var/www/html.
Once you have your content in place, the final step in the setup process is to reconfigure your router to allow network traffic access to your web sever. Open up a browser and go to your router's configuration page. Typically this is done by pointing your browser at the IP address of the router (example: 192.168.0.1). Look for the port forwarding section and make sure all http services or port 80 traffic is sent to the IP address of your web server.
If all went well you should now be able to point your browser at www.<yourdomain>, where you should see your home page. You can confirm that things are working by contacting someone not on your local network to see if they can visit your new website.
Now that your web server is up and running, you will want to make sure it stays that way. Continue regularly checking for updates to keep it stable and secure. Because you are allowing outside access, you will want to pay close attention to the activity on your web server.
A transaction record of your web activity is automatically saved in /var/log/httpd. Here you will find four basic files; access_log, error_log, ssl_access_log, and ssl_error_log.
Access_log will show a log of all pages viewed, what type of browser viewed them and from what network address the requests came.
Error_log will show all errors encountered by your website, included pages not found and problems with starting the service.
Ssl_access_log and ssl_error_log record all secure pages, which were not covered in this setup guide.
The numbers at the end of the files indicate older files that are stored as a temporary back-up. These back-up files are automatically overwritten over time.