plainblack.com
Username Password
search
Bookmark and Share
Subscribe

Running separate instance of apache with WRE

Wouldn't it be nice if you could have your very own, package based installation of Apache on the same server that you run the WRE on?  An instance of Apache where you could run whatever applications you wanted and install any applications out there that have packages easily?  And wouldn't it be sweet if you could do this and still have the WRE run right next to it serving WebGUI along side your other apps without breaking it and being completely transparent to your site visitors?  Well, it turns out this is very easy to do and in this article I tell you how.

Let's define what we're going to accomplish.  This will all be done on a working instance of WebGUI using the WRE ( try it on a dev server first so you're not breaking your live site while you play ).  For this example I am using CentOS 5 with WRE 0.7.2 and WebGUI 7.3.22 already installed, up and running.  Here are our goals:

1. Install the apache, php, and php-mysql packages using yum.
2. Configure this instance of apache to listen on port 82.
3. Configure mod_proxy apache in the WRE to send all of the traffic for a new domain (vhost) to our OS based apache, transparently to the end-user.

(If you *just* need to serve static pages from a directory, and don't need to be able to install special modules into the Apache instance, then this is overkill for you; go check out How To Configure a Static, non-WebGUI site.)

Lets get started.  First we need to install our packages.

Install Packages
# yum install apache
# yum install php
# yum install php-mysql

Next, we need to tell our newly installed instance of apache to run on a different port than the two instances of apache that come with the WRE out of the box.  To do that we need to change a single line in the new instance httpd.conf file. 

/etc/httpd/conf/httpd.conf
# Change the Listen directive to port 82 (or any unused port)
Listen 82

Now, since it's highly likely that whatever we'll be using our new instance of apache to run will require a database of some kind, why not use the one that comes with the WRE?  This will keep our data in one place AND will allow easy access to the data from WebGUI if you so desire ( such as the SQL Report for example ).  To do this, we need to tell PHP where the MySQL socket file is because the WRE does not place it in the standard location.  Edit your php.ini file and change the following line. 

/etc/php.ini
mysql.default_socket = /data/wre/prereqs/mysql/mysql.sock

Now, let's test what we have so far.  We want to make sure that Apache is listening on port 82, that PHP is working, and that it is looking for the MySQL socket in the correct place.  This is very easy.  Let's create a PHP test script and place it in the new instance of Apache's webroot, start everything up and see what we got.

/var/www/html/index.php
<?php phpinfo(); ?>

Time to start it all up.

Start apache
# service httpd start

Goto your website address that you use for your WebGUI site.  For example, www.snapcount.org but you need to append the port number to the end so it would look like this: www.snapcount.org:82/

If everything has gone to plan you should see a PHP test page.  Make sure the MySQL section shows our new MySQL socket location of /data/wre/prereqs/mysql/mysql.sock

Ok, everything is good but it kinda sucks that the user will have to remember to put a port number in the URL anytime they visit a site hosted on your new instance of apache!  Aside from that, I promised you this would be transparent to the user.  Enter the mod_proxy instance of the WRE's apache.  We're going to create a vhost for our new site and use mod_proxy for our site the exact same way WebGUI does.

Create a new .modproxy file in your /data/wre/etc directory that is named after the sites hostname. 

/data/wre/etc/www.mynewsite.com.modproxy
<VirtualHost *:80>
ServerName www.mynewsite.com
CustomLog /var/log/apache/logs/www.mynewsite.com.access_log combined
DocumentRoot /var/www/html
RewriteEngine On
RewriteLog "/data/wre/prereqs/apache/logs/modrewrite.log"
RewriteLogLevel 0

# proxy our OS apache
RewriteRule ^/(.*) http://www.mynewsite.com:82/$1 [P]
</VirtualHost>

Let's put this change in place... to do so we need to restart the WRE's modproxy instance of apache.

Restart modproxy apache
# service webgui restartmodproxy

or if that doesn't work

# /data/wre/sbin/rc.webgui restartmodproxy
or if that doesn't work

#/data/wre/sbin/wreservice.pl --restart modproxy

Now we should be able to goto www.mynewsite.com and see our glorious PHP test page.  And if you look in your browser bar, you'll notice that there is no port 82 in the URL.  Spiffy eh?

To finish things up we probably want to tell CentOS to start our new copy of apache every time the server starts.

Start new apache with the server
# chkconfig httpd on

You should also check your WebGUI site to make sure it is still working as well.  If there is a problem to undo this you can delete the .modproxy file you created for your new site, shutoff the new instance of apache you created and restart WRE's modproxy.

This should get your creative juices flowing, there are a lot of cool things you can do with this setup and most importantly enjoy the best of both worlds... a simple WebGUI install and a separate apache that you're used to for everything else all on the same server. 

 

This was taken from: a cached page from google search - because I needed these instructions. Originally posted on feeds.snapcount.org by Roy Johnson 9/6/2007 :

Keywords: apache Installation multi-site WRE

Search | Most Popular | Recent Changes | Wiki Home
© 2018 Plain Black Corporation | All Rights Reserved