Installing the PHP environment - spaceshiptrooper [Style]

Windows Part 2


18.) Click on httpd-2.4.25-win32-VC14.zip or httpd-2.4.25-win64-VC14.zip and browse into it. We’re just basically going to extract the Apache compressed file into our Downloads directory. So once we are in the compressed file, we’re going to click on the Extract option at the top of our File Explorer. It should bring down another option called Extract All. Extract it to the current location that it lists inside the text field. Simply, just leave it as what it has by default. By double clicking on Extract All, it should expand and become the toolbar if you click on any one of those options at the top such as File, Home, Share, View, and Extract. If you click on it once, it’ll bring down a toolbar that will disappear once you click out of it.





19.) Once you are done extracting the Apache directory, you can open up your favorite web browser again and browse back to windows.php.net/download and then download PHP. In this tutorial, we’re going to be using PHP 7.1 as it is the latest version of PHP. So scroll down a little bit to where you can see the download links. REMEMBER, there’s 2 different types for your architecture. There’s a Non Thread Safe and a Thread Safe. Non Thread Safe DOES NOT include a file that we need so REMEMBER to carefully download the THREAD SAFE one. Basically, the Non Thread Safe DOES NOT include php7apache2_4.dll which is what we need in order to load our PHP module. You’ll need to download the correct PHP for your architecture type. This means you’ll need to keep 2 things in mind, 1.) the PHP file you download needs to be the correct one for your architecture type and 2.) it has to be the Thread Safe. So once you have that all figured out, you can click on the Zip link for that appropriate one and save it to your Downloads directory. Then browse to the Downloads directory either by using the File Explorer or clicking on the dropdown list for your Downloads history. If you didn’t save it in your default Downloads directory, again, browse to where you downloaded it to using your File Explorer.




20.) Once you are in your Downloads directory, again, we’re going to extract the PHP compressed file into the Downloads directory. Same steps from the Apache one, we’re going to use for extracting our PHP compressed file. Again, we’re going to click on the Extract option at the top of our File Explorer and then click on Extract All. Then we’re going to leave the location to the default one in the text field again. This will be extracted to our Downloads directory.






21.) We are going to be doing something a little different from the Linux version of this tutorial. We’re going to create our development area first and then we’ll start installing everything. This means that this part of the tutorial will also be placed in the Prepping your system section instead of the Installing Apache section. So if you don’t already have your File Explorer opened. You’ll want to open it. This time, browse to the root of your C:/ drive. This is where we will be storing our development files. I recommend storing it in the root of our C:/ drive because it’s a lot easier to navigate to and it also is a better way for other accounts to access it. If you store the development environment in your own personal document directory or any other personal directory, it’ll be harder for other accounts to access since those accounts will be required to type in a password to access those directories. So this is why I recommend storing the development environment in the root of our C:/ drive to avoid any of these problems.

22.) Right-click on the blank area of our C:/ drive and from the context menu, there should be an option that reads New >. Click on it and then click on Folder. Basically, we’re going to create a new directory within our C:/ drive. Name that directory as dev. This is our development environment directory.


23.) Once you have created the dev directory, browse into it and we’re going to create 3 more directories. The first directory will be called logs. Basically, logs is where our error log is going to be stored. In Windows, everything we create or do has to be done manually. So if we don’t set our error logs, we’re not going to be able to debug anything. By default, Linux stores the error logs inside /var/logs/. So Linux users are lucky. Windows users however have to define it in the php.ini file which we’ll configure in the Installing PHP section. The second directory will be called progs. progs is going to be our programs directory. If you have installed the old PHP installer before, it would have stored it in C:/Program Files/PHP.x. But since the new way of installing PHP is by doing it manually, we’re going to be storing the programs inside the progs directory. This way, we can simply upgrade and downgrade as we wish. I’ll have a short video of an upgrade at the bottom of this post for you to watch and see how easy it is to upgrade. The same step can also be applied to downgrading as well. The third and final directory will be called www. www will be where we will store all of our development projects/ files in.


24.) Browse back to the root of your C:/ drive once you are finished creating the development environment. Now browse into the Windows directory from the root of your C:/ drive. And scroll way down to the System32 directory. Browse into the System32 directory. And scroll a little down or if you can see the directory called drivers, you can click on it. Once you are in the drivers directory, click on the etc directory. Within the etc directory, you should have a file called hosts. The hosts file is by default within the etc directory for both Windows and Linux. The only difference with Windows is that it is stored within multiple directories so you’ll have to go through a few directories to get to it. So in Windows, it’s C:/Windows/System32/drivers/etc/ while in Linux, it’s just /etc/.









25.) Once you have found the hosts file, you can either drag and drop the hosts file into your Desktop or you can copy&paste it there. For this tutorial, we’re going to drag and drop it. We have to copy it to our Desktop because by default, the hosts file CANNOT be modified or edited in the current location it is in. This is only with Windows. In Linux, you can modify the hosts file if you have root permissions. By dragging and dropping the hosts file to our Desktop, we are basically moving the hosts file there. If you cannot drop and drop the hosts file to the Desktop, just copy&paste it. So when we drag and drop the hosts file, Windows will prompt you a message box asking if you want to continue the process. It might also ask you to type in your password so do so if it does. Don’t close out of the File Explorer yet because we’re going to be moving the hosts file back or copying the modified hosts file into the etc directory.




26.) After we have moved or copied the hosts file to our Desktop, open up your favorite Text Editor. I am using Sublime Text 3, but you can use any Text Editor that suits you. Click on File in the top menu and then click on Open File.... Then click on the Desktop menu in the left sidebar. This is an easy way to browse back to your Desktop without actually typing it into the address bar. Our hosts file should appear in the selection. Double click on the hosts file to open it in our Text Editor.


27.) Once we have the hosts file opened, we’ll want to add in our local domain names. Our local domain names could actually exist or not even exist at all. Basically, we’re going to be pointing those domain names to our local IP Address. This means that if the domain that you pick does actually exist, whatever you do to it will not affect the actual domain itself. You’re not actually doing anything to that domain name and you don’t have the rights to it either. We’re just basically pointing the domain name to our local machine so that we can use a domain name to access our localhost environment. In this tutorial, we’re going to be using localhost.com. The actual localhost.com does exist and it doesn’t point to any nameservers at the moment. Anything we do to localhost.com will NOT do or change anything to whatever the actual localhost.com has. Anything we do locally, no one can see. So say for example, we create a local website on the domain name localhost.com. The original author of localhost.com will NOT see our local website nor have anything to do with it.

28.) So the first domain we will be adding in is localhost.com. This is our main domain. Our subdomains will have .localhost.com as its trailing domain name. So for example, we can have a subdomain name called example.localhost.com. The .localhost.com is our trailing domain name and the example part of the domain name is our subdomain name. Anything that is before the second period is our subdomain name. So if we only have one period, that’s our main domain name. So the other three domain names we’ll create are our subdomain names. Those will be phpmyadmin.localhost.com, sample.localhost.com, and test.localhost.com. test.localhost.com will most likely not be used. It’s just a sample subdomain to demonstrate that we can create as many subdomains as we want. We basically create subdomain names based on what the project or directory is about. phpmyadmin.localhost.com is going to be using the PHPMyAdmin application. sample.localhost.com will be used for testing to see if the subdomain names work. So we’ll have to point those domain names to our local IP Address which is 127.0.0.1. If you are done, you should have something similar to the picture below. You don’t necessarily have to use localhost.com. You can use any domain name that you’d like. We’re just using localhost.com for this tutorial.

29.) Once you are done modifying the hosts file. Close out of it and then move or copy the modified hosts file to the etc directory. Again, if you moved the hosts file to the Desktop, you’ll need permission to move it back to the etc directory. I believe you also need permission to paste the modified hosts file into the etc directory as well so this step remains the same for both drag&drop and copy&paste.




2 Likes