For local development you could also use Nginx with PHP as an replacement for XAMPP.
- Download Nginx for Windows: http://nginx.org/en/download.html | Direct: nginx-1.19.7.zip
- Extract the ZIP file to
c:\nginx
- Open the file
c:/nginx/config/nginx.conf
and replace theserver { ... }
section with this configuration:
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/html;
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
phpinfo();
- To start the webserver run:
cd c:\nginx
start nginx
- 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:
nginx -s stop
fast shutdownnginx -s quit
graceful shutdownnginx -s reload
changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processesnginx -s reopen
re-opening log filestaskkill /IM nginx.exe /F
Close all nginx processes
- Download PHP for Windows Thread Safe x64: 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:
[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 run:
cd c:\nginx\php
php-cgi.exe -b 127.0.0.1:9123
- Open
http://localhost
- You should see the phpinfo page.
- Follow these installation instructions: https://odan.github.io/2020/12/03/xampp-xdebug-setup-php8.html
Thanks! This was really useful for a quickstart. I ended up combining it with the Batch script from Nginx wiki resource. https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/
Then, I also created a shortcut for the Batch file to start it minimized.