Last active
September 16, 2024 12:24
-
-
Save Lewiscowles1986/ce14296e3f5222082dbaa088ca1954f7 to your computer and use it in GitHub Desktop.
Raspberry Pi PHP7, Nginx 1.9 Installer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$EUID" -ne 0 ] | |
then echo "Must be root" | |
exit | |
fi | |
apt-get update -y | |
apt-get upgrade -y | |
apt-get dist-upgrade -y | |
apt-get install -y rpi-update | |
apt-get install -y php7.0 php7.0-curl php7.0-gd php7.0-fpm php7.0-cli php7.0-opcache php7.0-mbstring php7.0-xml php7.0-zip | |
apt-get install -y nginx-full | |
update-rc.d nginx defaults | |
update-rc.d php7.0-fpm defaults | |
cat > /etc/nginx/sites-enabled/default << "EOF" | |
# Default server configuration | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/public; | |
index index.html index.htm index.php default.html; | |
server_name _; | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
try_files $uri $uri/ =404; | |
} | |
# pass the PHP scripts to FastCGI server | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php7.0-fpm.sock; | |
} | |
# deny access to .htaccess files, should an Apache document root conflict with nginx | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
EOF | |
mkdir -p /var/www/{public,private,logs,backup,vhosts} | |
echo "<?php phpinfo();" > /var/www/public/index.php | |
chown -R www-data:www-data /var/www | |
chmod -R 775 /var/www | |
usermod -aG www-data pi | |
service nginx restart | |
service php7.0-fpm restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment