Tag Archives: how to

How to install Laravel to a subdirectory

Simple! Just need to change a setting in the .htaccess file. I am using Laravel 4, you might be using some other version but the method should apply nevertheless. I use an alias to point to this directory.

Add this line “RewriteBase /l4″ to your .htaccess where l4 is your sub directory or folder.

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteBase /l4
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Have fun!

How to install Composer in Windows

I wanted to install PHP Composer in Windows. And to begin, I already have a copy of XAMPP 1.8.1, I think if you have a different way to get your PHP that should not matter. I tested this to work for Windows 7 but it should work for all versions of Windows.

0. Download and install XAMPP

You can download XAMPP here. I got the 7zip version rather than the installer itself. The ZIP version is similar, just with a larger file size. I extract the xampp folder into my C: drive, i.e. to C:\xampp. Then install it by opening the file C:\xampp\setup_xampp.bat. That will set the paths in XAMPP’s configurations.

1. Setting up environment variables

Continue reading “How to install Composer in Windows” »

How to set Catalina options in Ubuntu 12.10

This is more of a personal note and a really specific topic. This tutorial assumes you are using Ubuntu 12.10 or Ubuntu 12.04 and installed tomcat7 package. If you haven’t already installed tomcat7, use:

sudo apt-get install tomcat7

After doing so, create and edit the file setenv.sh. Putting setenv.sh in CATALINA_BASE/bin allows you to keep your customizations separate.

sudo nano /usr/share/tomcat7/bin/setenv.sh

I set my environment variables (in my case) as in setenv.sh:

CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m"

If the file is present, catalina.sh will pick it up and add to the runtime parameters.

To restart tomcat7, use:

sudo service tomcat7 restart

Verifying that it works

After the server restart, run this to check:

ps aux|grep jar

This should return:

tomcat7  14140 63.8 11.4 4001076 918296 ?      Sl   12:26   1:37 /usr/lib/jvm/default-java/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start
kahwee   15564  0.0  0.0  13580   936 pts/1    S+   12:29   0:00 grep jar

You should be able spot your line of customization. And that’s the proper way to setting up Catalina options. You can also set JAVA_OPTS through this method too.

How to troubleshoot Mountain Lion’s Apache

After I install Mac OS X Mountain Lion, it seems like my Apache server can no longer start successfully:

bash-3.2# sudo tail /private/var/log/apache2/error_log
[Thu Aug 02 09:36:46 2012] [notice] caught SIGTERM, shutting down
[Thu Aug 02 09:37:57 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
httpd: Could not reliably determine the server's fully qualified domain name, using kahwee-mba.local for ServerName
[Thu Aug 02 09:37:57 2012] [notice] Digest: generating secret for digest authentication ...
[Thu Aug 02 09:37:57 2012] [notice] Digest: done
[Thu Aug 02 09:37:57 2012] [notice] Apache/2.2.22 (Unix) DAV/2 mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Thu Aug 02 09:46:17 2012] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/favicon.ico
[Thu Aug 02 09:54:19 2012] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/r, referer: http://home.internal.kw.sg/
[Thu Aug 02 09:54:19 2012] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/favicon.ico
[Thu Aug 02 09:54:31 2012] [notice] caught SIGTERM, shutting down

To find out why, run apachectl -t:

bash-3.2# sudo apachectl -t
httpd: Syntax error on line 106 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_dav_fs.so into server: dlopen(/usr/libexec/apache2/mod_dav_fs.so, 10): Symbol not found: _dav_add_response\n Referenced from: /usr/libexec/apache2/mod_dav_fs.so\n Expected in: flat namespace\n in /usr/libexec/apache2/mod_dav_fs.so

Seems like it is caused by my disabling of mod_dav. mod_dav_fs acts as a support module for mod_dav and provides access to resources located in the server’s file system.

So I go to line 106 of /private/etc/apache2/httpd.conf and I comment out that line too.

sudo nano /private/etc/apache2/httpd.conf

Try to run the syntax check of Apache configuration again:

bash-3.2# sudo apachectl -t
Syntax OK
bash-3.2# 

That seems to be working, now we start Apache:

sudo apachectl start

Useful apachectl commands include:

  • apachectl start
  • apachectl stop
  • apachectl restart
  • apachectl -t

Hope it helps!

How to use Invision’s BBCode

Using Invision’s BBCode isn’t straight forward. Chances are that you need to invoke the BBCode parser if you want to create a plugin or hook for Invision Powered Board. Here’s the rough code to do so, with $topics being the array containing all the topics from the database to be parsed:

<?php

$classToLoadComposite = IPSLib::loadLibrary( IPS_ROOT_PATH . "sources/classes/editor/composite.php", "classes_editor_composite" );
$editor = new $classToLoadComposite();
#$editor->setAllowHtml( 1 );
//-----------------------------------------
// Return the data
//-----------------------------------------
foreach ($topics as &$topic) {
    $topic["formattedPost"] = $editor->process($topic["post"]);
    IPSText::getTextClass("bbcode")->parsing_section = "topics";
    IPSText::getTextClass("bbcode")->parse_smilies = TRUE;
    IPSText::getTextClass("bbcode")->parse_bbcode = TRUE;
    IPSText::getTextClass("bbcode")->parse_html = FALSE;
    IPSText::getTextClass("bbcode")->parse_nl2br = TRUE;
    IPSText::getTextClass("bbcode")->bypass_badwords = FALSE;
    $topic["formattedPost"] = IPSText::getTextClass("bbcode")->preDisplayParse( $topic["formattedPost"] );
}
?>

For the parsing_section, you should put a value that corresponds to the editor section. In my case, I need it to ‘topics’. To get the full list, you may need to look up Invision Powered Board’s source code which I cannot provide.

I wrote this down more as a personal note and I hope it benefits you as it did for me. If you have any questions, feel free to post and I can attempt answering.