-
-
Save kraeml/12d0d67bf6fafba2a1187c752d46e093 to your computer and use it in GitHub Desktop.
Raspberry Pi PHP7, Nginx 1.9 Installer
This file contains hidden or 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 | |
| echo "deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi" > /etc/apt/sources.list.d/stretch.list | |
| echo "APT::Default-Release \"jessie\";" > /etc/apt/apt.conf.d/99-default-release | |
| apt-get update -y | |
| apt-get upgrade -y | |
| apt-get dist-upgrade -y | |
| apt-get install -y rpi-update | |
| apt-get install -t stretch -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 -t stretch -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