Installing PHP with nginx-server under windows
By: Donald in PHP Tutorials on 2011-03-26
Installing PHP with nginx on Windows involves several steps:
-
Download and install the nginx server: You can download the latest stable version of nginx for Windows from the official website: https://nginx.org/en/download.html. Once downloaded, extract the contents of the archive to a directory of your choice, for example, C:\nginx.
-
Download and install PHP: You can download the latest stable version of PHP for Windows from the official website: https://windows.php.net/download/. Choose the appropriate version of PHP for your system architecture (32-bit or 64-bit) and the required version of VC++ runtime. Once downloaded, extract the contents of the archive to a directory of your choice, for example, C:\php.
-
Configure PHP to work with nginx: Open the PHP installation directory and locate the php.ini-production file. Rename it to php.ini. Edit the php.ini file and make the following changes:
-
Uncomment the following line by removing the semicolon (;) at the beginning: extension_dir = "ext"
-
Add the following lines to the end of the file: fastcgi.impersonate = 1 cgi.fix_pathinfo = 1 cgi.force_redirect = 0
-
-
Configure nginx to work with PHP: Open the nginx configuration file (nginx.conf) located in the conf directory of your nginx installation directory. Add the following lines to the http section of the configuration file:
server { listen 80; server_name localhost; root /path/to/your/web/root; index index.php;
location / { try_files $uri $uri/ /index.php?$query_string; }
location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
Replace /path/to/your/web/root with the actual path to the root directory of your web server, for example, C:\nginx\html.
-
Start the nginx server: Open a command prompt and navigate to the directory where nginx.exe is located, for example, C:\nginx. Run the following command:
nginx.exe
-
Start the PHP FastCGI process: Open another command prompt and navigate to the directory where php-cgi.exe is located, for example, C:\php. Run the following command:
php-cgi.exe -b 127.0.0.1:9000
This will start the PHP FastCGI process and bind it to the local IP address 127.0.0.1 on port 9000.
-
Test your PHP installation: Create a file named info.php in the root directory of your web server with the following content:
<?php phpinfo(); ?>Open your web browser and go to http://localhost/info.php. If everything is set up correctly, you should see the PHP information page.
That's it! You have now successfully installed and configured PHP with nginx on Windows.
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
- Data Science
- Android
- React Native
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Send push notifications using Expo tokens in PHP
PHP convert string to lower case
A Basic Example using PHP in AWS (Amazon Web Services)
Different versions of PHP - History and evolution of PHP
PHP code to write to a CSV file for Microsoft Applications
PHP code to write to a CSV file from MySQL query
PHP code to import from CSV file to MySQL
Password must include both numeric and alphabetic characters - Magento
Resume or Pause File Uploads in PHP
PHP file upload prompts authentication for anonymous users
PHP file upload with IIS on windows XP/2000 etc
Comments