How to Quickly Setup Your Own Web Server

In this tutorial, we’ll install all of the components required for setting up of a web server on a tandemservers. This will setup all of the basic components of a web server. If you will be hosting many sites, or want more robust site management, you should install a control panel like cPanel instead.

Components of a Web Server:

There are several major components to setting up a web server: This is often referred to as the LAMP Stack.

Linux: The operating system behind the LAMP stack is Linux. It’s a lightweight and secure OS, making it one of the most popular choices for the best web servers.

Apache: This is the software used to power the HTTP protocol which delivers web content from the server to the web browser.

MySQL: A popular database engine used for database driven websites.

PHP: A popular language of many websites, PHP is required for popular website scripts like WordPress.

Installation Instructions:

Connect to root via SSH to your ServerMania server.

ssh root@IP-Address

Install utilities wget,screen, and unzip which are required to execute the installation script:

yum -y install wget screen unzip

Download the LAMP installation script from github using wget:

wget –no-check-certificate -O lamp.zip https://github.com/teddysun/lamp/archive/master.zip

Unzip the installation files:

unzip lamp.zip

Change into the lamp-master folder:

cd lamp-master

Set the installation script to be executable:

chmod +x *.sh

Open a screen to start the installation process:

screen -S lamp

Execute the install script:

./lamp.sh

Complete the following steps during the install process:

– Choose an apache version. We recommend the latest version listed.
– Select the database you wish to install. We recommend MySQL and selecting the latest version.
– Click enter to use the default MySQL data directory
– Enter a MySQL root password
– Select a PHP version. We recommend selecting the latest version.
– Install any required PHP modules. php-imagick is a good option if you’re not sure what you need.
– Select 1 to install PHPMyAdmin
– Press any key to begin the install process

Managing Web Server Components:

Now that your LAMP stack is installed, you can use these commands to start, stop, and restart components of the web server:

Apache

/etc/init.d/httpd (start|stop|status|restart)

MySQL

/etc/init.d/mysqld (start|stop|status|restart)

Creating a New Site:

Now that the LAMP stack is installed, you can now setup your first website on the web server.

The following command will add a site to your apache configuration file:

lamp add

Follow the steps in the script, providing the domain name and database information (if required).

You can now add files to the directory of your website. The default directory is:

/data/www/domain.com

You can use the scp command from your local machine to upload files to the directory:

Pointing a Domain to the Web Server:

You will need to login to the admin interface at your domain registrar. Our tutorial did not setup any nameservers on the server, so you will need to use an external nameserver provider. Most domain registrars provide this for free.

Simply copy the IP address of your server into the A record of the domain name DNS zone file.

Once you point the A record of the domain to your servers public IP address, the data in this folder will be visible for users in their browser.

Conclusion:

You have now setup your web server. You can now install popular software to your web server like WordPress, or upload files to the server for download by users.