How to add a new user for a new website on your VPS

Step 1:Create an adress for your new website

Go to a free website hosting company and sign up for a site. Or use the account you might already have to add another website. Make sure you link the website to your vps ip adress.

Step 2: Add a new user when logged in as root
sudo adduser newuser
Step 3: Log in as newuser and a a directory public_html

Go to your terminal. Log out as root.

Log in as newuser and open Midnight Commander.

Create on the left side a directory named public_html

Step 4: Adding New Virtual Hosting using Apache

The Apache web server is the most popular way of serving web content on the internet. Each domain that is configured will direct the visitor to a specific directory holding that site’s information, never indicating that the same server is also responsible for other sites.

nano /home/newuser/public_html/index.html

In this file, create a simple HTML document that indicates the site it is connected to. My file looks like this:

<html>
  <head>
    <title>Welcome</title>
  </head>
  <body>
    <h1>This is just a test </h1>
  </body>
</html>

Save and close the file when you are finished.

Use the list command to see what’s under your available apache sites

spicey@voodoo:~$ ls /etc/apache2/sites-available/
 000-default.conf  default-ssl.conf  quincy.conf  voodoospace.conf

Now copy the confguration from an existing site to your new site.

 spicey@voodoo:~$ sudo cp /etc/apache2/sites-available/voodoospace.conf /etc/apache2/sites-available/hamradio.conf

 

sudo nano /etc/apache2/sites-available/newsite.conf
<VirtualHost *:80>
 # The ServerName directive sets the request scheme, hostname and port that
 # the server uses to identify itself. This is used when creating
 # redirection URLs. In the context of virtual hosts, the ServerName
 # specifies what hostname must appear in the request's Host: header to
 # match this virtual host. For the default virtual host (this file) this
 # value is not decisive as it is used as a last resort host regardless.
 # However, you must set it for any further virtual host explicitly.
 ServerName newsite.cloudns.cc

ServerAdmin yourmail@mailer.com
 DocumentRoot /home/username/public_html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
 # error, crit, alert, emerg.
 # It is also possible to configure the loglevel for particular
 # modules, e.g.
 #LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
 # enabled or disabled at a global level, it is possible to
 # include a line for only one particular virtual host. For example the
 # following line enables the CGI configuration for this host only
 # after it has been globally disabled with "a2disconf".
 #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Now you need to enable the virtual host files.
sudo a2ensite newsite.conf

When you are finished, you need to restart Apache to make these changes take effect:

sudo service apache2 restart

 

How to install the newest Ubuntu release using a bootable USB stick

Step 1 – Download the  iso file of the latest Ubuntu release

You can download the Ubuntu iso file directly from the ubuntu website and save it to your computer. Go to http://releases.ubuntu.com.

Choose for the LTS release, which stands for Long Term Support. Download the iso file of the Ubuntu release  and save it to your computer.

Step 2 –  Format your usb stick

First you will have to format your usb stick. You can use the disk utility (installed by default) to format the drive.Search for the application Disks on your computer and start the application.

Step 3 – Create a bootable USB-stick

There are several programs you could use to create a bootable usb stick with ubuntu on it. You could use for example Startup Disk Creator, UNetbootin or rufus. To install Ubuntu on my desktop I chose for Startup Disk Creator.

After opening the application, select the iso-file you just dowloaded and create a bootable usb-stick.

Step 4: Set boot order of the BIOS to USB

Newer computers allow you to enter the BIOS setup pressing one of the keys shown below during the boot process.

F1
F2  
F10 
DEL
ESC

Go to the boot menu and set the boot order on USB.

Step 4: Start your computer with your bootable USB stick

You should see a welcome screen asking you to choose your language and giving you the option to install Ubuntu or try it from the USB stick.

Step 5: Go through the installation menu
  1. Select Download updates while installing Ubuntu.
  2. Select and Install third-party software for graphics and WIFI-hardware, Flash, MP3 and other media. If you are not connected to the internet, you will be asked to select a wireless network, so connect during the installation.
  3. Choose to Install Ubuntu alongside another operating system, delete your existing operating system and replace it with Ubuntu, or — if you’re an advanced user — choose the ’Something else’ option
  4. Select your location
  5. Select your preferred keyboard layout. If you’re not sure, click the ’Detect Keyboard Layout’ button for help.
  6. Enter your login and password details
  7. Wait while the system installs…
  8. Restart your computer

How to enable virtual hosting / sites on your vps

Step 1 – register a domain name.
Step 2 – Start by copying the file for the domain:
newusername@yourvps:~$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/sitename.conf

Open the new file in your editor with root:

newusername@yourvps:~$ sudo nano /etc/apache2/sites-available/sitename.conf

The file will look something like this :

<VirtualHost *:80>

# The ServerName directive sets the request scheme, hostname and port that

# the server uses to identify itself. This is used when creating

# redirection URLs. In the context of virtual hosts, the ServerName

# specifies what hostname must appear in the request's Host: header to

# match this virtual host. For the default virtual host (this file) this

# value is not decisive as it is used as a last resort host regardless.

# However, you must set it for any further virtual host explicitly.

ServerName yourdomainname

ServerAdmin yourname@nomail.com

DocumentRoot /home/newusername/public_html/

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,

# error, crit, alert, emerg.

# It is also possible to configure the loglevel for particular

# modules, e.g.

#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are

# enabled or disabled at a global level, it is possible to

# include a line for only one particular virtual host. For example the

# following line enables the CGI configuration for this host only

# after it has been globally disabled with "a2disconf".

#Include conf-available/serve-cgi-bin.conf

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

As you can see, there’s not much here. We will customize the items here for our first domain and add some additional directives. This virtual host section matches any requests that are made on port 80, the default HTTP port.

First, we need to change the ServerAdmin directive to an email that the site administrator can receive emails through.

ServerAdmin yourname@nomail.com

Uncomment the  ServerName directive, which contains the base domain that should match for this virtual host definition. This will most likely be your domain.

Now that we have created our virtual host file, we must enable it. Apache includes some tools that allow us to do this.

We can use the a2ensite tool to enable each of our sites like this:

newusername@yourvps:~$ sudo a2ensite sitename.conf

When you are finished, you need to reload Apache to make these changes take effect:

newusername@yourvps:~$ sudo service apache2 reload

 

How to add a new user to your vps

Step 1 – Login to your vps with your username
username@desktopname:~$ ssh username@yourvpsip

Enter your password.

Step 2 – Add a new user to the system.

The system automatically chooses for the directory /home

username@yourvps:~$ sudo adduser username
Step 3 – Now logout of the system.
username@yourvps:~$ exit
Step 4 – Login ast the newly created user

Now you log in again , but as the newly created user.

username@desktopname:~$ ssh newusername@yourvpsip
Step 5 – Create a directory public_html

Open Midnight commander and create a directory public_html.

This is where you can put for example your wordpress site.

Step 6 – Give your new user administrator rights

Now you have to give your new user administrator rights.

This you have to do under your username, so first exit

newusername@yourvps:~$ exit

Now log back in with your main username.

username@desktopname:~$ ssh username@yourvpsip

and then use the visudo command

username@yourvps:~$ sudo visudo
Enter your password
 [sudo] password for username:
username@yourvps:~$ exit

Now login with the username you just created.

username@desktopname:~$ ssh newusername@yourvpsip

Now test out if the sudo command is working under your new username.

newusername@yourvps:~$ sudo su
[sudo] password for newusername:
root@yourvps:/home/newusername#

Creating a back up for your wp and forum and restoring it when things go wrong

Make sure you have a folder called public_html, your webserver’s document root. You can create a folder like this using Midnight Commander. In case it’s not there.

 

Step 1 – Creating a back up of your wordpress and forum databases

Go to phpmyadmin:

http://yourvpsip/phpmyadmin

Login as root using your mysql root password.

Click on wordpress and go to export.

It will give you two options:

Export Method:

Maybe it would be wise to start with custom. But I chose for the lazy quick option. Choose sql under format (the default value) and click on the Go button. It will ask you now to save the file as an sql file.

This sql file is the back up of your word press databases.

Repeat this but then for your forum.

Click on it and go to export.

But I chose for the quick option again. Choose sql under format (the default value) and click on the Go button. It will ask you now to save the file as an sql file.

Step 2 – Back up the rest of your wordpress

Open Filezilla

Make sure that on the left side you can see what is on your actual pc, while on the right side your vps is shown.

Now we have to copy all wordpress files from your vps to for example the desktop of your actual pc.

Select all files under the user directory you previously created in /home/username/public_html.

Step 3 – Restore your wordpress html files and database

Open filezilla.

Now you have to copy the wordpress html files from your back up to the location /home/username/public_html

Open phpmyadmin

Click on the logo to see the mainpage.

Go to Users .

Add user.

Choose a user name and select the option local under Host. Then type in a pass word. Select . Don’t touch global privileges.

Now select the database wordpress you just created on the left side by clicking it once.

Then go to Import.

Select your wordpress.sql file on your pc and click on go.

Install wordpress on your VPS

Step 1 – Download WordPress

Download the actual WordPress files from the project’s website.

Luckily, the WordPress team always links the most recent stable version of their software to the same URL, so we can get the most up-to-date version of WordPress by typing this:

cd /home/username/public_html
wget http://wordpress.org/latest.tar.gz

This will download a compressed file that contains the archived directory contents of the WordPress files to our home directory.

We can extract the files to rebuild the WordPress directory we need by typing:

tar -xzvf latest.tar.gz

 

This will create a directory called wordpress in your home directory.

If you want your first page to be your wordpress home page, you will first need to copy all files in the directory wordpress to your public_html directory of your username. You can use midnight commander.

Whjen you have done this, you can just delete the wordpress directory in midnight commander.

While we are downloading things, we should also get a few more packages that we need. We can get these directly from Ubuntu’s default repositories after we update our local package index:

sudo apt-get update
sudo apt-get install php5-gd libssh2-php

This will allow you to work with images and will also allow you to install plugins and update portions of your site using your SSH login credentials.

Step 2 — Configure WordPress

Go the the wordpress configuration page:

http://yourvpsip/wp-config.php

Step Five — Complete Installation through the Web Interface

Now that you have your files in place and your software is configured, you can complete the installation through the web interface.

In your web browser, navigate to your server’s domain name or public IP address:

http://server_domain_name_or_IP

You will see the WordPress initial configuration page, where you will create an initial administrator account:

Wordpress initial config

Fill out the information for the site and the administrative account you wish to make. When you are finished, click on the install button at the bottom.

WordPress will confirm the installation, and then ask you to log in with the account you just created:

WordPress confirm install

Hit the button at the bottom and then fill out your account information:

WordPress login

You will be presented with the WordPress interface:

WordPress admin interface

Configuring your webserver (Apache2)

This manual explains how you can serve web pages from out your ‘home user directories’. Not only is this safer, it is also easier to add or delete websites.

Step 1 – Enable the ‘userdir module’ in Apache2

Apache2 has a built in ‘userdir module’. Enable it by using the following command:

username@vpshostname:~$ sudo a2enmod userdir
Step 2 – Create a directory called ‘public_html’

Now you can create a directory called ‘public_html’ and serve your webpages to the world from there.

This you can do using the mkdir command or by using mc.

username@vpshostname:~$ mkdir public_html
Step 3 – Switch on PHP support in user directories

Edit your apache2 configuration as follows:

username@vpshostname:~$ sudo nano /etc/apache2/mods-available/php5.conf

Now you need to comment out a few lines from <IfModule mod_userdir.c> to the next </IfModule> so that the result looks like this:

# Running PHP scripts in user directories is disabled by default
#
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
#<IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_flag engine Off
# </Directory>
#</IfModule>

Restart the Apache webserver by using the following command:

username@vpshostname:~$ sudo service apache2 restart

And you should now be able to create php pages within your /home/username/public_html/ directory and serve them to the world (you can easily test this by placing our info.php file of earlier, into your /home/username/public_html/ directory, and then visit http://your vpsip/~username )

Step 4 – Install PHPMyAdmin

An easy way to work with mysql is through a GUI (Graphical User Interface), like the application PHPMyAdmin.

Install phpmyadmin on Ubuntu using the following command:

username@vpshostname:~$ sudo apt-get install phpmyadmin

During Installation a few pop-ups might appear, which have configuration questions for you to answer, for example:

For which webserver is phpmyadmin going to be configured? the answer is apache2 ofcourse

Next it will ask configure database for phpmyadmin with dbconfig-common? answer yes here.

Then it will ask the password for the mysql administrator user, use the mysql-password which you earlier specified during the installation of the LAMP-server here.

At last, it’ll ask for a phpmyadmin application password for mysql so make one up (this is a password which phpmyadmin will use to create a database of it’s own)

Step 5 – Configure your webserver

Phpmyadmin is now installed, but it can’t work in combination with your webserver yet, untill you configure it to do so:

username@vpshostname:~$ sudo nano /etc/apache2/apache2.conf

and add this code to the end of the config file:

Include /etc/phpmyadmin/apache.conf

Next we restart the server again with:

username@vpshostname:~$ sudo service apache2 restart

And when we now visit http://yourvpsip/phpmyadmin/

We should be greeted with the login screen of phpmyadmin, and you can now login as root, with your mysql administration password of earlier, to create and manage your databases.

How to install a VPS with Ubuntu Server 14.04

What is a VPS?

A virtual private server (VPS) is a virtual machine sold as a service by an Internet hosting service.

A VPS runs its own copy of an operating system, and customers have superuser-level access to that operating system instance, so they can install almost any software that runs on that OS.

You can use your VPS to create websites, fora, run an IRC server and so on.

Step 1 -Find yourself a good hosting company
Create an account

You will notice the hosting company has a client area where you can login with your client name and password and a user area. Here you can create a VPS.

Login as user

Under the section cd-rom  choose for Ubuntu Server 14.04 LTS. Now mount it by clicking the mount button.

Then you reboot your vps.Just click on the reboot button. As you can see you can reboot your vps , shut it down, boot it or reinstall it.

Make a remote desktop connection with your VPS

Go to the VNC viewer your hosting company uses to make a remote desktop connection with your VPS.

I had three options: html5 ssl, html5 and java vnc client

I chose for the java script based vnc client. I chose for the last one because the other two options didn’t work.

Step 2 – Installing Ubuntu 14.04 on your VPS

When you see the text Ubuntu 14.04 you hit F3 to enter the key map. Then choose for ‘Install Ubuntu Server’.

Now you will be asked a couple of questions that have to do with the installation language , your location and others. After these questions are answered things like the name of your VPS and your user name and password will be asked.

Partitioning your harddrive

Now you will be asked to partition your hard drive .

Make sure that you don’t install your operating system next to previously used operating systems.

Choose for the manual partitioning of your hard drive.

First remove all visible partitions by highlighting them , enter and then choose for deleting the partition. Now go to the free space, and create a new partition of for example 50 Gb. Type for the new partition primary. Change bootable flag to ‘on’. Go to done setting up the partition.

Now you will have to create a new partition on what is leftover after using the 50 Gb of this example for the primary (root- / ) partition. You will save this partition as swap partition. Choose for done setting up the partition.

Check the overview of your current partitions. You should have a root partition now and a swap partition.Choose for finish partitions and save changes to disk.

Automatic updates

You will now be asked how you want to manage security upgrades of your system.

Choose for automatic updates.

Add options to the core of your system

Now you will be asked what you want to add to the core of your system.

Make sure you choose for openSSH and LAMP . Use the space bar to select them.

Install the GRUB boot loader to the master boot record

GRUB is a boot program of Linux. (Lilo is another one, but is older and has less options) GRUB makes you boot your version of linux.

Finish the installation. Now you will automatically be redirected to the installation menu.

Close it.

Unmount your Ubuntu version

Don’t forget to unmount your chosen version of Ubuntu 14.04, which is basically the same as making your pc throw the installation disk out.

You do this in the user control panel of your VPS.

Now your system will need a reboot.

So click on the reboot button of your VPS.

Login to your vps

Now you can login to your VPS through the terminal.

ssh username @yourvpsip
Testing if php is working

Go to your webserver’s document root.In our case this was/home/username/public_html‘

cd /home/username/public_html

And create a file called ‘info.php’ by using the command:

sudo nano

After that you put this piece of text in your nano editor:

<?php
phpinfo();
?>

After that you press ctrl+x to save it as ‘info.php’ and exit.

When you now visit http://localhost/info.php , you should be presented with a nice information page about your current php installation and setup.

 

How to get started with Raspberry Pi

NOOBS (New Out Of the Box Software) is an easy operating system install manager for the Raspberry Pi.

Step 1 – Format your SD card with Gparted

It is best to format your SD card before copying the NOOBS files onto it. To do this:

First remove all other hardware from you computer.

Open Synaptic and search for Gparted.This is a program to edit partitions with. Remove all partitions on your SD card.

Make a new partition and save it in fat32 format. You don’t have to change anything, just use the default settings for your version of ubuntu.

Step 2 – Copy and paste NOOBS files to your SD card

Once your SD card has been formatted, unzip the NOOBS file and extract it. Copy  all the files in the extracted NOOBS folder and paste them into the SD card drive.Remove the SD card and insert it into your Raspberry Pi.

Step 3 – First boot

Plug in your keyboard, mouse and monitor  cables.

Now plug in the USB power cable to your Pi.

Your Raspberry Pi will boot, and a window will appear with a list of different operating systems that you can install. Choose fe Raspbian and click on Install.

Raspbian will then run through its installation process. Note this can take a while.

When the install process has completed, the Raspberry Pi configuration menu (raspi-config) will load. Here you are able to set the time and date for your region and enable a Raspberry Pi camera board, or even create users. You can exit this menu by using Tab on your keyboard to move to Finish.

Step 4 – Logging in

The default login for Raspbian is username pi with the password raspberry. Note you will not see any writing appear when you type the password. This is a security feature in Linux.

Step 5 – Accessing the graphical user interface

To load the graphical user interface type startx.

How to install Simple Machines Forum (SMF) on your VPS

Make sure a LAMP stack was installed while installing your vps.

Step 1- Setup the SMF database and obtain SMF files

Open phpmyadmin.

Create a new user.

Go to Users.

Add user.

Choose a user name fe smf and select the option local under Host. Then type in a pass word. Select . Don’t touch global privileges. Click on go

You will then need to obtain the latest SMF package from Simple Machines and extract the files into your web server’s directory. The commands below extract the files into the root web directory (/home/username/public_html)

First create a directory called forum in the folder public_html with mc.

Now open this new directory.

cd /home/username/public_html/forum

Use the program wget to download from the internet the latest version of SMF. The latest current version is 2.0.8 at the time of writing.

Make sure you check the latest version.

wget http://mirror.ord.simplemachines.org/index.php/smf_2-0-8_install.tar.gz

Extract the files.

tar xvfz smf_2-0-8_install.tar.gz

Now remove the installation file with the command rm (remove).

rm -rf smf_2-0-8_install.tar.gz
Step 2 – Go through the steps of the Installer.

Once the SMF files have been extracted and permissions changed, navigate to the directory forum in your web browser.

 

http://yourvpsip/~username/forum

Checking Files are Writable

Some files need to be writable for SMF to work properly. This step allows you to let the installer make them writable for you. However, in some cases it won’t work – in that case, please make the following files 777 (writable, 755 on some hosts):

  • attachments
  • avatars
  • cache
  • Packages
  • Packages/installed.list
  • Smileys
  • Themes
  • agreement.txt
  • Settings.php
  • Settings_bak.php

Go to terminal.

Use chmod change mode.

spicey@voodoo:~/public_html/forum$ chmod 777 ./attachments/
spicey@voodoo:~/public_html/forum$ chmod 777 ./avatars/
spicey@voodoo:~/public_html/forum$ chmod 777 ./cache
spicey@voodoo:~/public_html/forum$ chmod 777 ./Packages
spicey@voodoo:~/public_html/forum$ chmod 777 ./Packages/installed.list

spicey@voodoo:~/public_html/forum$ chmod 777 ./Smileys
spicey@voodoo:~/public_html/forum$ chmod 777 ./agreement.txt
spicey@voodoo:~/public_html/forum$ chmod 777 ./Settings.php
spicey@voodoo:~/public_html/forum$ chmod 777 ./Settings_bak.php

Now go back to the smf installer. Continue.

Database Server Settings
These are the settings to use for your database server. If you don’t know the values, you should ask your host what they are.

This is nearly always localhost – so if you don’t know, try localhost.

Fill in the username you need to connect to your database here.
If you don’t know what it is, try the username of your ftp account, most of the time they are the same.

Here, put the password you need to connect to your database.
If you don’t know this, you should try the password to your ftp account.

Fill in the name of the database you want to use for SMF to store its data in. If this database does not exist, this installer will try to create it.

The prefix for every table in the database. Do not install two forums with the same prefix!
This value allows for multiple installations in one database.
Now click on continue.
Forum Settings
This page requires you to define a few key settings for your forum. SMF has automatically detected key settings for you.

This is the name of your forum, ie. “The Testing Forum”.

This is the URL to your forum without the trailing ‘/’!.
In most cases, you can leave the default value in this box alone – it is usually right.
Gzip Output:

This function does not work properly on all servers, but can save you a lot of bandwidth.
Click here to test it. (it should just say “PASS”.)
Database Sessions:

This feature is almost always for the best, as it makes sessions more dependable.
UTF-8 Character Set:

This feature lets both the database and the forum use an international character set, UTF-8. This can be useful when working with multiple languages that use different character sets.
Allow Stat Collection:

If enabled, this will allow Simple Machines to visit your site once a month to collect basic statistics. This will help us make decisions as to which configurations to optimize the software for. For more information please visit our info page.
Create Your Account

The installer will now create a new administrator account for you.

Choose the name you want to login with.
This can’t be changed later, but your display name can be.

Fill in your preferred password here, and remember it well!

(just for verification.)

Provide your email address as well. This must be a valid email address.
Database Password

The installer requires that you supply the database password to create an administrator account, for security reasons.