Setting Php Mysql Nginx Di Windows Server

Setting PHP MySQL Nginx Di Windows Server


Before you begin installing and configuring PHP, MySQL and Nginx on your Windows Server, there are several prerequisites you need to verify. Firstly, your Windows Server should have IIS, so that your server is configured as a Web server and the necessary IIS components are installed. The components needed to run PHP and MySQL. Additionally, you’ll need to make sure that your server is up-to-date with all the available Windows updates so that the installation and configuration of the components runs smoothly.

When you’re ready, proceed with installing and configuring PHP, MySQL, and Nginx on your Windows Server.

Installing PHP

PHP isn’t installed by default in a Windows Server installation, so first you’ll need to download the installer from the official compilation. When the download is complete, simply run the installer and follow the on-screen instructions to install PHP on your Windows Server.

Once PHP has been installed, you’ll need to configure it to accept requests from Nginx. To do that, you’ll need to open the php.ini file and enable the correct extensions so that the PHP module and Nginx can communicate. Look for the cgi.force_redirect directive and make sure it’s set to 0.

You’ll also need to enable the php_mysql.dll extension as this will allow MySQL to function properly. To enable it, open the php.ini file and look for the extension section. Once you find it, make sure the line for php_mysql.dll is uncommented (delete the semicolon at the beginning of the line).

Installing MySQL

MySQL is the database back end used by PHP applications. To install MySQL on your Windows Server, download and run the installer from the official download page. During the installation, you’ll be asked to configure a few settings like the root password and the default database. Once the installation is complete, you’re ready to move on to the next step.

Installing Nginx

The next step is to install Nginx. This is the web server that will accept requests from clients and serve the results generated by the PHP scripts. To install Nginx, download the installer from the official website and run it. At this point, the installer will ask you to configure a few settings, such as the port that Nginx will listen to and the root directory. Make sure to choose the PHP-FPM as the default configuration for Nginx.

Once the installation is complete, you’ll need to configure Nginx to make it work properly with PHP. To do that, you’ll need to edit the nginx.conf file and add the correct directives. The directives you’ll need to add are:

  • fastcgi_pass;
  • fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  • fastcgi_param SCRIPT_NAME $fastcgi_script_name;

Save the file and Nginx is now properly configured for PHP.

Testing the Setup

Now that all the components are installed and configured, you can test your setup. To do that, create a simple PHP script with the following code:


Save the file in the root directory of your web server (default is C:/inetpub/) and open it in your web browser (http://localhost/filename.php). If the script is executed correctly, you should see a page with information about the configurations of your server.

Concluding the Setup

Once you’ve verified that all the components are working correctly, you can conclude the setup. This means that your PHP, MySQL, and Nginx combination is ready to be used for serving dynamic web pages. Remember to always keep the components up to date so that you don’t encounter any problems in the future.


In conclusion, setting up a LAMP (Linux, Apache, MySQL, PHP) environment on a Windows server is a fairly straightforward task, but it does require a basic understanding of each component and how they interact with each other. With the help of this guide, you should be able to install and configure the components easily so that you can start serving dynamic web pages.


Q: Do I need to install MySQL separately?

A: No. MySQL is the database back-end for PHP and it is included in the installation package. You simply need to configure it during the setup.

Q: Do I need Windows Updates to install PHP?

A: Yes. It is recommended that you keep your Windows Server up-to-date with the latest Windows updates so that the components can install and run properly.

Q: Do I need to configure Nginx for PHP?

A: Yes. You need to edit the nginx.conf file in order to enable the correct directives for PHP to function properly.

Thank you for reading this article. Please read other articles for more information on the subject.

Leave a Reply

Your email address will not be published. Required fields are marked *