In an earlier post I described how to set up a Slicehost server to run GemStone/S and we demonstrated serving web pages using a Smalltalk web server. In this post we look at installing and configuring Apache and FastCGI so that you can run Seaside in GemStone/S behind Apache.
Start by logging in to your Slice (I’ve created an alias name ‘slice’ for this command):
ssh -p 30000 glass@slice
Next, install Apache:
install apache2 apache2.2-common apache2-mpm-prefork apache2-utils \ libexpat1 ssl-cert apache2-threaded-dev
Now you should be able to navigate to your site and see the words “It Works!” by entering the following in a browser:
http://slice/
GLASS can be configured to use FastCGI and we need to download, build, install, and enable it:
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz tar zxvf mod_fastcgi-current.tar.gz cd mod_fastcgi* cp Makefile.AP2 Makefile make top_dir=/usr/share/apache2 sudo make install top_dir=/usr/share/apache2
Create a file that will load the FastCGI module (we will enable it later):
echo "LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so" \ > fastcgi.load sudo mv fastcgi.load /etc/apache2/mods-available/
Now we need to configure Apache to route requests to GemStone/S. Apache has a rich set of configuration options, including places to put config files. The basic model is that Apache reads /etc/apache2/apache2.conf and that file has a series of includes that pull in other files. Following the general spirit of how Apache seems to expect things, we can add a configuration file that references another config file:
echo "Include /opt/gemstone/etc/apache2.conf" > glass sudo mv glass /etc/apache2/sites-available/
Now we need to create some directories and set some permissions.
chmod 775 /opt/gemstone cd /opt/gemstone mkdir etc www www/glass1 www/glass2 www/glass3
Now we can create our Apache config file named /opt/gemstone/etc/apache2.conf and past the following lines (edit the second line that has an email address):
ServerName glass ServerAdmin webadmin@yourdomain.com Listen 8081 Listen 8082 Listen 8083 FastCgiExternalServer /opt/gemstone/www/glass1/seaside \ -host localhost:9001 -pass-header Authorization FastCgiExternalServer /opt/gemstone/www/glass2/seaside \ -host localhost:9002 -pass-header Authorization FastCgiExternalServer /opt/gemstone/www/glass3/seaside \ -host localhost:9003 -pass-header Authorization <VirtualHost *:80> DocumentRoot /opt/gemstone/www CustomLog /opt/gemstone/log/glass-access.log combined ErrorLog /opt/gemstone/log/glass-error.log LogLevel info <Directory "/opt/gemstone/www"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> <Proxy /seaside> AddDefaultCharset off Order allow,deny Allow from all </Proxy> ProxyPreserveHost On #make proxy rewrite urls in the output ProxyPass /seaside balancer://gemtrio ProxyPassReverse /seaside balancer://gemtrio <Proxy balancer://gemtrio> Order allow,deny Allow from all BalancerMember http://localhost:8081/seaside BalancerMember http://localhost:8082/seaside BalancerMember http://localhost:8083/seaside </Proxy> </VirtualHost> <VirtualHost *:8081> CustomLog /opt/gemstone/log/glass-vhost-8081-access.log combined ErrorLog /opt/gemstone/log/glass-vhost-8081-error.log LogLevel warn DocumentRoot /opt/gemstone/www/glass1 </VirtualHost> <VirtualHost *:8082> CustomLog /opt/gemstone/log/glass-vhost-8082-access.log combined ErrorLog /opt/gemstone/log/glass-vhost-8082-error.log LogLevel warn DocumentRoot /opt/gemstone/www/glass2 </VirtualHost> <VirtualHost *:8083> CustomLog /opt/gemstone/log/glass-vhost-8083-access.log combined ErrorLog /opt/gemstone/log/glass-vhost-8083-error.log LogLevel warn DocumentRoot /opt/gemstone/www/glass3 </VirtualHost>
Now we are ready to enable the new site and restart Apache:
sudo a2enmod proxy_balancer sudo a2enmod proxy_http sudo a2enmod fastcgi sudo a2dissite 000-default sudo a2ensite glass sudo apache2ctl restart
Create a new home page:
echo '<html><body><h1><a href="seaside">Seaside Rocks!</a></h1></body></html>' \ > /opt/gemstone/www/index.html
If there are no errors, then you should be able to view the new home page by refreshing your web browser. Now we need to start GemStone and start some Gems:
source /opt/gemstone/product/seaside/defSeaside startGemstone runSeasideGems start
At this point you should be able to refresh your browser and follow the link to Seaside. You can log out of the Slicehost virtual private server at this point and leave GemStone/S running.
4 comments
Comments feed for this article
September 12, 2008 at 1:17 pm
[|]
What if we want Apache to serve the static files?
What do we have to do?
September 12, 2008 at 2:47 pm
James Foster
In the above apache2.conf the only thing being handled by GemStone is what comes through the proxy from the /seaside directory. Any request not referencing the /seaside directory will be served by Apache directly (without going to the proxy handler). For example, we created a new home page at /opt/gemstone/www/index.html and this is a static page served by Apache. You can create other directories and documents. As an experiment, I created a document /opt/gemstone/www/images/bglines.gif, and modified the body tag in index.html to have the following (I’ve left out the angle-brackets):
body background=”images/bglines.gif”
When I refreshed the main page, the background displayed the image being served by Apache. You could do the same with CSS, JavaScript, and other images.
September 27, 2008 at 11:24 am
Miguel Cobá
I have configured Gemstone/S with lighttpd and fastcgi. You can read about in:
http://leugim.com.mx/blog/2008/09/gemstones-and-fastcgi-with-lighttpd.html
By the way, Gemstone/S it is amazing.
Miguel Cobá
January 10, 2010 at 2:14 pm
FastCGI is slow to close connection? « Programming Gems (on GemStone)
[…] 10, 2010 in Uncategorized I’ve recently been building a new slice and following my own instructions on how to build the FastCGI library. One problem was that pages seemed to load quite slowly, and […]