Skip to content

Instantly share code, notes, and snippets.

@s4wny
Last active October 21, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s4wny/f99a6ee62251212e0f27 to your computer and use it in GitHub Desktop.
Save s4wny/f99a6ee62251212e0f27 to your computer and use it in GitHub Desktop.
Install a ubuntu webserver
sudo apt-get update
##
## NGINX
##
sudo apt-get install nginx -y
##
## MySQL
##
# Will prompt about a password for the user
sudo apt-get install mysql-server -y
sudo mysql_install_db
# Will prompt about:
# - Change pswd?
# - Remove anon usr?
# - Disallow root login remotely?
# - Remove test db?
# - Reload priv?
sudo mysql_secure_installation
##
## PHP
##
sudo apt-get install php5-fpm php5-mysql php5-curl -y
# todo: add extension=curl.so in php.ini
sudo cat > /etc/nginx/sites-available/default <<'EOF'
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name _;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
EOF
sudo service nginx restart
#########################
####### OPTIONAL ########
#########################
##
## Password protect webserver
##
sudo apt-get install apache2-utils -y
# Change 'exampleuser' to whatever you want
sudo htpasswd -c /etc/nginx/.htpasswd exampleuser
# Edit the nginx config file
sudo nano /etc/nginx/sites-available/default
# Add this:
# auth_basic "Restricted";
# auth_basic_user_file /etc/nginx/.htpasswd;
sudo /etc/init.d/nginx reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment