📜 ⬆️ ⬇️

Windows 2012 R2 + IIS + MS SQL + PHP installation, configuration, pitfalls

I hasten to share the experience of installing and configuring the monsters listed in the title!



Unfortunately, this bunch is not so popular to find something worthwhile on this topic in search engines. But I managed to catch my Zen with fragments and pieces .

In this example, I will use my student benefits. Therefore, the software from Microsoft, I will take the most fresh on the program Dreamspark .
')
So, we will make a task.
1. Install MS SQL Server 2014;
2. Install the “Web Server (IIS)” version 8;
3. Install PHP 5.4.24;
4. And, of course, to make it all work in conjunction on Windows 2012 R2 (I will not, of course, consider installing and preparing the server).

Domain available: test.local

Install and configure MS SQL Server 2014
I decided to complicate this stage only by the fact that we will have a dedicated server with a database. Since in most cases, it is then that the need arises to “tie” IIS + PHP when the base is already “stuffed” with something and moreover, it is located remotely.

Server name: sql.test.local

Installation is extremely primitive, clicking "Next". I had all the components of the instance installed, with the exception of SQL Server Replication. Standard paths are listed.
Your own, named instance “bd” is selected .



Standard service accounts.



"Mixed mode" is selected . The MSsql2014 password for the sa account is set, and the current system user is also added. (Click the Add current user button.



In this way. We have finished installing MS SQL Server 2014.
Now you can create a test database using the included Microsoft SQL Server Management Studio. In this example, the database name is “test” . ( Some data on the screen, such as Server, Connection, Owner, were intentionally erased on the screen, because the original screens from the test site were lost ).



Now we will immediately configure the ability to connect to the current instance “from the outside” (in this example, from the local network).
To do this, we need to open the Sql Server Configuration Manager snap-in. Go to the SQL Server Network Configuration - Protocols for BD section and open the TCP / IP properties. Go to the IP addresses tab and the most important thing to do here is: specify port 1433 (in this example, use the default port) for the required IP address (in this example, the server address with MS SQL 192.168.2.27) and connect to This IP is active. IPv6 and other addresses - you can enable or disable as needed. (Important is noted in the screenshot).



After applying the settings you will receive a notification.
After that we need to choose SQL Server Services. And restart SQL Server (BD).



Stayed the final stage. Create a matching rule in Firewall. Namely, allow incoming connections on port 1433. For a more detailed acquaintance with this process, you can refer to the original manual on msdn .

In my case, the firewall is just turned off. (I do not recommend this practice in any way as a guide to action ).



So, MS SQL server, we have installed and configured for external connections.

Next, we install the Web Server (IIS) role using standard tools.

In the components, we also put a check in the opposite: the .NET Framework 3.5 functions, which includes the .NET 2.0 version (we will need it to install the PHP Manager, just below).

In the components of the IIS itself - just leave everything by default.

But then, perhaps the most important thing. We download and install the Microsooft web platform .
This wonderful tool will help us solve many problems.

The installation is primitive, so I will not describe it in detail.

After launching the web platform, you will be able to install a lot of components. The web platform automatically selects the language based on the installed system. Therefore, I have Russian product names. If you have Windows installed with a different localization - product names may differ!

Heading to the products and choose what we need:

PHP 5.4.9 (at the time of writing, PHP 5.6.0 version was admissible for installation, as well as PHP 5.5.11 version, but unfortunately, as I didn’t dance, it wasn’t possible to get them to work on php-cgi. Possible The reason for this is the lack of drivers in the list).
Together with this product 2 more are automatically delivered:
PhP Manager for IIS is extremely useful and easy to use. (it is for him that the .NET Framework 3.5 \ 2.0 component is required).
Microsoft 3.0 drivers for PhP version 5.4 for SQL Server in IIS (just the very drivers that are not available on the web platform for versions 5.5.11 and 5.6.0



At this primary installation is ready. As it turned out - everything is easy and without problems.

Now you can open PHP Manager in IIS and select the function “Check phpinfo ()” there. Indeed, very comfortable! Here you will be given recommendations on the optimal configuration of PHP, in addition, you can install or remove PHP extensions.



After viewing the phpinfo, making sure that everything works fine, you can create a test script that will check our connection to the database.
Thanks to the "Unknown Soldier" from the sandbox. It was from his article that I borrowed this script.

<?php $serverName = "SQL\BD"; //        .  instance  port ,     $connectionInfo = array("UID" => "sa", "PWD" => "MSsql2014", "Database"=>"test"); //    , UID -  . PWD -        $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established.\n"; } else { echo "Connection could not be established.\n"; die( print_r( sqlsrv_errors(), true)); } /* Close the connection. */ sqlsrv_close( $conn); ?> 


If everything went well and you did not miss anything, then the result of the execution will be:

Connection established.

Otherwise, you will see:

Connection could not be established. And errors resulting from processing.

I hope I have not forgotten anything. And I will be glad if this article is useful to someone!

Used sources
Microsoft Web Platform
Some MSDN
Sandbox article

Source: https://habr.com/ru/post/237105/


All Articles