by Kerry Mraz, Development Lead
I am providing these steps for installation on an Ubuntu Server as a known tested and good method for working SaaS installation using CodeIgnitor and 4thRecess approved software apps. This is done mostly as a fall back to personal study, a procedure to follow should a restore be necessary, and a training guide for future techs or developers.
Current server settings used for testing:
Minimum recommendations for VirtualBox installations:
After installation of Ubuntu Server on the Virtual Box, run these commands to install Apache2, MySQL, PHP5 and Samba. More information can be found at this Digital Ocean page.
- If you forget to sudo something, you can type: sudo !! to repeat the previous code with sudo.
- You can run multiple commands by && (anding) them together. i.e. sudo apt-get update && sudo apt-get upgrade
- You can bypass the installation confirmation (Y/n) message by adding -y to the command. i.e. sudo apt-get install -y mysql-server
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get -y install apache2
sudo apt-get -y install mysql-server libapache2-mod-auth-mysql php5-mysql
sudo apt-get -y install php5 libapache2-mod-php5 php5-mcrypt php5-curl
#add index.php to front of search for index files
sudo nano /etc/apache2/mods-enabled/dir.conf
sudo service apache2 restart
#to show available php install packages use
apt-cache search php5-
#for more information about the package use
apt-cache show package_name
#install samba file sharing
sudo apt-get -y install samba samba-common system-config-samba python-glade2 gksu
#install and set up Uncomplicated Firewall
sudo ufw allow 80 #web server
sudo ufw allow samba
sudo ufw enable
#option ports to enable depending on your configuration
sudo ufw allow 22 #ssh
sudo ufw allow 21 #FTP
You will also need a MySQL database administration tool, such as PHPMyAdmin or Oracle MySQL Workbench. The command below will install PHPMyAdmin on Ubuntu.
sudo apt-get install phpmyadmin
If this is to be a production server, make sure to secure the access to PHPMyAdmin through the following Digital Ocean article. PHPMyAdmin can be accessed from any computer on the network via the server name or the IP address through a web browser. To find the IP address of the linux server type:
The IP address is provided by the network router and typically has the values 192.168.X.X or 10.0.X.X depending upon the make and model of the router. From the other computer (even the computer hosting the VirtualBox) in a web browser, you can type into the address bar: http://<ip address>/ and the default apache welcome screen should appear.
On the Linux system, you can locate the default "www" folder at:
You will need to add your Linux user (<username>) to the "www-data" group and change the permissions on the "www" and subfolders. It is not recommended to do work on these folders as the root user. To check which groups your user is part of, type:
To verify that "www-data" is a valid group type:
cat /etc/group |more
To add a new user to the group "www-data", type:
sudo useradd -G www-data <username>
To add your user to the group, type:
(It is important to add the -a, otherwise you will make the group primary for the user and remove other groups.)
sudo usermod -a -G www-data <username>
Create a samba password:
sudo smbpasswd -a <username>
To change directories to view and make modifications use the "cd" command:
To view the contents of the folder with their permissions, type:
This will give you the files, directories in a list format and tell you the owner:group permissions. They should say, "root:root" as the owner and group. We need to modify this to say, "<username>:www-data". To do this, type:
sudo chown -R <username>:www-data www/
-R makes the command recursive (i.e. will also change permissions on all sub-directories and files in the sub-directories).
If you create folders in here, they will also be folders on the website. For example, if you create a folder called "example": (We no longer need to use "sudo" in front of the commands, since we want all future files and directories to be owned by your username and not by root.)
To view the new folder and its permissions, type:
In the browser on the other computer, you can now access this new folder at the following url:
You will need a code editor. There are many out there. If you have one already, use it. If not, here is a list of some I've used, seen, and recommend.
There are many ways to modify content on a server. Since this testing server happens to reside on your network, it is easiest to access and modify this content directly. The main risk with this method is that there is a single copy of the content. Modifications you make remotely are irreversible once you close the text editor you are using unless you make constant back-ups of your site content. This should only be used for development and testing sites.
Earlier, we installed Samba. This is a software program that is used for file sharing to Windows and Mac based networks. We want to share the"html" folder to the network. Here is how:
sudo mv smb.conf smb.conf.bak
sudo nano smb.conf
We went to the samba directory that is owned by the root user. We moved the Samba configuration file to a backup file. Now we are going to create a new one with the "nano" program. The code below will set up the Samba file share program. Make any modifications below to suit your needs. For example, "test_server" will be the server's name on the network and can be used in place of the ip address. (http://<ip address>/ == http://test_server/). Type:
workgroup = WORKGROUP #this is where the computer will be listed on the workgroup
server string = Samba Server %v
netbios name = test_server #this is the name of the computer you will see on the network
security = user
map to guest = bad user
dns proxy = no
[www] #This will be the name of the folder visible on the network
path = /var/www/html
valid users = @www-data #gives read and write access to these users
guest ok = no #yes, if you want this to be readable to anonymous users
writable = yes
browsable = yes
Press Ctrl+O to save, and then Ctrl+X to close. Now, to restart the Samba server with the new configuration, type:
sudo service smbd restart
sudo service nmbd restart
From your computer, you should now see a new computer called "test_server" on the "WORKGROUP" with a folder called "www" on the network. Unless you modified these values in the configuration file above. If you do not know how to access a computer from the network, you can try:
Click Start -> Run, and type:
I like to map this folder as a network drive for easy access. If you need help doing this, do a Google search for "map network drive".
Now you have access from your computer to modify content on the web server you just created. Now we are going to create a little content. First we have to remove the Apache2 default web page. On the Linux VirtualBox, type:
mv /var/www/html/index.html /var/www/html/index.html.bak
On the system with the text editor, create a new file. Paste this in the new file:
<head><title>My first page title</title>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
When you save the file, call it "index.html". Be sure to save it in that new shared folder on the server. You can browse to it through the network, or type "\\test_server\www\index.html" in the File Name text box.
In your browser, access the url, "http://test_server/" and you should see your page displayed.
There are several things to consider when developing the data architecture for a Software as a Service (SaaS) application. The first and most important decision you'll make is whether or not your application will be single or multi-tenant. With single tenant applications, the database design implications are a bit less dramatic from a design and development perspective. The drama for a single tenant architecture occurs a little later in the process with Change & Configuration Management.
If your application is going to be multi-tenant, then here are some of the things to consider;