Last active
March 7, 2016 03:03
-
-
Save triple-j/49378f94f8ae24b0a994 to your computer and use it in GitHub Desktop.
Setup Nginx and PHP on RaspPi
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/sh | |
sudo apt-get install --yes nginx php5-fpm | |
sudo cp /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default-backup-$(date +%s) | |
mkdir --parents /home/$USER/nginx/www | |
echo "server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
root /home/$USER/nginx/www; | |
index index.php index.html index.htm index.nginx-debian.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 listening on 127.0.0.1:9000 | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
# With php5-cgi alone: | |
#fastcgi_pass 127.0.0.1:9000; | |
# With php5-fpm: | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
} | |
}" > /home/$USER/nginx/server.conf | |
cp /var/www/html/index.nginx-debian.html /home/$USER/nginx/www/ | |
echo "<?php echo phpinfo(); ?>" > /home/$USER/nginx/www/info.php | |
sudo ln --force --symbolic /home/$USER/nginx/server.conf /etc/nginx/sites-enabled/default | |
sudo /etc/init.d/nginx start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment