Posts Tagged Time: ~5 Minutes

Serving django media files from the same host as the passenger app server

WARNING: Please read before continuing ▼

Difficulty: Easy
Time: ~5 Minutes
Last Updated: 20rd September 2010
Applies to: *NIX

The recommended configuration for django is to have any static files, such as script, CSS or images uploaded onto a CDN network. While this is the best configuration for a large site, for toy applications it is overkill.

Also, you may wish to run your development environment using passenger, rather than using manage.py runserver.

To start, we need to make a media directory in your passenger app root, and then create a symbolic link to the admin media files located on your system.

1
2
3
cd /var/www
mkdir media #the directory where our media files will be stored
ln -s /usr/lib/pymodules/python2.6/django/contrib/admin/media/ admin_media

Next, we need to disable passenger on the directories/symlinks we have created, as per the previous article on the blog.

Once this is done, edit settings.py in your django app, specifying the new addresses for your media.

Finally, restart apache, and you should now be able to access the media files you need.

, , , , , ,

No Comments

Serving non-python files from a subdirectory of the passenger root.

WARNING: Please read before continuing ▼

Difficulty: Easy
Time: ~5 Minutes
Last Updated: 23rd September 2010
Applies to: *NIX

Serving non-python or ruby files from a subdirectory below the passenger app root requires a simple change to the site configuration.

Open it up, and add something similar to this under the VirtualHost entry (this example shows the subdirectory phpPgAdmin being disabled, so that phpPgAdmin can be served by php instead):

1
2
3
4
        Alias /phpPgAdmin /var/www/phpPgAdmin
        <Location /phpPgAdmin>
                PassengerEnabled off
        </Location>

Once this is done, restart php and any requests made to yourdomain.com/phpPgAdmin will not be served by passenger.

, , , , , , , , , ,

1 Comment

Installing the ssh2 PHP extension, with PHP 5.3

WARNING: Please read before continuing ▼

Difficulty: Moderate
Time: ~5 Minutes
Last Updated: 21st March 2010
Applies to: *NIX

Currently, due to an API change ssh2 will not install via pecl. Despite being a one-line fix, and 5.3 being out for some months now, the maintainers have neglected to make their extension compatible with PHP 5.3

If you recieve an error similar to:

1
2
/tmp/pear/download/ssh2-0.11.0/ssh2.c:52: error: duplicate "static"
/tmp/pear/download/ssh2-0.11.0/ssh2.c: In function "zif_ssh2_methods_negotiated":

Then you are affected. To fix this, you need to download and extract the ssh2 package:

1
2
pecl download channel://pecl.php.net/ssh2-<version>
tar xvf ssh-<version>.tar

Open up ssh2-<version>/ssh2.c and look for the following block around line 50:

1
2
3
4
5
6
7
8
#ifdef ZEND_ENGINE_2
static
    ZEND_BEGIN_ARG_INFO(php_ssh2_first_arg_force_ref, 0)
        ZEND_ARG_PASS_INFO(1)
    ZEND_END_ARG_INFO()
#else
static unsigned char php_ssh2_first_arg_force_ref[] = { 1, BYREF_FORCE };
#endif

From that block, you need to remove the first “static” so it looks like this:

1
2
3
4
5
6
7
#ifdef ZEND_ENGINE_2
    ZEND_BEGIN_ARG_INFO(php_ssh2_first_arg_force_ref, 0)
        ZEND_ARG_PASS_INFO(1)
    ZEND_END_ARG_INFO()
#else
static unsigned char php_ssh2_first_arg_force_ref[] = { 1, BYREF_FORCE };
#endif

After you’ve done this, simply repackage and install:

1
2
pecl package package.xml
pecl install -f ssh2-<version>.tgz

, , , , , , , , ,

No Comments

Renaming the admin user on a WordPress 2.8+ blog

WARNING: Please read before continuing ▼

Difficulty: Easy
Time: ~5 Minutes
Last Updated: 16th October 2009
Applies to: WordPress

By default, WordPress uses “admin” as the log in name for the first user. With this information, a prospective cracker is only a password away from your wordpress admin account. By changing the admin user name, the minimum amount of information required for any miscreant to access the account is increased.

Read the rest of this entry »

, , , , ,

No Comments

Technical Procedures is Digg proof thanks to caching by WP Super Cache