search

Note:
1. Only used in Windows 7 environment, date is 2015-8-11, other environments are for reference only.
2. Only provide the simplest configuration


Quick installation and configuration

  • Download the required Nginx version, and decompress (compile and install) to the required directory http://nginx.org/en/download.html
  • Download the required PHP version and unzip (compile and install) it to the required directory http://php.net/downloads.php
  • Find and modify or add the server block of the Nginx configuration file nginx.conf:
<code>server {
        # 替换为需要的端口
        listen       80<span>;</span>
        server_name  localhost<span>;</span>        # 替换为需要的目录
        root   D:/Projects/nginx-html<span>;</span>
        index  index.html index.htm index.php<span>;</span>        location ~ \.php$ {
            include         fastcgi.conf<span>;</span>
            # 连接到本机 PHP FastCGI Server 开启的端口
            fastcgi_pass    127.0.0.1:9001<span>;</span>
        }
    }</code>
  • Add the directory where nginx and php-cgi are located to the Path environment variable
  • Run nginx
  • Enter the following command on the command line to run php-cgi, the port remains with the server block location block fastcgi_passConfiguration is consistent
<code>php<span>-cgi</span><span>-b</span><span>127.0</span><span>.0</span><span>.1</span>:<span>9001</span></code>
  • Create a new index.php file under D:Projectsnginx-html (the directory set by the root of the server block), and write
<code><span><?php </span><span>echo</span><span>"<h1 id="PHP-works">PHP works!</h1>"</span>;</span></code>
  • access the server_name and listen of the server block The configured address and port (for example http://localhost:80/index.php), and seeing "PHP works!" indicates success!

Quickly start, restart, and shut down Nginx service under Windows

    Tool download RunHiddenConsole, and add its storage location to Path
  • Create
  • nginx-start.bat, and write
<code>@echo off
echo Starting php-cgi <span>...</span>
RunHiddenConsole php-cgi -b <span>127.0</span><span>.0</span><span>.1</span>:<span>9001</span>
echo Starting nginx <span>...</span>
c:
cd C:\Program Files\nginx-<span>1.9</span><span>.3</span>
RunHiddenConsole nginx
pause</code>
    New
  • nginx-reload.bat and write
<code>@echo off
echo Reloading Nginx <span>...</span>
c:
cd C:\Program Files\nginx-<span>1.9</span><span>.3</span>
nginx -s reload
pause</code>
    Create new
  • nginx-quit.bat and write
<code>@echo off
echo Closing php-cgi <span>...</span>
taskkill /IM php-cgi.exe
echo Closing nginx <span>...</span>
c:
cd C:\Program Files\nginx-<span>1.9</span><span>.3</span>
nginx -s quit
pause</code>
    Store the above three files to the nginx installation directory
  • Command line input
  • nginx- start, nginx-reload, nginx-quit can quickly start, restart, and shut down Nginx service and php-cgi

Reference:

1. How to correctly configure Nginx+PHP
2. Installation and configuration method of Nginx+PHP5 under Windows

Copyright statement: This article is an original article by the blogger. Please indicate the source when reprinting. Although I don't think there's anything better. . .

The above has introduced the simplest Nginx+PHP, including all aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Optimize PHP Code: Reducing Memory Usage & Execution TimeOptimize PHP Code: Reducing Memory Usage & Execution TimeMay 10, 2025 am 12:04 AM

TooptimizePHPcodeforreducedmemoryusageandexecutiontime,followthesesteps:1)Usereferencesinsteadofcopyinglargedatastructurestoreducememoryconsumption.2)LeveragePHP'sbuilt-infunctionslikearray_mapforfasterexecution.3)Implementcachingmechanisms,suchasAPC

PHP Email: Step-by-Step Sending GuidePHP Email: Step-by-Step Sending GuideMay 09, 2025 am 12:14 AM

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

How to Send Email via PHP: Examples & CodeHow to Send Email via PHP: Examples & CodeMay 09, 2025 am 12:13 AM

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

Advanced PHP Email: Custom Headers & FeaturesAdvanced PHP Email: Custom Headers & FeaturesMay 09, 2025 am 12:13 AM

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Guide to Sending Emails with PHP & SMTPGuide to Sending Emails with PHP & SMTPMay 09, 2025 am 12:06 AM

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!