After you’ve installed SmartOS on your server it’s time to make running services inside virtual machines which are SmartOS (exSolaris) zones. Thanks Joyent setup of virtual machine (VM) is quite simple.
vmadm -f newmachine.json
Here is an example of json manifest for new VM. Note that I used example names and simplified network settings. I will write a post re. network settings soon.
"image_uuid": "9eac5c0c-a941-11e2-a7dc-57a6b041988f", #this is Base 64bit Smartmachine image
Vm creates in 1 minute and after that you get working copy of base SmartOS VM with basic software and services running. This is base64 image which is pretty minimalistic.
Login to your new VM:
We have to install apache (or nginx if you prefer), mysql (percona-server preferred) and php. You could choose between php5.3 and php5.4.
Thanks Joyent and Jonathan Perkin there is very convenient package tool called pkgin and rather large repository with thousands of packages. First we have to update pkg database:
pkgin -y up
Then we look for our packages:
pkgin av | grep "\(percona\|apache\|php\)"
I’ve chosen Apache 2.2 and php 5.4. Choose preferred versions of apache and php and install all packages with following or similar command:
pkgin in apache-2.2 php-5.4 ap22-php54 percona-server
Also you will need some shared libraries for php (at least mysql drivers). Let’s install mysql bindings and most common libraries:
pkgin in php54-mysql php54-mysqli php54-curl php54-gd php54-dom php54-iconv php54-mbstring
After that it’s time to configure the services:
1.1) First start percona server:
svcadm enable percona-server
1.2) Then change mysql root password:
/opt/local/bin/mysqladmin -u root -p password 'your_new_password'
1.3) Next run script which will remove non-secure ingredients from fresh installation of mysql.
1.4) Create your database and upload their your data if needed.
2.1) Make changes in apache config:
Change followig sections:
Listen 'your ip here':80
in the end of long set of LoadModule … clauses add:
LoadModule php5_module lib/httpd/mod_php5.so
AddHandler application/x-httpd-php .php
Change ServerAdmin and ServerName clauses to appreciate values.
Change DocumentRoot to the location where your www documents will be stored:
Change in the <Directory «your/document/root/dir»> section the following:
Options 'consult http://httpd.apache.org/docs/2.2/mod/core.html#options for values here'
You could also change the logging options and other. Refer to httpd docs.
After configuring, start apache:
svcadm enable apache
3.1) At least you have to enable php extensions:
Find «extension=php_bz2» keystring by pressing «/» in vim and entering the keystring.
you will find a lot of commented out extensions declarations. Note that they are for Windows format. So you have not simply to uncomment some of them, but rewrite:
You could more extensions or shared libraries here if you’ve installed them at the previous step with pkgin.
Refresh apache to make php-module reread the config:
svcadm refresh apache
Now put your php application into the document_root directory and enter your domain or ip in your browser. It has to show your site!