
Install Empresa, MySQL 5 and Php with GD on Ubuntu
Written by Claudiu Bischoff, on 27 mai 2010
OVERVIEW
Every mivascript developer have its own habits. Some of us are using good old Mia to develop. I found it very annoying to develop this way, because of a simple reason. Having to change the root and mivadata directory each time I want to access one of my projects, it's a pain in the ass. How many times I forgot to change the mivadata folder and got into very dangerous modifications....
So, here is my challenge with Ubuntu desktop 10:
1. To be able to add as many virtual hosts (VH) in seconds
2. To be able to access each VH by a domain name (and subdomains: like
proj1.mydomain.com, proj2.mydomain.com)
3. To be able to work and compile each Miva Script project from my Windows 7 machine ( I still use Homesite and I don't want to change that )
4. To be able to access and modify from my Windows machine all the projects files and directories without restriction.
By the way, I'm using Virtual Box for my server. This way I don't need a second computer for my server and I can easily make copy and paste on my Ubuntu machine :-) But of course, you can do the same thing on a different computer if you like. ( PS: I know I can do copy/paste with VNC on a distant machine but I don't like it :P )
Here are the services we need to install:
1. Apache server
2. Php
3. Mysql
4. Bind9
5. Samba - To share folders with windows
6. ACL ( Access Control List ) - We need it to manage multiple users rights on files
7. Empresa (if you didn't downloaded it you will have to do it in advance):
http://www.mivamerchant.com/products/empresa/download/index.mv (and choose in the list menu, "Miva Merchant Empresa for LINUX"). Once you have downloaded the latest Empresa don't forget to download the latest MivaScript - MySQL connector lib if you want to work with Miva Script and MySQL:
https://support.mivamerchant.com/supportsuite/index.php?_m=downloads&_a=view and choose : "Miva Empresa MySQL Connector v2.017 - Linux": ... or click here
INSTALLING THE UBUNTU MACHINE
I presume that you already downloaded the ISO file. If not here is the link :
http://www.ubuntu.com/desktop/get-ubuntu/download
If you're willing to use VirtualBox, be careful when choosing the disk space. You won't be able to expand that virtual disk easily later. And one more important thing. In the Settings/Preferences of your virtual machine, go the the Network menu and change from NAT to "Access by Bridge" (or something like that..). This way you will be able to change and access the IP of the server anywhere from your network easily.
Install Ubuntu following the normal steps. Once you have installed the system, go to your Network Connections (System -> Preferences -> Network Connections) and change the IP4 to your own IP (In my case, I have my intranet rooter set on 192.168.1.254 and my server will be 192.168.1.1 (so I'll be able to access the server by this IP). My Windows 7 computer have the IP: 192.168.1.2 ):
Click EDIT when in this menu...

Change the Method to Manual and click ADD. Double click on the empty area under each column and add your address. Don't forget to add the same IP Address to the DNS servers,
you will understand why later.
Once you have changed the IP of the server (remember your server IP, it's important), open your Terminal ( Applications -> Accessories -> Terminal )

Once the Terminal opened, start with :
sudo su
Put your administrator password and this way you're root. Now we'll start with the Ubuntu upgrade :
apt-get upgrade
You will have to wait till all the upgrade is done (it might take a while). Once it's finished lets start by the annoying part, installing the DNS server:
Once it's installed, we will need to parameter the server DNS:
In this file, delete the # in front of the forwarders and put your DNS ip (in my case I'm using the DNS of OpenDns servers - they are very reliable). So the final file will be like this:
208.67.220.220;
208.67.222.222;
};
In my case I decided that my domain name will be : server.com . You can choose any domain name YOU want, even if it exists, because you will use your own DNS server. No need to register your intranet domain name, unless you want people to access your server (but I wouldn't do that if I were you. The settings of this server are not the most secured one - remember, all we want here is to develop our miva script projects, not to make a public server !
Now we will create our NS entries.
Change "server.com" with your own domain name!
Inside the file, put the following lines.
Change server.com with your own domain and change also the IP 192.168.1.1 with the one you set in the server network settings!
@ IN SOA ns.server.com. root.server.com. (
3 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns.server.com.
@ IN A 127.0.0.1
@ IN AAAA ::1
ns IN A 192.168.1.1
Save the file : Ctrl+X and choose Y to save the file. Now, let's continue:
Inside the file, put the following lines.
Change server.com with your own domain!
@ IN SOA ns.server.com. root.server.com. (
4 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns.
1.0.0 IN PTR ns.server.com.
Save the file : Ctrl+X and choose Y to save the file. Now, let's continue:
Inside the file, add at the bottom the following lines.
Change server.com with your own domain and change also the IP 1.168.192 with the lease you set in the server network settings!
zone "server.com" {
type master;
file "/etc/bind/db.server.com";
};
zone "1.168.192.in-addr.arpa" {
type master;
notify no;
file "/etc/bind/db.192";
};
Save the file : Ctrl+X and choose Y to save the file. Now, let's continue:
Normally our job is done. We'll restart the Bind server in order to see if we have any errors:
Now we'll install SAMBA. This is very important if we want to share folders in the network:
Once SAMBA is installed, we'll install ACL :
We'll have to modify our fstab so the HDD can be mounted with ACL:
Inside the file, get to the HDD partition line and put ",acl" behind the existing options. In my case I had to put ",acl" behind "errors=remount-ro":
UUID=7c2dc92e-cc8f-4d1e-88c2-6c600c97d0e0 / ext4 errors=remount-ro,acl 0 1
Save the file : Ctrl+X and choose Y to save the file. Now, we'll have to remount our existing HDD (in this session) so we can use the ACL without restarting the session. Change /dev/sda1 with the partition name you have in your fstab (it's written right on top - in my case: "# / was on /dev/sda1 during installation")
Ok , we're done with the hard part, and we'll get to the "fun" part. Installing the apache server:
Confirm whatever it asks you to confirm. Now you will have to share the \var\www folder. So type in the terminal
Change "youradminname" with your real Ubuntu administrator login :
chgrp users /var/www
OK, now, last thing, let's give the folder all the necessary rights.
Change "youradminname" with your real Ubuntu administrator login :
Now let's try and get our empresa installed. First, we'll prepare our files. Once you have downloaded the linux tar file, create a folder on your Windows machine ( like c:\Miva ) and share it with everyone (right click... Properties... Share... etc..). Untar in this folder the content of your empresa tar archive: (use Rar if you don't know how to untar a file on Windows ). You will have the following structure: C:\Miva\mivavm-v5.06
Now, create a new folder inside C:\Miva, and name it mivarep (it will be our miva cgi-bin repository) . So, the structure will now be:
C:\Miva\mivarep
Now, create a new directory inside mivarep, and that directory will be cgi-bin. so we'll end with this structure:
C:\Miva\mivarep\
C:\Miva\mivarep\cgi-bin\
We'll install Miva Empresa in Standard mode (I found it personnaly more flexible when it comes to VH), so we'll have to put inside mivarep 2 files: mivavm and libmivaconfig.so. You will have to navigate into your mivavm-v5.06 and copy the following file
inside C:\miva\mivarep\cgi-bin\ folder, and you will have to RENAME it to libmivaconfig.so. Now copy the mivavm file:
to your C:\miva\mivarep\cgi-bin\ folder, and you will have to RENAME it to mivavm. Last file, copy the diag5.mvc from
and paste it in the C:\miva\mivarep\ folder (just near the cgi-bin folder NOT INSIDE)
Last thing, we need to put our mysql.so lib inside the mivavm-5.06 folder. So, unzip your mysql5.zip (that you have downloaded already from the miva merchant support website - you'll find the link in th top of the tutorial) file to the following folder:
Once you have unzipped the files (mysql4.so and mysql5.so), go to the files and rename mysql5.so to mysql.so.
Ok, the repository is ready. We have done that in order to use the shell script I made which will create virtual hosts easily.
Now, let's get back on our Ubuntu machine. Go on the top menu: Places -> Connect to server -> Service type, select "Windows share", in Server put your Windows computer IP (the computer where you have created the miva folder) and check Add bookmark checkbox (you will need it in the future) and connect. Put your login name of the windows machine and your password. If your network is not WORKGROUP, change it with your name (in some cases we see MSHOME)


If all is done right, you will have a new window with your windows shared folders. Go into the Miva folder, select everything and right click and choose COPY.
Now on your left side, you will find a "File System" folder. Click on it, and navigate to your www folder ( double click on var and www ). Once inside the www folder, right click and select PASTE. Normally you have all necessary files. You need 1 more files. So let's copy it directly from Ubuntu. In the same time we'll grant execution rights to the mivavm binary file.
Change "youradminname" with your real Ubuntu administrator login :
wget http://mivascript.org/ubuntu/mivavm.conf
chown youradminname mivavm.conf
chmod +x mivavm
Now, we'll have to modify our Apache2 file settings. I'm used to work with the httpd.conf file so I'll create first a symbolic link at the bottom of the server to my apache2.conf:
Now, we have to create a symbolic link to the mysql sock in order to make it works with Miva Empresa:
You would think we're done with the symbolic link, but it's not all. The problem with the temp folder is that Ubuntu will empty it at reboot, so to avoid recreating the symbolic link every time you reboot your machine, we'll create a service that will activate the link at the startup:
wget http://mivascript.org/ubuntu/mvlink
chown root mvlink
chgrp root mvlink
chmod +x mvlink
update-rc.d mvlink defaults
There is a small error about the header, but it's ok, it will work. Now each time you have to reboot the server, the link will be created automatically.
Ok, now with the httpd.conf modifications:
Inside the file, go to the bottom and comment the following line:
After that, add the following lines:
DirectoryIndex index.html index.mvc index.html.var index.shtml index.htm index.cgi index.php index.wml
AddType application/x-miva-compiled .mvc
Action application/x-miva-compiled /cgi-bin/mivavm
ServerName server.com:80
NameVirtualHost 192.168.1.1:80
<VirtualHost *:80>
DocumentRoot "/var/www/default/www"
</VirtualHost>
Save the file : Ctrl+X and choose Y to save the file. Now, let's continue. We need to create the default root server folder :
mkdir /var/www/default/www
mv /var/www/index.html /var/www/default/www/
We need to activate a few apache modules (else we'll get errors):
a2enmod actions
Ok, let's restart our Apache server:
If everything is OK, we won't get any error. Last thing to do, create our install.sh file, so we can install virtual hosts very easily. Download the file and edit it inside Ubuntu. Please oh please, change the name of the administrator with your Ubuntu admin name and of course, change the IP with your own:
wget http://mivascript.org/ubuntu/install.sh
chown youradminname install.sh
chmod +x install.sh
nano install.sh
Once you have changed the IP (192.168.1.1) with the IP you choosed for your Ubuntu machine and the "youradminname" with your Ubuntu login name, Ctrl+X and Y to save the file.
Now you can execute it and install your first virtual host:
Follow the instructions (login name is the vh user login name, pass, the password and domain name, the domain name of the Vh - in my case I use xxx.server.com (ex: miva.server.com). Once you have done it, it will create the VH and you will be able to access the domain anywhere in the network.
Final step, change the DNS IP on your Windows computers if you want to be able to use the personal DNS server. Go to your control panel, connection settings, properties -> IP4 -> and in the DNS IP put the server IP - in my case 192.168.1.1 and second one put a real DNS Ip - in case the personal server is off - 208.67.222.222 (is the IP of Open DNS server)
You can now access and modify the Ubuntu folders from your windows machine. Shared Network - NameOfYourUbunuMachine (generally is ADMINNAME-DESKTOP). If you cannot see the server, just write in the address of your file explorer \\IP_OF_THE_SERVER - in my case \\192.168.1.1 and you'll see the files. If you still cannot access the folders, reboot the Ubuntu machine.
Final words
This is my own experience with Ubuntu. I'm not an expert and this configuration is not a very secured one. It's supposed to be an internal development server (not a public one) so be aware, do not give access to that machine from the outside world). I hope you enjoy my tutorial, and if you have questions, use the forum...
COMMENTS
I started a thread in the Miva Merchant (Miva Script section), so don't hesitate: http://extranet.mivamerchant.com/forums/showthread.php?t=100440

