Jan
26
2007
4

Installing php5-cgi on Debian

For a long time I wanted to be able to run both PHP 4 and PHP 5 on the same server. Now I finally managed to come up with a solution that is easy to install and easy to use.

  1. Add the Debian Backports repository to your /etc/apt/sources.listdeb http://www.backports.org/debian/ sarge-backports main contrib non-free(on one line)
  2. Issue a package update: aptitude update
  3. Install PHP 5 as CGI module: aptitude install php5-cgi
  4. Configure Apache by adding the following lines to your main config file. In my case this was /etc/apache2/apache2.confScriptAlias /php5-cgi /usr/lib/cgi-bin/php5
    Action php5-cgi /php5-cgi

  5. Now find the Virtual Host you want to run on PHP 5 and simply put the following line into the <Directory> directive.AddHandler php5-cgi .php
    This overrides the default handler for files ending in .php which would be the normal PHP 4 module. Whit this directive it is now parsed and executed by the PHP 5 CGI binary.
  6. Reload your webserver config with
    /etc/init.d/apache2 reload
Written by Florian Beer in: linux, server
rel-tag , , , ,

Mar
09
2006
0

made my day

i had a vision
someone should make an operating system with apache2 as the kernel and everything else implemented as mod_perl handlers.

via http://pfig.livejournal.com/80557.html

Written by Florian Beer in: private, web
rel-tag , ,

Jan
07
2006
7

Fixing non working Permalinks on Wordpress

After struggling almost one week to find the cause for my not entirely working Permalinks on this Wordpress installation, I finally found the cure on the Wordpress Codex. I already read this page about five times and I just can’t tell how this one paragraph could always slip away… anyway the solution is rather simple.

As I’m a decently paranoid Server Admin I once changed the way Apache reports it’s server software. This poses some troubles with Wordpress which checks to see if the host is running Apache or IIS to determine wether to write a .htaccess file with some mod_rewrite rules or not. As Wordpress can’t find out on it’s own on my host I just had to help it a little ;)

In wp-includes/vars.php on line 40 is the check for the hosting webserver, I changed the entire line to read

$is_apache = 1;

After this small modification Worpress happily updatet the .htaccess file with the apropriate mod_rewrite rules (given the file permissions are correct on the server).

One small sidenote: If you are using FAlbum and have “friendly urls” enabled you have to make sure that the rewrite rules made by FAlbum are above the ones from Wordpress.

Written by Florian Beer in: blog, server
rel-tag , , , , ,

May
22
2005
1

SSL Zertifikat erstellen

Bei den Eisenstädter Linuxwochen habe ich von einer wirklich netten organisation namens CaCert erfahren. CaCert stellt gratis Zertifikate aller Art aus.

Also dachte ich mir, machen wir uns doch mal daran und erstellen uns so ein Ding für den Server …. naja, leichter gesagt als getan, aber nichts was ein wenig Googlen nicht herausfinden könnte :)

Simple SSL cert HOWTO

- Make a new ssl private key:

Generate a new unencrypted rsa private key in PEM format:
openssl genrsa -out privkey.pem 1024
You can create an encrypted key by adding the -des3 option.

- To make a self-signed certificate:

Create a certificate signing request (CSR) using your rsa private key:
openssl req -new -key privkey.pem -out certreq.csr
( This is also the type of CSR you would create to send to a root CA for them to sign for you. )

Self-sign your CSR with your own private key:
openssl x509 -req -in certreq.csr -signkey privkey.pem -out newcert.pem

- To make a certificate signed by your own certificate authority (CA):

Configure /etc/ssl/openssl.cnf and use CA.pl to create the CA private key and certificate:
vi /etc/ssl/openssl.cnf
/usr/lib/ssl/misc/CA.pl -newca

Your copy of openssl.cnf and CA.pl may be located elsewhere.

Create an unsigned certificate using your rsa private key:
openssl req -new -x509 -key privkey.pem -out cert.pem
Use your private key and your certificate to make a CSR:
cat cert.pem privkey.pem | openssl x509 -x509toreq -signkey privkey.pem -out certreq.csr
Sign the certificate with the CA private key using the CSR you just made:
openssl ca -in certreq.csr -out newcert.pem
rm -f certreq.csr

- To install the signed certificate and private key for use by an ssl server:

The newcert.pem is the certificate signed by your local CA that you can then use in an ssl server:
( openssl x509 -in newcert.pem; cat privkey.pem ) > server.pem
ln -s server.pem `openssl x509 -hash -noout -in server.pem`.0 # dot-zero

( The server.pem is a PEM file that can be used by apache along with the hash file. )

You can view the contents of a CSR with:
openssl req -noout -text -in certreq.csr
You can view the contents of a certificate with:
openssl x509 -noout -text -in newcert.pem
You can display the MD5 fingerprint of a certificate with:
openssl x509 -fingerprint -noout -in newcert.pem
You can verify that your private key, CSR, and signed cert match by comparing:
openssl rsa -noout -modulus -in privkey.pem |openssl md5
openssl req -noout -modulus -in certreq.csr |openssl md5
openssl x509 -noout -modulus -in newcert.pem |openssl md5

Written by Florian Beer in: server
rel-tag , ,

Mar
30
2005
2

Custom Apache Errors

Ich habe mich endlich mal dran gemacht ein paar spassigere HTTP Error Messages für den Apache hier zu basteln. Die standardmässigen sind einfach zu langweilig. Hirschy war so nett mich mal mit ein paar netten Sprüchen zu versorgen.

Die Fehler werden alle von einem Script abgefangen, dem der Statuscode übergeben wird.
>>> Sourcecode

Im Apache muss nur noch in der httpd.conf für jede abgefangene Fehlermeldung ein Eintrag gemacht werden:

# Custom Response Messages
ErrorDocument 402 http://no-panic.at/error.php?e=402
ErrorDocument 403 http://no-panic.at/error.php?e=403
ErrorDocument 404 http://no-panic.at/error.php?e=404
ErrorDocument 405 http://no-panic.at/error.php?e=405
ErrorDocument 406 http://no-panic.at/error.php?e=406
ErrorDocument 407 http://no-panic.at/error.php?e=407
ErrorDocument 409 http://no-panic.at/error.php?e=409
ErrorDocument 410 http://no-panic.at/error.php?e=409
ErrorDocument 411 http://no-panic.at/error.php?e=411
ErrorDocument 414 http://no-panic.at/error.php?e=414
ErrorDocument 415 http://no-panic.at/error.php?e=415
ErrorDocument 417 http://no-panic.at/error.php?e=417

—————————————————–
Wichtig!
Die Direktive für den Fehler 401 MUSS ein lokaler Redirect sein, da sonst nicht der richtige Response an den Client geschickt wird und daher vermutlich keine Aufforderung zur Passwort eingabe erfolgt.
—————————————————–

Leider hab ich keine Möglichkeit gefunden, wie man das ganze bewerkstelligen kann ohne einen externen Redirect zu machen (mittels http://…) sodass es trotzdem für alle Domains auf diesem Server gilt. Wenn jemand Ideen hat, wäre ich sehr erfreut :) (evtl. mittels mod_rewrite ?).
Wenn man intern weiterleitet hat man nämlich den Vorteil, dass etliche Variablen vom Server gleich gesetzt werden, man müsste also nichtmal den Response Code per GET übergeben, sondern könnte ihn direkt in PHP per $_SERVER['REDIRECT_STATUS'] auslesen. Zusätzlich würden noch einige andere sehr interessante Variablen gesetzt werden, die man dann weiterverarbeiten kann.

Anschließend noch ein paar Beispiele:

Vorschläge zu weiteren Error Messages sind bitte erwünscht!
Auch Ideen, welche Bilder man bei den jeweiligen Messages verwenden könnte.
Fragen, Wünsche und vor allem Ergänzungen/Anmerkungen zum PHP Code sind ausdrücklich erbeten ;)

Written by Florian Beer in: linux, server
rel-tag , ,