Saturday, November 05, 2011

Name Virtual Host

Edit httpd.conf

sudo vi /etc/apache2/httpd.conf
Add this line

NameVirtualHost *:80
NOTE: You can replace *:80 with your_ip_address:80

Now create the domain name config file. I use the domain_name.com

sudo vi /etc/apache2/sites-available/domain.com
Add this to the file


ServerAdmin admin@domain.com
ServerName www.domain.com
ServerAlias domain.com
DocumentRoot /var/www/domain.com/public_html/
ErrorLog /var/www/domain.com/logs/error.log
CustomLog /var/www/domain.com/logs/access.log combined

Make sure the directories in the domain.com config exists

/var/www/domain.com/public_html/
/var/www/domain.com/logs
NOTE: use the mkdir command like this if needed

sudo mkdir /var/www/domain.com/public_html/
sudo mkdir /var/www/domain.com/logs
Now we need to enable the new config file like this

sudo a2ensite domain.com
You should see a notice to restart apache, use this command

/etc/init.d/apache2 restart
Now we need a test file to view

sudo vi /var/www/domain.com/public_html/index.html
Add some text

Hello domain.com
Open your web browser and go to your new domain

http://domain.com

Wednesday, July 27, 2011

Prado and installing PHPExcel - Auto Loading bug

Well this was a headache and then some.

The problem is Prado has a Auto Loading process that can cause 3rd party or additional libraries to break and act strange if they also have a Auto Loading process.

The Solution is to turn off Prado's Auto Loading process, Load the 3rd party/Additional library and then turn Prado's Auto Loading process back on.

Here is what it looks like: (In this example I'm using the namespace instead of the path alias)


$phpExcelPath = Prado::getPathOfNamespace('Application.Core.php_excel.Classes');

// Disable Prado Auto Loading process
spl_autoload_unregister(array('Prado','autoload'));

// Add PHP Excel
require_once($phpExcelPath.'/PHPExcel.php');
require_once($phpExcelPath.'/PHPExcel/Writer/Excel2007.php');

// Do PHP Excel stuff here

// Reload Prado Auto Loading process
spl_autoload_register(array('Prado','autoload'));



Reference: http://www.ramirezcobos.com/2010/11/05/how-to-use-phpexcel-with-yii/
They are using YII but the process is very similar

There is a discussion here for possibly more information regarding this issue.