Setting up a local web server on Windows and Linux

Those into web development would agree with me that having a local web server set up on your own computer is very useful and essential. Especially if you are using a scripting language  such a PHP, then you’ll definitely need a local  server with the PHP interpreter installed.

Secondly, having a local server happens to be very useful during the development process itself. For example, each time you make changes you don’t have to re-upload the file(s) to your online server to see the effects, instead you just have to edit the files containing your codes with your favourite editor such as Dreamweaver or Sublime then save and refresh the page in your browser.

Which web server to use?

The two most popular web servers are Apache and Nginx (engine-x) the latter however, is a bit more difficult to configure and set up than Apache.

Installing the web server

To install a Apache web server on your computer you can head to the official Apache website and download the appropriate version for your OS.

But this way will only get you the httpd web server service so no support for PHP, MySQL nor Perl.

So the easiest way to install all of these services is through a distribution package that contains all of them. Popular examples of these distributions are XAMPP and WAMP with the latter being exclusive to Windows.

Getting Started with XAMPP on Windows

So to install XAMPP on Windows, go to https://www.apachefriends.org/download.html and download the latest version.

Select all the components that you need. Usually all we need is:

  1. Apache (Obviously)
  2. MySQL
  3. PHP
  4. phpMyAdmin

Other components are optional depending on your needs. Click next to get the installation started.

When the installation is completed, open the XAMPP Control Panel and start Apache and MySQL.

Last step: open your favourite web browser and enter http://127.0.0.1 or simply type http://localhost in the address bar.

You will see a page that says “Welcome to XAMPP for Windows…”. If that’s what you got then congratulations you’ve set up a server on your machine.

Getting Started with XAMPP on Linux

To get Apache, MySQL and PHP on your Linux computer, go to https://www.apachefriends.org/download.html and download the latest version of XAMPP for Linux.

After the download is completed, open a Terminal where the downloaded xampp installation file is. For instance if the file is on your Desktop type the following:

cd /home/user/

Don’t forget to replace user with your username.

Now with need to give the .run XAMPP installer file permission to run as a program. We do this by typing:

chmod +x xampp-linux-7.0.2-1-installer.run

Then execute the installer file by type the following:

sudo /home/user/xampp-linux-7.0.2-1-installer.run

 

You need to replace the file name with the version you downloaded (Example xampp-linux-(version number)-installer.run)

Select XAMPP Core Files as component for installation. You can choose to install developer files as well, they contain manuals and other stuffs to get you started.

Press next and proceed to the installation.

Once the installation is  completed, open the XAMPP Control Panel with the following command:

sudo /opt/lampp/manager-linux.run

Start Apache and MySQL from Control Panel

To test if your local server is working properly, open your browser and enter http://127.0.0.1 or http://localhost in the address bar.

The should get a start page saying “Welcome to XAMPP for Linux”.

You are now all set to start developing. 🙂

 

Regards,

Cédric