Mit ‘webserver’ getaggte Artikel
Symfony + Hiawatha
Da wir seit Längerem schon Symfony einsetzen, wissen wir, dass durch Caching eine ganze Menge an Geschwindigkeit herausgekitzelt werden kann. Manchmal jedoch eben nicht mehr, und dann stellt sich die Frage, an welchen Schräubchen noch geschraubt werden kann.
In unserem Fall war es eine Applikation, die sehr viel AJAX verarbeitet. Wenig erfreut über die Performance und den Speicherhunger von Apache 2.2 schauten wir uns nach einer schnellen und soliden Lösung um. Diese fanden wir: sie heißt Hiawatha. Die Gründe für Hiawatha liegen einerseits im extrem kleinen Memory-Footprint und andererseits im ausgereiften URL-Toolkit, welches URL-Rewriting relativ einfach macht. Gängige Regeln für alle möglichen WebApps sind ebenfalls auf der Website zu finden.
Erste Belastungstests mit Apaches “ab”-Tool ergaben eine Performancesteigerung von 50% bei dynamischen Seiten – also fast alles, was Symfony an XHR-Requests verarbeitet. Inzwischen läuft der Server im Produktivbetrieb und wir müssen dem Entwickler Hugo Leisink zustimmen: das Konzept des kleinen Servers geht voll auf!
Jetzt aber zum HowTo:
HOWTO Setup Symfony with Hiawatha on Debian
OK, let’s start with the usual development environment: We need to build the hiawatha-package the debian way.
Prerequisites
Logon to your Server as root and execute the following commands:
aptitude install libc6-dev libssl-dev make dpkg-dev debhelper fakeroot libxml2-dev libxslt1-dev
Now you need PHP5 and a database for Symfony, in this HowTo we use MySQL:
aptitude install php5-cgi php5-mysql php5-gd mysql-server
Installation
Now fetch the Hiawatha package, compile and install it:
cd appname="hiawatha-7.4" wget http://www.hiawatha-webserver.org/files/${appname}.tar.gz tar -xzf {appname}.tar.gz cd ${appname} ./configure make make deb cd .. dpkg -i ${appname}_i386.deb
You’re done!
Configuration
Now we’re going to configure the server:
Edit /etc/hiawatha/hiawatha.conf to your needs:
ServerString = none ConnectionsTotal = 150 ConnectionsPerIP = 20 ... Binding { Port = 80 # HTTP-POSTs should work up to 20MB upload: MaxRequestSize = 20480 } ... FastCGIserver { FastCGIid = PHP5 ConnectTo = 127.0.0.1:2005 Extension = php } ... Include /etc/hiawatha/sites-enabled
Create a directory for all your virtual hosts-definitions:
mkdir -p /etc/hiawatha/sites-enabled
Now you need to uncomment line 25 in /etc/hiawatha/php-fcgi.conf to activate the fastCGI-Server:
Server = /usr/bin/php5-cgi ; 127.0.0.1:2005 ; www-data
Speed up PHP with xCache:
aptitude install php5-xcache # configure: sed -i -e 's/xcache.size =.*/xcache.size = 32M/' /etc/php5/conf.d/xcache.ini sed -i -e 's/xcache.count =.*/xcache.count = 2/' /etc/php5/conf.d/xcache.ini sed -i -e 's/xcache.var_size =.*/xcache.var_size = 16M/' /etc/php5/conf.d/xcache.ini
Finally, restart both the Webserver and the fastCGI-Server:
/etc/init.d/php-fcgi restart && /etc/init.d/hiawatha restart
“Install” Symfony
Put your Symfony-Project for this HowTo in /var/www/mysite.com/.
First, create the appropriate dir and put Symfony into it:
mkdir -p /var/www/mysite.com cd /var/www/mysite.com mkdir -p lib/vendor
Second, download Symfony:
mysymfony=symfony-1.4.8 cd lib/vendor rm -r symfony wget http://www.symfony-project.org/get/$mysymfony.tgz tar zxpf $mysymfony.tgz mv $mysymfony symfony rm $mysymfony.tgz cd ../..
Does it work? – Check your installation:
php lib/vendor/symfony/data/bin/symfony -V
This command should show you the following output:
symfony version 1.4.8 (/var/www/mysite.com/lib/vendor/symfony/lib)
Now you’re able to create a project for test purposes:
php lib/vendor/symfony/data/bin/symfony generate:project mysite # and create the needed symlinks (as root!) cd web ln -s ../lib/vendor/symfony/data/web/sf sf ln -s ../lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/web sfDoctrinePlugin cd ..
Now create a vHost-File for your Symfony-Project, e.g. /etc/hiawatha/sites-available/mysite.com and put the following content into it:
UrlToolkit { ToolkitID = symfony RequestURI isfile Return Match ^/favicon.ico$ Rewrite /images/favicon.png Match .* Rewrite /index.php } VirtualHost { WebsiteRoot = /var/www/mysite.com/web Hostname = mysite.com, www.mysite.com StartFile = index.php UseFastCGI = PHP5 UseToolkit = symfony EnablePathInfo = yes AccessLogfile = /var/log/hiawatha/mysite.com-access.log ErrorLogfile = /var/log/hiawatha/mysite.com-error.log }
There you are! Fast and simple…
If you want to host multiple projects on a server just move the UrlToolkit into the main-config (/etc/hiawatha/hiawatha.conf) and reuse it for all further virtual hosts.



