Fixing WordPress permissions

In your WordPress directory, run the following:

This should fix all your WordPress woes relating to permissions

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.

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

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:xamppsetup_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:

[code language=”bash”]sudo apt-get install tomcat7[/code]

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

[code language=”bash”]sudo nano /usr/share/tomcat7/bin/setenv.sh[/code]

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

[code language=”bash”]
CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m"
[/code]

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

To restart tomcat7, use:

[code language=”bash”]sudo service tomcat7 restart[/code]

Verifying that it works

After the server restart, run this to check:

[code language=”bash”]ps aux|grep jar[/code]

This should return:

[code language=”bash”]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[/code]

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:

[code lang=”bash”]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
[/code]

To find out why, run apachectl -t:

[code lang=”bash”]
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_responsen Referenced from: /usr/libexec/apache2/mod_dav_fs.son Expected in: flat namespacen in /usr/libexec/apache2/mod_dav_fs.so
[/code]

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.

[code lang=”bash”]sudo nano /private/etc/apache2/httpd.conf[/code]

Try to run the syntax check of Apache configuration again:

[sourcecode language=”bash”]
bash-3.2# sudo apachectl -t
Syntax OK
bash-3.2# [/sourcecode]

That seems to be working, now we start Apache:

[code lang=”bash”]sudo apachectl start[/code]

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:

[code lang=”php”]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”] );
}
?>[/code]

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.

How to install APC in Ubuntu 12.04

This installation is through PEAR. You can install it in other methods too. This has installed APC 3.1.9 for me over Ubuntu 12.04 LTS.

[code lang=”bash”]sudo apt-get install build-essential libpcre3-dev php5-dev
sudo pear update-channels
sudo pecl install apc[/code]

Continue reading “How to install APC in Ubuntu 12.04”