In some our previous articles we learned about how to set up an Ubuntu Linux environment for the website. We also learned about creating the sub domain, install WordPress, install SSL Certificate, install MySQL, install phpMyAdmin and others. In our this and upcoming articles, we are going to learn How to set up our website environment Windows Server 2016.
In this article, we are going to
- How to create a Compute Engine VM Instance for Google Cloud Platform with Windows Server 2016?
- How to install IIS and PHP in Compute Engine VM Instance?
Following are the steps to create a Windows Server 2016 VM Instance
Click on Create button to create a new VM Instance.
For a new VM Instance, select options as shown in the following options. You may change the disk size and ram size. Finally, click on Create button.
Wait for VM to start. Once VM is started access VM using IP Address.
For accessing VM we need to first create a password. For this click on VM to open it. Finally, click on Set Windows Password button.
Copy and save the newly generated password for future use.
Now click on RDP to download RDP Connection file. Double click on RDP file to launch.
Click on Connect Button
Provide password we generated in the above steps.
Finally, we are connected to our Windows Server 2016.
IIS not installed, So first we need to install it.
For Installing IIS Select Add roles and features.
Click on Next
In the next window, select required features you want to install and then Click on Next. We selected
1. Web Server (IIS)
In next window we selected
- .NET Framework 4.6 Features
- .Net Framework 4.6 (Installed)
- Asp .Net (Select It)
Click on Next
In next window we selected
- FTP Server
- FTP Service
- FTP Extensibility
- Application Development
Finally, click on next
On Summary, Click on Install.
Once the installation completed click on Close.
Following are the installation of PHP7 on Windows Server 2016.
- First, download PHP version 7.1 (At the time of writing this article SQL Server driver for PHP 7.2 are not available so we are not going to download PHP 7.2). Visit https://windows.php.net/download#php-7.1. For this article, we are installing VC15 x64 Non Thread Safe (2018-Jan-04 07:06:49). Note for this version of PHP we need to download and install Visual C++ Redistributable for Visual Studio 2015. Download it from https://www.microsoft.com/en-in/download/details.aspx?id=48145
- Once the download is complete, extract zip file. We are extracting the zip file in C drive. You may select a different drive or location. Our extracted files are available in C:/php7
- Now we are going to add permission for IIS on PHP7 folder.
- For this open php7 folder properties.
- Security Tab → Advanced → Edit → Add → Advanced → FInd Now → Scroll and IIS_IUSRS → Click on OK to Add.
- Gave all permissions for IIS_IUSRS. Finally, click on OK to close all open dialogs.
- Before moving to IIS Setup we need to first modify the php.ini file. Open C:\php7 (Path may be varied based on your PHP file location). In php7 folder look for php.ini_production. Rename it to php.ini.
- Open php.ini file in your favorite text editor. Search for ; extension_dir = "./" and replace it with extension_dir = "C:/php7/ext". Note extension path may vary based on your extracted file locations.
- Modify or un-comment following properties in php.ini file.
- Now we are going to enable following extensions. Remove “;” in the fronts of the extension, you want to enable.
- Add PHP in environment path.
- Open Control Panel (Windows + R → Control Panel → System and Security → System → Advance System Settings → Environment Variables → System Variables → Path → Add C:\php7.
- Close all the open dialog by clicking on OK
- To check the above changes. Open Command Prompt and type PHP -version. If everything is fine you are able to see the version of PHP. In this article, we Installed PHP version 7.1. The output for use is
PHP 7.2.1 (cli) (built: Jan 4 2018 04:00:18) ( NTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
- Next, we need to open IIS. I prefer shortcuts so, I am going to open Run and then type INETMGR followed by Enter. It is going to open IIS.
- Click on Handler Mappings
- Click on Add Module Mapping. In the new dialog for Add Module Mapping
- Request path: *.php
- Module: FastCgiModule
- Executable(optional): C:\php7\php-cgi.exe
- Name: FastCGI
- Click on OK. For confirmation dialog box, click on OK
- Go Back or Click on your server name
- Click on Default Documents and index.php
- Now we are going to create a PHP file to display hello, vLemonn! Text. For this run notepad as an administrator. Add “<?php echo “Hello, vLemonn”; ?>” In your new file. Save the file with name hello extension PHP.
- Test your site by visiting http://localhost/hello.php
Our server is ready to host our Web Site.
Next we are going to
- Reserve Static IP for our Server
- Configure our Domain and DNS Entires, Update Name Servers
- Configure our Web Server for Custom Domain
- Add a Sub Domain
- Install SQL Server. Configure SQL Server for Remote Access
- Install PHP Drivers for SQL Server Database
- Install MySQL.
- Install phpMyAdmin.
- Install SSL Certificates.
- Use FTP.