We are researching the http protocol and building our own http server. This guide build nginx and test it out.

Build php

wget https://www.php.net/distributions/php-8.2.3.tar.xz
tar xvf php-8.2.3.tar.xz
cd php-8.2.3
Mac: ./configure --enable-fpm --prefix=/Users/peter/Downloads/my-php --with-iconv=$(brew --prefix libiconv) --with-mysqli
Linux: ./configure --enable-fpm --prefix=$HOME/Downloads/my-php --with-mysqli

If you in WSL, comment out "#define HAVE_LQ_TCP_INFO 1" from "main/php_config.h"

make -j
make install
cd ..

Build nginx

wget https://nginx.org/download/nginx-1.23.2.tar.gz
tar zxvf nginx-1.23.2.tar.gz
cd nginx-1.23.2
./configure --prefix=$HOME/Downloads/my-nginx
make -j
make install

Make nginx works with php

cd $HOME/Downloads/my-php/etc
cp php-fpm.conf.default php-fpm.conf
cd $HOME/Downloads/my-php/etc/php-fpm.d
cp www.conf.default www.conf
edit www.conf , change to "listen ="
make sure "user = peter" and "group = peter". Remark : "group = peter" is for linux only
create index.php in $HOME/Downloads/my-nginx/html
cd $HOME/Downloads/my-php/sbin
sudo ./php-fpm

configure nginx

cd $HOME/Downloads/my-nginx/conf
edit nginx.conf

2. sudo ../sbin/nginx

To stop php-fpm and nginx:
sudo killall -9 nginx
sudo killall -9 php-fpm

Browse to http://localhost


Install wireshark, remember install ChmodBPF. Open loopback, then you see how nginx talk to php-fpm by port 9876

To enable FCGI, make sure FCGI is enabled by menu “analyze” -> “Enabled Protocols”:

Set the port to 9876, go to “Preference” – > “Protocols” -> “FCGI”, set the port to 9876:

Then filter the protocol by “fcgi”, you can see the captured packet matched with our code