Configure web local environment

The first step to prepare before even starting to write a line of code is to set up your environment. Many configurations are of course possible and each programmer has his or her own preferences. However, the instructions below will give you the basics to create a website directly on your machine.

Prerequisites

  • Install a text editor (SublimeText, PHPStorm, Notepad++, etc.)
  • Install local environment (WAMP, MAMP, etc…)

Setting up a local environment

Once you have installed a text editor and your local environment (Example: SublimeText and WAMP), you are ready for development on your machine.

Follow this guide to set up your environment:

  • Create a /myproject directory.
  • Create a file from your text editor; name your file: index.php. (NB: the index is the first file selected by the server in a predefined directory)

Copy a basic HTML code into it. Example :

<!DOCTYPE html>
<html lang="en">
   <head>My project title</head>
   <body>
      <h1>My content</h1>
   </body>
</html>
  • Save the index.php file in your myproject directory.
  • Then copy the myproject directory into the htdocs folder of your MAMP software (WAMP or LAMP). On a PC, this folder can be found in the location pre-defined during installation. It can also be located at the root of the software, which is the case for MAMP.
  • Once the folder is copied, you can open WAMP/MAMP and start the local servers.
  • Now you are ready to see if everything works! To do so, visit http://localhost:8888/myproject. Add after /myproject/my-page-name.php, if you have not named your index.php file. This link is the root of your web page and it is from this URL that you will be able to generate all your subpages.

If the URL you enter returns a 500 error, you probably need to change the port to :8888. Some local servers use :8889 or :8999, and can be customised as well. Example: :8455, 9809, etc… However, it is not recommended to change the port number manually.