SmartOS LAMP Instal

By peterm, 9 June, 2014

I'm starting to work with our smart data center project. I stumbled around looking for a recipie and came up with this basic list of instructions for getting a LAMP stack on a sdc:sdc:base64:13.1.0 image.

Objective - setup a lamp install, then install Drupal 7

Apache 2.4

pkgin install apache

MySQL

pkgin install mysql-server, mysql-client

PHP

sudo pkgin install php54 php54-extensions-5.4.13

NOTE: the php54-extensions drops lots of extras module files into /opt/local/lib/php/20120301

Configure Apache

- need to make the standard entries for PHP (LoadModule, AddHandler)

- need to make the standard entry for index.php

- added a symlink for the htdocs dir to point to the recommended drupal file path

- learn the SmartOS commands for svcs -a, sudo svcadm resstart apache

- test your connection at http://x.x.x.x

Configure PHP

- add extension_dir path of /opt/local/lib/php/20120301

- add extensions: (YMMV depending on needs)

  extension=mysqli.so

  extension=json.so

  extension=dom.so

  extension=gd.so

  extension=pdo_mysql.so

  extension=pdo.so

  extension=pdo_dblib.so

- create a phpinfo file to review Apache/PHP config

- turn on display_errors in php.ini for initial debugging info

Configure MySQL

- secure the default MySQL install with a root password

- edit /opt/local/my.cnf as needed.

- create a sample database, create a table, create a couple of rows of data (see below for some scripts)

- create a mysql-test.php file to determine connection success

Install Drupal

- use the built in instructions at http://wiki.joyent.com/wiki/display/jpc2/Installing+Drupal+on+SmartMachi.... Note that you need to use MySQL root credentials if you haven't created a user with admin priv's.

- note the db_name, db_user, db_pass that come back from the script. They are need in the install.php portion for Drupal

- I was getting a json_encode fatal error. That made me go back and add more extensions (first json, then pdo). I may have more extensions on that I actually need.

Helper Scripts

This one will help get a connection to a MySQL database

http://www.phphaven.com/article.php?id=65 

This one will help create a sample potluck database.

https://www.digitalocean.com/community/articles/a-basic-mysql-tutorial

You'd need to adjust the script to like this:

// A QUICK QUERY ON A FAKE USER TABLE        

$query = "SELECT * FROM `potluck`";

$result = $mysqli->query($query) or die($mysqli->error.__LINE__);

// GOING THROUGH THE DATA

        if($result->num_rows > 0) {

                while($row = $result->fetch_assoc()) {

                        echo stripslashes($row['food']);        

                }

        }

        else {

                echo 'NO RESULTS';      

        }

Tags