📜 ⬆️ ⬇️

Deploy Wordpress to VPS with Windows Server 2012. Step-by-Step Guide



Recently, many of our clients have faced various kinds of problems when deploying their site on a virtual server running Windows Server 2012 R2. In this regard, we have decided to write the most detailed guide, in which users can find answers to their questions.

In this guide, we will deploy WordPress on a bunch of IIS + PHP + MySQL, and also give some recommendations on how to configure each of these components. We will do this on RUPS VPS from 2CPU, 2GB RAM, 20GB SSD configuration. So let's get started ...

Install and configure MySQL


First install distributable packages for Visual Studio 2013 ( https://www.microsoft.com/ru-ru/download/details.aspx?id=40784 )
')
Next, download the MySQL installer from here ( mysql-installer-community-5.6.28.0.msi ) and run. We will need to install the server and editor.








Getting Started. MySQL developers recommend using the “Server Machine” configuration type when installing MySQL on a server that will also run a web server. This option primarily affects the amount of memory consumed. We remove the flag from the “Open Firewall port for network access”, since the web server will also be located on this server, and we will work with the database using the MySQL Worbench local visual editor, which we also installed on this server. On the next window, create a user wp. Under this account, our site will work with the database.




On all the following windows, simply click "Next". At the moment, the default settings offered there will suit us.





In the configuration file C: \ ProgramData \ MySQL \ MySQL Server 5.7 \ my.ini, add the bind-address = localhost field in the [mysqld] section so that mysql accepts TCP connections only to the ring interface port.
We restart the MySQL57 service in the services.msc service management snap-in.
Run the command line interpreter (cmd.exe) and execute:

C:\Users\Administrator>sc queryEx MySQL57 && netstat -nao | findstr 3306

SERVICE_NAME: MySQL57
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 1196
FLAGS :
TCP 127.0.0.1:3306 0.0.0.0:0 LISTENING 1196



So, the server is running and listening to the port we need.

Create the db1 database using the MySQL Workbench installed by us :






Done!

Installing IIS + PHP + FastCGI



Install IIS
Now we need to install IIS with the FastCGI module. Open the server control panel and click "Add new roles and features":




Now we need to activate the CGI service (along with the FastCGI module is activated)








Installing PHP5.6



Download php 5.6 ( php-5.6.22-nts-Win32-VC11-x86.zip ). We will use the Non-thread safe version, since FastCGI itself provides single-threaded execution.
Also for php to work correctly, we need the C ++ Redistributable 2012 package ( https://www.microsoft.com/en-us/download/details.aspx?id=30679 ).
We unpack php in the c: \ PHP folder. Next, rename the file php.ini-production in php.ini, open and set the following parameters:

cgi.force_redirect = 0 - , IIS (http://php.net/manual/ru/security.cgi-bin.force-redirect.php)
open_basedir="c:\inetpub\wwwroot\wordpress"; - wordpress
error_log = c:\PHP\php_errors.log - ,
date.timezone = UTC
php_mysqli.dll - wordpress



We check the configuration by running the command line:

php -i


Create a site in IIS



First, we configure a handler for requests to your site.




Now you need to make some adjustments to the FastCGI module.





Set up the default document:





Now create a site in IIS. First remove the Default Web Site.






Our site is ready. But before trying to access it via http, we need to open TCP port 80.
Open the firewall.cpl snap-in and add the appropriate rule for incoming connections:









Rule added!

Next, create a file test.php with the following contents:

 <?php phpinfo(); 


Place this file in the root directory of your site (c: \ inetpub \ wwwroot \ wordpress) and open your “site” in the browser: ip_your_server
Should get something like this:



Remove the test.php file. Now you can finally install Wordpress.

Install Wordpress



Download Wordpress ( wordpress-4.5.2-ru_RU.zip ).
Unpack the archive and copy the contents of the wordpress folder to our root directory (c: \ inetpub \ wwwroot \ wordpress).
Now let's grant the rights to write to the c: \ inetpub \ wwwroot \ wordpress directory and its subdirectories to the IIS_USRS group



Open our website in the browser at ip_ashe_server and go through the installation steps:







Log in and get into CMS Wordpress personal account!



Now open the main page at ip_ashe_server .



Problem solved!

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


All Articles