Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save singhmohancs/c56abd33d51fb0edb79dfb6e9ae23208 to your computer and use it in GitHub Desktop.
Save singhmohancs/c56abd33d51fb0edb79dfb6e9ae23208 to your computer and use it in GitHub Desktop.
How to set up a subdomain on a Linode server with a Drupal installation and a repository
• SSH to your server to start creating a subdomain (https://library.linode.com/hosting-website#sph_configuring-name-based-virtual-hosts)
• Go to ~/public/
› mkdir -p sub.example.com/{public,log,backup}
› cd sub.example.com/public/
› nano index.html | nano index.php
• Write 'Hello world' or whatever, we just need a html|php file to test with
› sudo nano /etc/apache2/sites-available/sub.example.com
• Paste and edit the following:
# domain: sub.example.com
# public: /home/[user]/public/sub.example.com/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin hello@example.com
ServerName sub.example.com
ServerAlias www.sub.example.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/[user]/public/sub.example.com/public
# Log file locations
LogLevel warn
ErrorLog /home/[user]/public/sub.example.com/log/error.log
CustomLog /home/[user]/public/sub.example.com/log/access.log combined
</VirtualHost>
• Save, then create symbolic link and restart Apache
› sudo a2ensite sub.plur.dk
› sudo service apache2 restart
• Go to https://manager.linode.com/dns/ and log in
• Choose your domain, and create a new A record, fill in hostname and IP
• Wait 15 min for nameserver, check that index.html|php is loaded
› cd ~/public/sub.example.com/public/
› drush dl drupal
› cp -R drupal-7.??/* .
› rm -rf drupal-7.??/
› cd sites/default/
› mkdir files/
› chmod a+w files/
› cp default.settings.php settings.php
› chmod a+w settings.php
• Log in with mysql user and create db (https://library.linode.com/hosting-website#sph_creating-a-database) (http://www.pantz.org/software/mysql/mysqlcommands.html)
› mysql -u root -p (root password needs numbers, special-, lower- and uppercase-characters)
› create database example_projectname_drupal;
› grant all on example_projectname_drupal.* to 'klaus' identified by 'password';
› flush privileges;
› quit;
• Go to site in browser to complete Drupal installation
› chmod a+w settings.php
• Using GitHub or BitBucket? Copy your key and add it on the website
› pbcopy < ~/.ssh/id_rsa.pub
› cd ~/public/sub.example.com/public
› git clone git@github.com:username/git-repo.git
› cp -R git-repo/.git .git
› cp git-repo/.gitignore .
› cp git-repo/README.md .
› git reset --hard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment