nginx, php, virtual hosts, raspbian stretch, minimal

This is the minimal nginx web server installation with php support.
It is based only on two main paskages nginx and php-fpm.
Since I am in love with virtual host concept so I will do this in virtual host way :)

These are the steps I do on the Raspbian stretch side:
apt -y update

apt -y upgrade

apt -y install php7.0-fpm

apt -y install php7.0-mysql

systemctl status php7.0-fpm

ls -l /etc/nginx/sites-available

find /run -name *fpm.sock*

cat << 'EOF' > /etc/nginx/sites-available/5d61057e5e1f.sn.mynetname.net
server {
server_name 5d61057e5e1f.sn.mynetname.net;
listen 80;
root /var/www/5d61057e5e1f.sn.mynetname.net/;
access_log /var/log/nginx/5d61057e5e1f.sn.mynetname.net.com-access.log;
error_log /var/log/nginx/5d61057e5e1f.sn.mynetname.net-error.log;
index index.php index.html index.htm;
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
EOF

ln -s /etc/nginx/sites-available/5d61057e5e1f.sn.mynetname.net /etc/nginx/sites-enabled/5d61057e5e1f.sn.mynetname.net

mkdir -p /var/www/5d61057e5e1f.sn.mynetname.net

#create php sample file
echo "" > /var/www/5d61057e5e1f.sn.mynetname.net/index.php

#restart config file for php and nginx
systemctl restart php7.0-fpm nginx

vim /etc/nginx/nginx.conf
# server_names_hash_bucket_size 64;

No comments: