dotAdmin developers can now use the dotAdmin vagrant image for development and testing purposes. This can be found in the dotAdmin repository at [your checked out folder]/vagrant/dev.
To use the Vagrant image you must first install:
VirtualBox: https://www.virtualbox.org/
Vagrant: https://www.vagrantup.com/
You may need to stop apache before running vagrant, otherwise it may try to listen on ports which are already in use:
$ sudo apachectl -k stop
To start the vagrant image, simply check out the repository, navigate to the [your checked out folder]/vagrant/dev directory in terminal and type:
$ vagrant up
This will then create the vagrant virtual machine, install dotAdmin and create the main dotAdmin website. You can "order" additional installations using the dotAdmin website on your vagrant virtual machine.
Your dotAdmin instance has a global config file at [your checked out folder]/shared/config/settings.config.class.php. this should read as follows:
<?php define('CMS_VERSION' , '3.0.00a'); define('INSTALL_ROOT' , '/var/www/dotadmin/3.0/'); if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)){ define('CMS_ASSETS_DOMAIN' , 'http://cmsassets.dotadmin.test:8080'); } else { define('CMS_ASSETS_DOMAIN' , 'http://cmsassets.dotadmin.test:8080'); } define('TOKEN_NAME' , 'token'); define('DEFAULT_DB_ENGINE' , 'mysql'); define('DEFAULT_DB_HOST' , 'localhost'); define('DEFAULT_DB_USER' , 'root'); define('DEFAULT_DB_PASS' , 'root'); define('DEFAULT_DB_PORT' , '3306'); define('LOG_PATH' , '/var/log/dotadmin/'); define('ERROR_EMAIL' , ''); define('ERROR_STACKTRACE' , true); define('DEFAULT_LOCALE', 'en_GB.utf8'); define('PROFILER', false); Class InvSettings { public static $company_name = 'dotAdmin by Invent Partners Ltd'; public static $address1 = '22a Fishergate'; public static $address2 = ''; public static $address3 = ''; public static $city = 'York'; public static $county = 'North Yorkshire'; public static $postcode = 'YO10 4AB'; public static $country_code = 'GB'; public static $tel = '01904 636677'; public static $email = 'support@inventpartners.com'; public static $vatnumber = 'GB126010861'; public static $help_chat_code = ''; } Class InvCommonDatabaseConnections { } ?>
You will need to add entries to your /etc/hosts file on the host machine so that domains hosted on your vagrant VM are accessible from your host machine. These initial entries must be added:
127.0.0.1 cmsassets.dotadmin.test 127.0.0.1 dotadmin.test
The webserver is listening on localhost port 8080 on your machine. You will be able to access the default dotAdmin website on http://dotadmin.test:8080 and the cmsassets CDN on http://cmsassets.dotadmin.test:8080
Any later website which you add will appear on [sitename].dotadmin.test:8080
When you are finished using your Vagrant virtual machine, navigate to the /vagrant/dev directory in terminal and type:
$ vagrant suspend
To resume the vagrant machine after it has been suspended or after the host machine has ben restarted, navigate to the /vagrant/dev directory in terminal and type:
$ sudo apachectl -k stop $ vagrant resume
You can access MySQL using an SSH tunnel. MySQL on your vagrant machine has the root username "root" and the password "root" So the following SSH tunelling settings would work on a default vagrant installation:
Database:
host: 127.0.0.1
username: root
password: root
port: 3306
SSH tunnel:
host: 127.0.0.1
username: vagrant
password: vagrant
port: 2222
Add the site folder to your /sites/ folders as usual, and add the dotadmin_[sitename] database to the MySQL server.
Add an entry for the new site domain to your /etc/hosts file.
127.0.0.1 [sitename].dotadmin.test
For example: if you install a new site called "demo.dotadmin.test" you must add the following to /etc/hosts
127.0.0.1 demo.dotadmin.test
You will also need to add a [sitename].conf for apache to /vagrant/dev/sites-enabled:
<VirtualHost *:80> ServerName [sitename].dotadmin.test DocumentRoot /var/www/dotadmin/3.0/site/[sitename]/htdocs DirectoryIndex application.php ErrorDocument 404 /Error404 #php_flag display_errors on #This bit does redirects from /url to /content/[id] <Directory /> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /application.php [L] </IfModule> </Directory> ErrorLog /var/www/dotadmin/3.0/site/[sitename]/logs/error_log CustomLog /var/www/dotadmin/3.0/site/[sitename]/logs/access_log combined </VirtualHost>
Once the [sitename].conf entry is added, you'll need to restart apache. Navigate to the /vagrant/dev directory in terminal and type:
$ vagrant ssh
This will log you in to the Vagrant virtual machine. You can now restart apache with:
$ sudo apachectl restart
Apache will by default write its logs to:
/var/log/apache2/access_log
/var/log/apache2/error_log
Individual website installations will write their logs to:
/var/www/dotadmin/3.0/site/[sitename]/logs/access_log
/var/www/dotadmin/3.0/site/[sitename]/logs/error_log
When working on code in the platform it is a good idea to tail the error log for the site you're currently working in, as errors from the site code, themes, templates and CMS will all be written into that site's error log:
tail -f /var/www/dotadmin/3.0/site/[sitename]/error_log
You may find that static files don't update on your test site when you change them in the site root folders.
This is because the server serving the static files is using the "sendfile()" syscall, which is broken with the VirtualBox file system. You need to disable sendfile() usage in your server. Add this to /etc/apache2/apache2.conf:
EnableSendfile off