Ubuntu Nginx With PhpFpm Install
I made a bash install script that is more precise and updated which does the same and more it can be found on my git server [ here ]
There are quite a few ways to do this and this is one way.
Note using this configuration the server will not respond when accessing the server by IP address this can be changed however in the file /etc/nginx/sites-available/default
Install And Configure Nginx
apt install -y nginx
Remove unnecessary files and create directories for configuration files code snippets etc.
rm /var/www/html/index.nginx-debian.html rm /etc/nginx/snippets/snakeoil.conf mkdir -p /var/cache/nginx/fcgi
Grap the code snippets this make the nginx configuration files easier to read.
git clone https://git.x-files.dk/webserver/nginx-snippets.git /etc/nginx/nginx-snippets
Install php php-fpm and configure nginx with some standard php modules.
apt install -y php-fpm php-apcu php-curl php-dom php-gd php-imagick php-ldap php-mbstring php-mysql php-pear php-soap php-xml php-zip
Configure Nginx.
curl https://git.x-files.dk/webserver/nginx-snippets/raw/branch/main/nginxconf/nginx.conf > /etc/nginx.conf curl https://git.x-files.dk/webserver/nginx-snippets/raw/branch/main/nginxconf/default > /etc/nginx/sites-available/default
In the file /etc/nginx.conf find this line:
server unix:/var/run/php/phpVERSION-fpm.sock;
And replace it with the verion of php-fpm let's say it's 8.3 then the line should look like this:
server unix:/var/run/php/php8.3-fpm.sock;
Restart nginx and php-fpm
systemctl restart php8.3-fpm && systemctl restart nginx



