Home

Language Translator

Hacking Zone

Hacking Tools
Attacking

Configure Windows

Windows Configuration

Mix Tutorials

Asterisk
Website Building

Novels

Mix Novels

Human Personality

Body Language
How to Set up A Web Server in Linux? Print E-mail
Article Index
How to Set up A Web Server in Linux?
Page 2
Page 3
Page 4

How to Set up A Web Server in Linux?

Contributed by Davidlohr Bueso 

              This article teaches you, the reader, how to configure a GNU/Linux based server with three of the most important services that must be provided in a company, at home, a lab or anywhere else, both for clients and internal usage: web, database, mail. So it will be assumed that the idea is to host websites that use certain technologies such as a scripting language and a database (for dynamic sites), and also to act as a mailing tool, for sending and receiving email.

Consider that this article only shows some of the basic features for configuring these services, each program has much more in depth options. Entire books have been written just about Apache or MySQL. So, don't just stay with what you learn here, play around, read, learn; system administration is all about security and performance, so there's a lot more to discover.

 

I have also decided to show some optimization (tuning) techniques for a better performance. We will use only free/open source software in this article, thus,it is not necessary to buy commercial licenses. The software we will use is Debian GNU/Linux, Apache, MySQL, PHP and Postfix. The first three are what is called LAMP, where the P can stand for various server side scripting languages such as PHP, Perl and Python. In general, it represents the open source web platform (both for developing and using it). I have been using LAMP and Postfix for years and must say that, after trying lots of other programs of the same sort, it is the wisest choice if you want a powerful, easy to use/configure/maintain and secure server environment.

Why use Debian? I have always liked this distribution because it's easy to manage packages (programs) and system services. It is also very secure and stable, making it perfect for servers and any system that must run 24/7. It's huge package repository (over 15490) is more than enough to get the best use out of any computer system.

Why use Apache? Simple - it's currently the best, most secure and most used HTTP server. It also supports a huge amount of modules and extensions. Here are some specific benefits of Apache: support, efficiency, portability and customizability.

Why use MySQL? It's logo says it all: The world's most popular open source database. This DBMS is reliable, powerful and easy to manage and use. Also, we will use it with Postfix for better integration and performance.

Why use Postfix? If you ask any systems administrator why he/she uses Postfix as a Mail Transport Agent (MTA) the answer will be it's easy and fast. Another great feature is it's security and the wide amount of operating systems it can run on (BSD, Linux, AIX, Solaris, OSX, etc.)

Installing and Configuring Apache

We will use Apache 2 because it has been rewritten for better performance and security. It brings more out of the box optimizations for scalability and throughput, as opposed to version 1.3 (which is not even being maintained anymore). So let's get to it, we first download and install the essential software:\

apt-get install apache2

This will also install the following packages: apache2, apache2-common,apache2-mpm-worker and apache2-utils. Now, try connecting to localhost:80 and you should see a page saying that Apache as been configured correctly. If not,you might have something wrong with the network settings, but that's a whole different ball game. By default, when installing services in Debian it leaves them configured to start when you boot GNU/Linux so you don't have to worry about further system configuration. For controlling the daemon we have apache2clt or we can use Debian's init utilities:

/etc/init.d/apache2 start|stop|restart|reload|force-reload 
apacheclt start|stop|restart|...

Apache2's configuration files, by default, are in /etc/apache2/. Whenever a configuration is modified, the server must be restarted. Here is a description of some of the more important files and directories:

  • apache2.conf is where the main configuration is, it used to be httpd.conf, so don't be fooled.
  • mods-available/ is the directory with all the modules that are available. The .load contain the Apache directives that are needed to load the modules. And the .conf are the configuration directives for each module.
  • mods-enabled/ is the directory that contains the symbolic links to the modules that we want to enable from mod-available/. At least the .load file must be there, so we will have: /etc/apache2/mod-enabled/modulex.load -> /etc/apache2/mod-available/modulex.load

Let's take this to practice, say we want to enable user directories:

(www.myurl.com/~someuser/). First uncomment the following in apache2.conf:

Next, we create the symbolic links for this module and restart the server:

cd /etc/apache2
ln -s mods-available/userdir.* /etc/apache2/mods-enabled/
/etc/init.d/apache restart

This works for all the modules you want to load. Now let's try some optimization methods. Apache uses a great deal of resources, specially RAM, because it accumulates whatever is necessary to accommodate what it's serving and this process never decreases until it is complete. This takes up as much RAM as the largest dynamic script.

To help reduce this problem, edit apache2.conf and enable KeepAlive (increases time) and set a low value for KeepAliveTimout (this will reduce the time the process waits without doing anything). Also, set the value for MaxRequestsPerChild around 20, depending on the amount of dynamic sites the server is hosting. The idea behind this is that when the process ends, it makes it start over again, but with lower RAM usage. However, by doing this, you might have to increase MaxClients around 50%.


 
Next >
Your Ad Here

RSS socialnet

Add to MyYahoo!
Subscribe in NewsGator Online
Add to Newsburst
Add to Google
Add to My AOL
Add to Pluck
Subscribe in FeedLounge
Add to Windows Live
Add to NetVibes
Subscribe in Rojo
Subscribe in Bloglines
Add to MyMSN
Add to Plusmo for your cellphone
Add to PageFlakes
Add to Technorati
Add to BlinkBits