Last active
December 21, 2018 05:43
-
-
Save killtw/10223247 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
if [ -z "$1" ]; then | |
project_name="laravel" | |
else | |
project_name="$1" | |
fi | |
# Add repo for latest stable nginx | |
sudo add-apt-repository -y ppa:nginx/stable | |
sudo apt-get update | |
# Install nginx | |
sudo apt-get install -y nginx | |
echo ">>> Configuring Nginx" | |
# Configure Nginx | |
cat > /etc/nginx/sites-available/$project_name << EOF | |
server { | |
listen 80; | |
root /vagrant/$project_name/public; | |
index index.html index.htm index.php app.php app_dev.php; | |
server_name localhost; | |
access_log /var/log/nginx/vagrant.com-access.log; | |
error_log /var/log/nginx/vagrant.com-error.log error; | |
charset utf-8; | |
location / { | |
try_files \$uri \$uri/ /app.php?\$query_string /index.php?\$query_string; | |
} | |
location = /favicon.ico { log_not_found off; access_log off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
error_page 404 /index.php; | |
include hhvm.conf; | |
# Deny .htaccess file access | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
EOF | |
# Nginx enabling and disabling virtual hosts | |
curl -L https://gist.githubusercontent.com/fideloper/8261546/raw/ngxen > ngxen | |
curl -L https://gist.githubusercontent.com/fideloper/8261546/raw/ngxdis > ngxdis | |
sudo chmod guo+x ngxen ngxdis | |
sudo mv ngxen ngxdis /usr/local/bin | |
# Setup the vhost generator script for nginx | |
# This sould be used for the above setup eventually, rather | |
# than the hard-coded config above! | |
curl -L https://gist.githubusercontent.com/fideloper/9063376/raw/ngxhost.sh > ngxvhost | |
sudo chown root:root ngxvhost | |
sudo chmod guo+x ngxvhost | |
sudo mv ngxvhost /usr/local/bin | |
# Disable "default", enable project_name | |
sudo ngxdis default | |
sudo ngxen $project_name | |
sudo service nginx restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment