Ever wanted to setup your own web server to host a website or share files with family? Creating a web server is really easy to do and we’ll show you everything you need to get started.
In this tutorial, we’ll install all of the components required for setting up of a web server on a ServerMania server. 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.
See Also: Emby vs Plex – Which is the Better Media Streaming Server?
Why should I use an external server for my web server instead of a computer in my house?
There are many reasons why you should use a ServerMania Hybrid or Dedicated Server to set up your web server instead of setting up a web server at home:
- Cost: It may sound cheaper to use that old computer lying around doing collecting dust, but when you factor in the cost of powering an old computer 24 hours a day, it can get very expensive. A 250W desktop computer running 24 hours per day at 12 cents per KW/h is a whopping $262.00 per year! Not to mention the cost of internet, hardware replacement, etc. It is much cheaper to rent a ServerMania server each month in the long run.
- Reliability: Consumer grade internet and computer hardware are not designed for the stresses of 24×7 usage and connections from around the globe. ServerMania on the other hand, uses enterprise grade hardware and connections to ensure everyone can connect to your server at lightning fast speeds.
- Support: One of the major drawbacks of hosting your own website is that you are responsible for any support issues. With ServerMania, you get 24×7 support included with every server, so you know we’re always here if you need help.
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.
See also: Why Use Linux? 9 Benefits to Consider
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.
See also: What Is PHP.ini – And How Can You Find It?
What You’ll Need
Get started by ordering a ServerMania Hybrid or Dedicated Server.
The system requirements for setting up a personal web server depends on the type of sites you intend to run. The minimum requirements are as follows:
- A ServerMania Hybrid or Dedicated Server
- CentOS 7+
- 512MB RAM
- 2GB Disk Space
Database driven sites may require greater system resources to run effectively.
See Also: (Live Webinar) Meet ServerMania: Transform Your Server Hosting Experience
These instructions will work on Ubuntu / Debian Linux. Commands may vary on other distributions.
Step 1: Connect to root via SSH to your ServerMania server.
Step 2: Install utilities wget, screen, and unzip which are required to execute the installation script:
apt-get -y install wget screen git
Step 3: Download the LAMP installation script from github using wget:
git clone https://github.com/teddysun/lamp.git
Step 4: Change into the lamp-master folder:
Step 5: Set the installation script to be executable:
chmod +x *.sh
Step 6: Open a screen to start the installation process:
screen -S lamp
Step 7: Execute the install script:
Step 8: 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:
service httpd (start|stop|status|restart)
service 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:
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:
You can use the scp command from your local machine to upload files to the directory:
For those looking to setup a web server on Windows Server 2012, Windows Server 2016, or Windows Server 2019, the following steps can be followed.
Step 1: Open the Server Manager
Step 2: Click Manage > Add Roles and Features
Step 3: Click Next
Step 4: Click Next
Step 5: Select the server and click Next
Step 6: Select Web Server and click Next
Step 7: Click Next
Step 8: Click Next
Step 9: Click Next
Step 10: Click Install
Managing the Server
You can now open the IIS Manager. If you click on the Sites link and click Explore, you can view the web root folder and move any site files to this location.
You can then visit your servers primary IP to access your site, or follow the instructions below to point a domain to the server.
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.
You have now setup your web server and can install popular software to your web server, like WordPress, or upload files to the server for download by users.
ServerMania not only supports businesses with technical tutorials, but also through enterprise focused solutions such as colocation and server cluster configurations. For these advanced partnership opportunities, please book a free consultation with our account executives today.
Find out more about ServerMania through our on-demand webinar.
COMPLETE DIGITAL SERVER SOLUTIONS FOR ALL
Bare Metal Dedicated Servers
A single tenant, physical server allowing you full access to its resources.
Professional Hybrid Servers
Virtualized server platform hosted on enterprise-grade physical servers.
Scalable Cloud Servers
High-performance and highly-available infrastructure.Browse servers
Our next-generation data center facilities.
what about windows? IIS, SQL?
windows license cost > Linux
I’ve added a section to the tutorial for you which demonstrates how to setup a web server using Windows Server and IIS!
Hi i have added a record from domain register panel, but its not working.
i put @ and * a record.
Are you following the Linux or windows tutorial? Note that when you set your domain to your domain registrar’s nameservers and set the A record, you then need to allow the records to propagate before the site will be accessible.
I agree that the power consumption is a factor that must be considered, but I think your estimate for the power consumption of a desktop computer just running one website is way too high and the only way to find out the actual consumption is by measuring the consumption using electricity consumption meter like a Spartan.
These are all, of course, average numbers. Each computer would have a different power supply and power consumption requirements. The activities of the computer itself will also impact power usage. A database-driven website being accessed 24 hours a day will use more resources and therefore more power. Furthermore, the actual cost of power will vary by region. But the numbers we have provided are all based on average power consumption of a desktop PC and power cost, so they are not out of the realm of ordinary costs. You may have access to a PC using less power and lower electricity rates, so the actual numbers will always vary.
The only reason we mention these numbers is that we hear people say something along the lines of “I might as well host this on that old Dell I have kicking around, it’s free after all.” But they don’t account for power costs of these older machines running 24 hours a day.
Thanks for your comments!