Feb 18 2008

PHP & ionCube Loader: ‘The Loader must appear as the first entry in the php.ini file in Unknown on line 0′

Tag: Apache, Linux, PHP, Techjs @ 3:00 pm

I received the following in my Apache error_log when attempting to load the ionCube loader in my php.ini file:

PHP Fatal error: [ionCube Loader] The Loader must appear as the first entry in the php.ini file in Unknown on line 0

This is because ionCube must be loaded before any of the Zend extensions are. So if you have the Zend extension/optimizer loaded, your php.ini should look like this to get ionCube to work:

[Zend]
zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.1.so
zen_extension_ts=/usr/local/ioncube/ioncube_loader_lin_5.1_ts.so
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.0
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.0
zend_optimizer.version=3.3.0a
zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so

—————-
Now playing: Tommy McCook & The Aggrovators - A Loving Melody
via FoxyTunes

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Dec 06 2007

mod_rewrite & PHP: How to match urlencoded plus sign (+ = %2B)

Tag: Apache, PHP, Programmingjs @ 9:37 pm

I ran into trouble when trying to pass a urlencode()‘ed plus sign into a web address being processed by mod_rewrite.

$url = ‘http://www.server.com/browsealpha/name+has+plus+in+it/’;
$url = urlencode($url); // http://www.server.com/browsealpha/name%2Bhas%2Bplus%2Bin%2Bit/

This $url variable gets echo()’d as a link in a page, so once it’s clicked and loaded in the browser, I then needed mod_rewrite to translate that to the actual URL, which is:

http://www.server.com/browsealpha.php?name=name%2Bhas%2Bplus%2Bin%2Bit

Here is the RewriteRule I was using to match:

# match any name containing any combination of letters, numbers, and the % sign (to match urlencoded URLs)
RewriteRule ^browsealpha/([%\w]*)/?$ /browsealpha.php?name=$1 [QSA,L]

This rule should match http://www.server.com/browsealpha/name%2Bhas%2Bplus%2Bin%2Bit/ but for some reason it wouldn’t work. After hours of frustration, I found a few threads mentioning the need to urlencode the string twice, like so:

urlencode(urlencode($variable));

IT WORKS!!! Apparently this is because mod_rewrite automatically decodes the urlencoded URL, so if you pass in %2B, PHP sees it as %2B0. If you double encode, mod_rewrite decodes the first one, and PHP receives the second one (which is now %2B, which is what we want).

—————-
Now playing: Autechre - 444
via FoxyTunes

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Aug 02 2007

Apache VirtualHost on Ubuntu

Tag: Apache, Tech, Ubuntujs @ 5:24 pm

Here’s a quickie tutorial on how to add Virtual Hosts to Apache on Ubuntu. This tutorial assumes that you have a basic understanding of Apache configuration and that your Apache is installed and able to serve websites.

  1. cd /etc/apache2/sites-available
  2. sudo vim yourdomain.com.conf and enter your VirtualHost directive. Below I’ve put the most basic example, see Apache docs for details and additional features:
    <VirtualHost *>
    ServerName yourdomain.com
    DocumentRoot /home/youruser/public_html
    </VirtualHost>

    Save & exit.

  3. sudo vim /etc/hosts and add your new domain to the 127.0.0.1 locahost line so it looks like this:
    127.0.0.1 localhost yourdomain.com

    Save & exit.

  4. Enable your new virtualhost:
    sudo a2ensite yourdomain.com.conf
  5. Reload the Apache configuration:
    sudo /etc/init.d/apache2 reload

That’s it! Repeat for each of your VirtualHosts.

—————-
Now playing: Alèmayèhu Eshèté - Tchero Adari Nègn
via FoxyTunes

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Feb 20 2007

Squirrelmail and Very Large (Big-Ass) Inboxes

Tag: Apache, PHPjs @ 2:14 pm

We have an account with a VERY large inbox (over 80,000 emails), and when logging into Squirrelmail the main pane would not load. Instead we’d be prompted by the browser to download a right_main.php file. Accounts with smaller inboxes would load fine, so I figured it had something to do with system resources. This is an easy fix. Open up your php.ini file, and increase the memory_limit value to something larger than the default 8M. Restart Apache and try opening your big-ass inbox again. If it still doesn’t work, increase memory_limit again. Repeat until your inbox will load, but be careful if you have little RAM. I was able to load my 80,000+ inbox by setting memory_limit = 32M.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Dec 07 2006

FCKeditor Error: this.DOMDocument has no properties

Tag: Apache, FCKeditor, Techjs @ 6:29 pm

In my prior post I ran into a problem with FCKeditor on Apache having to do with serving JavaScript files as the proper MIME type. I ran into a similar problem with XML files when trying to load multiple instances of FCK textareas:

Error: this.DOMDocument has no properties
Source File: http://www.mysite.com/FCKeditor/editor/js/fckeditorcode_gecko.js
Line: 43

This is easily fixed in the same way, by telling Apache how to properly serve XML files. Put this in your httpd.conf or an .htaccess file:

AddType text/xml .xml
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Dec 07 2006

FCKeditor in Firefox - Illegal Character JavaScript error

Tag: Apache, FCKeditor, Techjs @ 5:38 pm

For some reason, FCKeditor would not load in Firefox 2.0 even though it loaded in IE just fine. Turns out Apache was serving up the javascript files as the wrong FileType, so Firefox would choke on some jibberish characters:

Error: illegal character
Source File: http://www.myserver.com/FCKeditor/editor/js/fckeditorcode_gecko.js
Line: 1, Column: 1
Source Code: /*

The fix is easy enough, simply add an .htaccess file to your dir containing the following:

AddType application/x-javascript .js

Now FCKeditor should work fine in Firefox.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Apr 18 2006

Serving up a Windows Media Video (WMV) with Apache.

Tag: Apache, Techjs @ 7:32 pm

When trying to serve up a Windows Media Video file from my Apache webserver, I ran into the problem of Firefox being unable to handle the file properly. It would simply load it as a plain text file, resulting in a bunch of jibberish representing the machine code of the video (as if you had opened the video with Notepad). It turns out that with a stock install, Apache does not know how to serve this type of file, so it serves it as the default, which is plain text. It’s an easy fix, you simply have to tell Apache how to serve these types of files. Open up /etc/mime.types and add the following line:

video/x-ms-wmv wmv

You will also need to add the following to your httpd.conf file:

AddType video/x-ms-wmv .wmv

Save and exit, restart Apache, and your browser should now prompt you for how you want to handle the file (Open/Save).

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Next Page »