warning: Invalid argument supplied for foreach() in /var/www/vhosts/abduzeedo.com/httpdocs/sites/all/modules/relevant_content/relevant_content_cck/relevant_content_cck.module on line 226.

WebTech#2: Complete Server SolutionListThumbs

WebTech#2: Complete Server Solution

November 26, 2008

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

User picture

I'm Carlos Taborda, I'm a 24 year old Engineer/Developer/Designer from Barranquilla, Colombia @ Miami,FL. I'm the founder of Webbynode, and have a great passion for the Design & (rails & php) Developer Community. You may check out my blog at blog.webbynode.com - I will bring the best things of my world to you guys, so I hope you find it useful in your internet adventures. You may also check our site out at webbynode.com for any vps needs, and follow me on Twitter.

Sponsored Links:

Webbynode Free VPS for Beta Testers!

More content from:

Help us to share this!

3 Comments

AJ Batac11/26/2008

Awesome post for the newbie *nix users out there. Keep this up.

starlight8611/27/2008

thanks for the tips!

Amix12/01/2008

Keep this up. I'll need to start moving my site to a fully dedicated sever pretty soon this is all going to be useful.

Post new comment

The content of this field is kept private and will not be shown publicly.

Icon Ads Wall

  • Openjobs - Oportunidades de Emprego para Profissionais de Talento
  • Zee - Irrezeestível Design Digital
  • Tradd.us - Contextual Translator
  • DesignFlavr, Inspirational Art and Design served daily
  • Signalnoise.com | The art of James White
  • Alberto Seveso - Illustrator
  • Description: Award Winning Portfolio and blog of Web Developer Anthony Woods

Do you want to advertise here?