Skip to content

Instantly share code, notes, and snippets.

@odan
Last active November 4, 2025 19:55
Show Gist options
  • Select an option

  • Save odan/b5f7de8dfbdbf76bef089776c868fea1 to your computer and use it in GitHub Desktop.

Select an option

Save odan/b5f7de8dfbdbf76bef089776c868fea1 to your computer and use it in GitHub Desktop.

Revisions

  1. odan revised this gist Oct 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nginx-php-windows-setup.md
    Original file line number Diff line number Diff line change
    @@ -97,7 +97,7 @@ default_socket_timeout = 60

    extension=curl
    extension=fileinfo
    extension=gd2
    extension=gd
    extension=gettext
    extension=intl
    extension=mbstring
  2. odan revised this gist Oct 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nginx-php-windows-setup.md
    Original file line number Diff line number Diff line change
    @@ -59,7 +59,7 @@ nginx runs as a standard console application (not a service), and it can be mana

    # Install PHP

    * Download [PHP for Windows](https://windows.php.net/download/) Thread Safe x64: [php-8.0.2-Win32-vs16-x64.zip](https://windows.php.net/downloads/releases/php-8.0.2-Win32-vs16-x64.zip)
    * Download [PHP for Windows](https://windows.php.net/download/) Thread Safe x64: [php-8.3.12-Win32-vs16-x64.zip](https://windows.php.net/downloads/releases/php-8.3.12-Win32-vs16-x64.zip)
    * Extract the ZIP file to: `c:\nginx\php`
    * Make sure that the file `C:\nginx\php\php-cgi.exe` exists.
    * Create a new file: `c:\nginx\php\php.ini` and copy/paste this content:
  3. odan revised this gist Feb 27, 2021. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions nginx-php-windows-setup.md
    Original file line number Diff line number Diff line change
    @@ -135,3 +135,7 @@ To start [PHP with FastCGI](https://www.nginx.com/resources/wiki/start/topics/ex
    * `php-cgi.exe -b 127.0.0.1:9123`
    * Open `http://localhost`
    * You should see the phpinfo page.

    ## XDebug Setup

    * Follow these installation instructions: https://odan.github.io/2020/12/03/xampp-xdebug-setup-php8.html
  4. odan revised this gist Feb 27, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions nginx-php-windows-setup.md
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,7 @@ phpinfo();
    * To start the webserver run:
    * `cd c:\nginx`
    * `start nginx`
    * Allow the windows firwall access
    * Allow the windows firewall access
    * Run the tasklist command-line utility to see nginx processes: `tasklist /fi "imagename eq nginx.exe"`

    nginx runs as a standard console application (not a service), and it can be managed using the following commands:
    @@ -56,7 +56,7 @@ nginx runs as a standard console application (not a service), and it can be mana
    * `nginx -s reload` changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
    * `nginx -s reopen` re-opening log files
    * `taskkill /IM nginx.exe /F` Close all nginx processes
    *

    # Install PHP

    * Download [PHP for Windows](https://windows.php.net/download/) Thread Safe x64: [php-8.0.2-Win32-vs16-x64.zip](https://windows.php.net/downloads/releases/php-8.0.2-Win32-vs16-x64.zip)
  5. odan revised this gist Feb 27, 2021. 1 changed file with 68 additions and 2 deletions.
    70 changes: 68 additions & 2 deletions nginx-php-windows-setup.md
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,6 @@ phpinfo();

    ```


    * To start the webserver run:
    * `cd c:\nginx`
    * `start nginx`
    @@ -63,9 +62,76 @@ nginx runs as a standard console application (not a service), and it can be mana
    * Download [PHP for Windows](https://windows.php.net/download/) Thread Safe x64: [php-8.0.2-Win32-vs16-x64.zip](https://windows.php.net/downloads/releases/php-8.0.2-Win32-vs16-x64.zip)
    * Extract the ZIP file to: `c:\nginx\php`
    * Make sure that the file `C:\nginx\php\php-cgi.exe` exists.
    * Create a new file: `c:\nginx\php\php.ini` and copy/paste this content:

    ```ini
    [PHP]
    engine = On
    short_open_tag = Off
    implicit_flush = Off
    zend.enable_gc = On
    expose_php = Off
    max_execution_time = 30
    max_input_time = 60
    memory_limit = 512M
    error_reporting = E_ALL
    display_errors = On
    display_startup_errors = On
    log_errors = On
    variables_order = "GPCS"
    request_order = "GP"
    register_argc_argv = Off
    auto_globals_jit = On
    post_max_size = 8M
    default_mimetype = "text/html"
    default_charset = "UTF-8"
    include_path = "."
    extension_dir = "c:\nginx\php\ext"
    enable_dl = Off
    file_uploads = On
    upload_max_filesize = 2M
    max_file_uploads = 20
    allow_url_fopen = On
    allow_url_include = Off
    default_socket_timeout = 60

    extension=curl
    extension=fileinfo
    extension=gd2
    extension=gettext
    extension=intl
    extension=mbstring
    extension=mysqli
    extension=openssl
    extension=pdo
    extension=pdo_mysql
    extension=sqlite3

    [Session]
    session.save_handler = files
    session.save_path = "c:\nginx\temp"
    session.use_strict_mode = 0
    session.use_cookies = 1
    session.use_only_cookies = 1
    session.name = PHPSESSID
    session.auto_start = 0
    session.cookie_lifetime = 0
    session.cookie_path = /
    session.cookie_domain =
    session.cookie_httponly =
    session.cookie_samesite =
    session.serialize_handler = php
    session.gc_probability = 1
    session.gc_divisor = 1000
    session.gc_maxlifetime = 1440
    session.cache_limiter = nocache
    session.cache_expire = 180
    session.use_trans_sid = 0
    session.sid_bits_per_character = 5
    ```

    To start [PHP with FastCGI](https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/) run:
    * `cd c:\nginx\php`
    * `php-cgi.exe -b 127.0.0.1:9123`
    * Open `http://localhost`

    * You should see the phpinfo page.
  6. odan revised this gist Feb 27, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion nginx-php-windows-setup.md
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,8 @@ nginx runs as a standard console application (not a service), and it can be mana
    * `nginx -s quit` graceful shutdown
    * `nginx -s reload` changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
    * `nginx -s reopen` re-opening log files

    * `taskkill /IM nginx.exe /F` Close all nginx processes
    *
    # Install PHP

    * Download [PHP for Windows](https://windows.php.net/download/) Thread Safe x64: [php-8.0.2-Win32-vs16-x64.zip](https://windows.php.net/downloads/releases/php-8.0.2-Win32-vs16-x64.zip)
  7. odan revised this gist Feb 27, 2021. 1 changed file with 40 additions and 20 deletions.
    60 changes: 40 additions & 20 deletions nginx-php-windows-setup.md
    Original file line number Diff line number Diff line change
    @@ -6,39 +6,48 @@ For local development you could also use Nginx with PHP as an replacement for XA

    * Download Nginx for Windows: http://nginx.org/en/download.html | Direct: [nginx-1.19.7.zip](http://nginx.org/download/nginx-1.19.7.zip)
    * Extract the ZIP file to `c:\nginx`
    * Create a new sub-directory: `c:\nginx\htdocs`
    *
    * Open the file `c:/nginx/config/nginx.conf` and replace the `server { ... }` section with this configuration:

    ```conf
    server {
    listen 80;
    server_name localhost;
    index index.php;
    error_log c:/nginx/logs/localhost.error.log;
    access_log c:/nginx/logs/localhost.access.log;
    root c:/nginx/htdocs;
    location / {
    try_files $uri /index.php$is_args$args;
    }
    listen 80;
    server_name localhost;
    index index.php;
    error_log c:/nginx/logs/localhost.error.log;
    access_log c:/nginx/logs/localhost.access.log;
    root c:/nginx/html;
    location ~ \.php {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9123;
    location / {
    try_files $uri /index.php$is_args$args;
    }
    location ~ \.php {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9123;
    }
    }
    ```

    * Create a file `c:/nginx/html/index.php` and copy/paste this content:

    ```php
    <?php

    phpinfo();

    ```


    * To start the webserver run:
    * `cd c:\nginx`
    * `start nginx`
    * Allow the windows firwall access
    * Run the tasklist command-line utility to see nginx processes: `tasklist /fi "imagename eq nginx.exe"`

    nginx runs as a standard console application (not a service), and it can be managed using the following commands:
    @@ -48,3 +57,14 @@ nginx runs as a standard console application (not a service), and it can be mana
    * `nginx -s reload` changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
    * `nginx -s reopen` re-opening log files

    # Install PHP

    * Download [PHP for Windows](https://windows.php.net/download/) Thread Safe x64: [php-8.0.2-Win32-vs16-x64.zip](https://windows.php.net/downloads/releases/php-8.0.2-Win32-vs16-x64.zip)
    * Extract the ZIP file to: `c:\nginx\php`
    * Make sure that the file `C:\nginx\php\php-cgi.exe` exists.

    To start [PHP with FastCGI](https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/) run:
    * `cd c:\nginx\php`
    * `php-cgi.exe -b 127.0.0.1:9123`
    * Open `http://localhost`

  8. odan created this gist Feb 27, 2021.
    50 changes: 50 additions & 0 deletions nginx-php-windows-setup.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    # Nginx and PHP Setup on Windows

    For local development you could also use Nginx with PHP as an replacement for XAMPP.

    # Install Nginx

    * Download Nginx for Windows: http://nginx.org/en/download.html | Direct: [nginx-1.19.7.zip](http://nginx.org/download/nginx-1.19.7.zip)
    * Extract the ZIP file to `c:\nginx`
    * Create a new sub-directory: `c:\nginx\htdocs`
    *
    * Open the file `c:/nginx/config/nginx.conf` and replace the `server { ... }` section with this configuration:

    ```conf
    server {
    listen 80;
    server_name localhost;
    index index.php;
    error_log c:/nginx/logs/localhost.error.log;
    access_log c:/nginx/logs/localhost.access.log;
    root c:/nginx/htdocs;
    location / {
    try_files $uri /index.php$is_args$args;
    }
    location ~ \.php {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9123;
    }
    }
    ```

    * To start the webserver run:
    * `cd c:\nginx`
    * `start nginx`
    * Run the tasklist command-line utility to see nginx processes: `tasklist /fi "imagename eq nginx.exe"`

    nginx runs as a standard console application (not a service), and it can be managed using the following commands:

    * `nginx -s stop` fast shutdown
    * `nginx -s quit` graceful shutdown
    * `nginx -s reload` changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
    * `nginx -s reopen` re-opening log files