Top Navigation

WebTech#2: Complete Server Solution

November 26, 2008 from cartab's blog

Hello everyone, this post will be the second in the Abducted by Servers series. In the last post, we went over the main basics of logging-in and doing some basic commands on your server. (http://abduzeedo.com/webtech-1-introduction-servers). In this article we will look at installing and configuring a complete server solution for your VPS/server, including a web-server (Apache), and a popular Database server (Mysql) This article will cover a broad base of topics in a general sense in order to get things up and running.

This article will be based on CentOS, as we got a huge amount of requests to vary the OS, so we'll give it a try on CentOS, however, you may follow this same tutorial for Ubuntu/Debian you may need to do a few adjustments when using apt-get vs yum.

Before we begin lets get a couple of clarifications out of the way. At the time of writing the latest release of CentOS was version 5.2, but this article should apply to any earlier versions without much modification. We will be using the yum package manager rather than installing from source for its ease of use and ability to handle dependencies. Finally, we assume you will be installing from a root-level account.

We'll be installing the latest versions of the following software:

HTTP: Apache with PHP

Database: MySQL

mac_terminal.jpg

Make sure you login! Read WebTech#1 for details

Before we proceed with installing anything let's update our VPS to the latest version:

# yum update

Installing Apache 2 and PHP 5

To install Apache and PHP, run the following command

# yum install httpd httpd-devel php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

Now configure your system to start Apache at boot time:

# chkconfig --levels 235 httpd on

We have to start Apache by hand after installation. To do this, type

# /etc/init.d/httpd start

You will see a warning about ServerName, so let’s go ahead and fix that now. Open the main apache config file:

# nano /etc/httpd/conf/httpd.conf

Hit CTRL+W to bring up the search prompt and type in “ServerName”. Repeat until you find the line of code that says

# ServerName www.example.com:80

Change this line to your hostname or FQDN and take out the pound sign (#) in front of ServerName. Now reload Apache:

# /etc/init.d/httpd reload

Now open a web browser and type in your VPS IP address. If everything went well you should see the default Apache landing page.

Installing MySQL 5

You can install MySQL server, client, and module with the following command:

# yum install mysql mysql-devel mysql-server

MySQL should now be installed. The configuration file is located at: /etc/mysql/my.cnf

Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:

# chkconfig --levels 235 mysqld on
# /etc/init.d/mysqld start

Now we delegate control of MySQL to a user. By default MySQL runs on the root account with no password. Lets password protect the root account:

# mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD(’new-password’) WHERE user=’root’;
mysql> FLUSH PRIVILEGES;

mysql> quit;

Although we have password protected the root account, you must never use it in your production environment. The best practice is to create a user to connect to MySQL. Then restart your MySQL server:

# /etc/init.d/mysqld restart

You should now have a complete installation of Apache and MySQL and should be ready to serve content on the web.

About the author

Carlos Taborda, is Founder and CEO of Webbynode a Hosting Provider for Developers, and StackFu a Social Hub for Server Stacks.

You can follow me on Twitter @cartab.

Sponsored Links:

More articles about:

Comments and Reactions

Featured Tutorial

Realistic Golden Text in Pixelmator
Realistic Golden Text in Pixelmator
In this tutorial I will show you how to create a beautiful golden text in Pixelmator. It might be useful for your next Christmas design. We will use basic tools and gradients to mimic gold with this super easy technique. I also have writen a tutorial showing how to create the same effect but for Photoshop, you can find it at PSDTUTS.

Try this Wallpaper

Wallpaper of the Week #145 by Magomed Dovjenko
Wallpaper of the Week #145 by Magomed Dovjenko
The wallpaper of this week is an image created by Magomed Dovjenko, a very young thought talented illustrator and designer based in Cologne, German. He just updated his portfolio with new work like his "Help Japan" poster.

Book Suggestion

Book Suggestion - Poke the Box
Book Suggestion - Poke the Box
The book of this week is Poke the Box. Written by Seth Godin, Poke the Box is very inspiring and motivating about initiating and shipping. It makes you think about so many things and makes you want to make things happen. If you're stuck at the starting line, you don't need more time or permission. You don’t need to wait for a boss’s okay or to be told to push the button; you just need to poke.