Skip to content

Instantly share code, notes, and snippets.

@anselmdk
Last active January 30, 2017 09:14
Show Gist options
  • Select an option

  • Save anselmdk/3fe36c5fb7c4f59b5d14 to your computer and use it in GitHub Desktop.

Select an option

Save anselmdk/3fe36c5fb7c4f59b5d14 to your computer and use it in GitHub Desktop.
Hosting Cheat Sheet

A collection of notes related to hosting

Apache

Set up a new site

  1. Copy a site from /etc/apache2/sites-available/ and edit it
  2. Enable it by running sudo a2ensite mynewsite
  3. Add your local dns settings: sudo vim /etc/hosts
  4. Restart apache: sudo service apache2 restart

Error log

tail -f /var/log/apache2/error.log

Mysql

Restart

sudo service mysql restart
sudo service mysqld restart
sudo /etc/init.d/mysql restart

Change root password:

mysqladmin -u root password NEWPASSWORD
or:
mysqladmin -u root -p'oldpassword' password newpass

Mysql from the command line

http://www.cyberciti.biz/faq/how-do-i-access-mysql-server-from-the-shell-prompt-command-line/

#Syntax examples
mysql -u {mysql-user} -p {mysql-password} -h {mysql-server}
mysql -u vivek -h mysql10.nixcraft.in -p

show databases;

USE MYDB;
SHOW TABLES;

Rewrites

www to non-www

RewriteEngine On
#rewriting www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Force https

RewriteEngine On
#force https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment