
Getting the right hardware and network setup for your server is difficult enough. Choosing the right operating system, configuring it, and then maintaining it can be overwhelming. Here are a few tips to get you through the process.
1. If you are on a limited budget, you should definitely consider a free and open source operating system like Linux, FreeBSD, or OpenSolaris.
2. You can support your own server if you have the technical knowledge. Otherwise, you should get a commercial operating system (open source or proprietary) that comes with support.
3. Make sure the OS you choose is one you can live with for a long time. It is never a good idea to change the server OS once the server is live.
4. Think long term. You want an OS that will be stable, updated, and supported for years to come.
5. If you are trying a new OS like Linux for the first time, test it using a virtual machine like Virtualbox. You can learn a lot from it before ever even installing it on your server.
6. Make sure the software and web applications you want to run will be compatible with the server operating system you choose. You do not want to find out that they are not compatible after the fact.
7. Paying more will not necessarily get you better quality. Weigh the pros and cons of features, security, and stability to make your decision.
Photo Source: Flickr

Over the course of the past year, we have covered many dedicated server maintenance issues, particularly for servers running Linux. In no particular order, here is a list of some of the more important tips you should remember when taking care of your server.
1. When possible, rely on the distribution updates and repositories. Only add third-party software when absolutely necessary.
2. Periodically run fsck to check the file system.
3. Monitor system and service logs.
4. Disable unused services.
5. Periodically optimize MySQL databases.
6. Monitor CPU and RAM usage.
7. Optimize RAM and swap usage.
8. On larger servers, run the database server on a separate machine, optimize the servers for scalability, and consider using a CDN (Content Delivery Network).
Photo Source: Flickr

GREP, which stands for global regular expression print, is a sophisticated Linux/Unix tool that can serve many purposes, but one useful purpose on a dedicated server is its ability to search files and directories. With grep you can search within multiple files with relative ease. You can also parse printed screen data to simplify results.
To search a file, just enter “grep” followed by the search term and then the filename. For example, to search the file “httpd.conf” for the word “localhost”, you would type:
grep localhost httpd.conf
To use grep, to simplify printed screen lists, use the following format:
ls -al /usr/bin | grep make
This will list all of the files in the /usr/bin directory, but will only display those files that contain the word “make”. For more in-depth documentation, including use of regular expressions, type “man grep” from the command line.
Photo Source: Wikimedia Commons
Previously, I mentioned some of the benefits of using the “history” command to display any or all of your previous commands. On dedicated servers, whether Linux or Unix, that use “sudo” rather than “su” to become root, it can be aggravating when you type a long command string only to realize you forgot to type “sudo.”
One easy solution is to press the up arrow, move over to the beginning of the string, and add sudo. But there is an even easier way to replay the command with root permissions.
Right after you have entered the command missing sudo, just type the following:
sudo !!
This will automatically run the last command in the shell history with whatever you place before it (in this case “sudo”). It is quick, easy, and gets the job done. In fact, you can use “!!” any time you want to repeat the previous command. Log in to your server via SSH and give it a try.
Photo Source: Wikimedia Commons

Question: How can I easily perform incremental backups on my dedicated server?
Answer: There are few tasks more important than backing up your server. Because of the nature of computers and especially the nature of the Internet, you are bound to have problems. They may or may not cause data loss, but that is not a chance you want to take.
Rsync is a tool that simply syncs the files in one directory with another. What makes it ideal for backups is that 1) it can archive files and compress them and 2) it can use SSH to perform the backups to remote servers.
To run an rsync backup, just execute the command like this:
rsync -avz ~/public_html username@hostname.com:/home/user/backupfiles/
This will backup, archive, and compress the files found in public_html on your server. Finally, it will send those archives to the remote server in the directory specified. The best part about rsync is that, the next time you perform a backup, it will only backup the files that have changed (i.e. incremental backups), saving you bandwidth and time.
YUM is a package management system for Red Hat Enterprise Linux (RHEL), CentOS, Fedora, and other Red Hat-based Linux operating systems. It is command-line driven and is an easy tool you can use to keep your server updated and install any new software you need.
Normally, when you perform updates, YUM will search the distribution’s online repository and select any newly updated packages for download and installation. These may include everything from Apache web server to the Linux kernel itself.
Most of the time, it is a general good practice to update all of the available packages, but there are times when this may not be ideal. For example, if you know for certain that a new version of a particular package that you have installed will not work with a version of one of your web applications, you may want to delay updating until you have patched your application. Another possible scenario is that you may want to update most of your other packages now but wait until later to update the kernel, which will require a reboot.
YUM has a built-in feature that allows you to exclude a package or group of packages of your choosing. You can either use the exclude function on a long-term basis or for one particular update. To make a long-term change, you should edit your repository file (usually yum.conf). Find the [main] section and add the following line:
Continue reading: How to Force YUM to Exclude Certain Packages

Question: How do I remote software that I installed from my Linux dedicated server?
Answer: The answer to that question depends on how you installed the software in the first place. Once you establish how and where the software has been installed, you can determine how to remove it.
1. Package Manager - Most software should be installed with a package manager like YUM or Apt. If that is the case, you remove it with the normal command for the package manager:
yum remove [packagename]
apt-get remove [packagename]
2. Manual Deb, RPM, etc - If you installed a distribution package manually, you can remove it manually or use your package manager to remove it.
3. Binary Archive - If you were given a tar.gz or similar package with binaries inside, and you unpacked them to a directory, simply remove the directory. If the package had an installer program, try using that to uninstall it.
4. Source - If you compiled the software from source and used “make install” to install it, removing it may be more tricky. If you still have the source files, you can simply run “make uninstall”. Otherwise, you will have to find out where the files were installed and remove. They may be in several directories.

Question: One of my Linux system log files has suddenly become very large (several hundred megabytes). What should I do?
Answer: The first thing to find out is what exactly is happening in the log files. To see the latest log activity for your web server error log, for example, you would run:
tail -f /var/log/httpd/error.log
If the file is expanding, you should see errors popping up. When you are finished looking at it, press CTRL-C.
The next step is to fix whatever error you are receiving. If it is enough to fill up several megabytes or even a gigabyte of log space, it is a recurring error that should be fixed. For a web server, repeated failed connections could be some type of denial of service (DoS) attack. For a mail server, numerous open connections could mean that someone is using your server to send spam. The key is to find out exactly what the root cause is and then fix it. If you want to clear the log file, run:
> /var/log/httpd/error.og
Your logs will be back to normal size once your server is running normally again.

Question: My database server is timing out because MySQL seems to hang once it has used up 4GB of RAM, even though the server is equipped with 6GB. How can I make MySQL take advantage of the full 6GB available?
Answer: If your current server setup involves a 32-bit architecture or even just a 32-bit version of your operating system, the short answer is: you cannot. By design MySQL will not be able to use more than 4GB unless it is running on a 64-bit OS.
If you are running Linux, type ” uname -m ” from the command line to see whether or not you are using a 64-bit version. If you know for a fact that your server actually has 64-bit processors, you can reinstall Linux with a 64-bit kernel.
The other less-drastic measure you may be able to take is to install a PAE (Physical Address Extension) kernel, which will allow your server to access physical address space larger than 4 GB. Some distributions, such as CentOS offer PAE kernel packages that you can easily install.
Source: Webhostingtalk.com
Photo: Flickr
Continue reading: How to Increase MySQL Memory Usage Above 4GB
Question: I have a new Linux dedicated server, and I have read a lot of documentation referring to packages. What are Linux packages?
Answer: In Linux distributions, a “package” refers to a compressed file archive containing all of the files that come with a particular application. The files are usually stored in the package according to their relative installation paths on your system. Most packages also contain installation instructions for the OS, as well as a list of any other packages that are dependencies (prerequisites required for installation.
Common types of Linux packages include .deb, .rpm, and .tgz. Since Linux packages do not usually contain the dependencies necessary to install them, many Linux distributions use package managers that automatically read dependencies files and download the packages needed before proceeding with the installation. Some examples of package managers are APT, YUM, and Pacman.
As I mentioned in a previous MySQL post, knowing how to quickly perform database tasks from the command line is a good idea if you are a Linux system administrator. Sometimes, it is the easier way to get things done, especially if you are helping another user and need root access to his or her database.
To delete a table, first login to MySQL:
mysql -u root -p
Enter your password and then switch to the database you want to edit by typing the following at the mysql> prompt:
mysql> use [db name];
Finally, drop the table:
mysql> drop table [table name];
Replace [table name] with the actual name of the table you want to remove.
To remove a row, type:
mysql> DELETE from [table name] where [field name] = 'whatever';
When you are finished, type “quit” to exit.
SSH secure iconSSH stands for Secure Shell and is a secure encrypted method of connecting to a server for shell/command line access. It can be useful for shared hosting, virtual private servers, and dedicated servers. Linux server usually come with SSH enabled by default, although some web hosts may disable it for shared hosting accounts.
To connect to your server via SSH, simply type:
ssh -l(username) hostname_or_ip
It will prompt you for a password. Type your password, and you should be connected. Some web hosts may use a different port for SSH, other than the default port (22). If so, you will need to specify it, for example:
ssh -p 2222 -lmyname webserver.com
Normal Linux/Unix shell commands apply, once you are logged into the server. When you are finished, simply type “exit”.