0

I'm trying to set up a website on my machine, and am having some trouble. I've prototyped the website using Flask and the debug server, and now would like to host it for a bit while I further debug it. This is only for internal use within my company network.

I cannot seem to get Apache configured correctly. I currently run a default site that links to my home directory, so I can grab files from other machines through a web browser.

I haven't changed my apache2.conf at all, but here's my httpd.conf

<Location /server-status>
    SetHandler server-status

    Order Deny, Allow
    Deny from all
    Allow from .mycompany.com
</Location>

My default config, located within /etc/apache2/sites-available/default, has

<VirtualHost *:80>
    ServerAdmin [email protected]

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinksMultiViews
        AllowOverride None
        Order allow,deny
        allow from .mycompany.com
    </Directory>
    <Directory /var/www/home/>
        Options Indexes FollowSymLinks MultiViews
        AllowOVerride None
        Order allow,deny
        allow from .mycompany.com
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

While the app I'm trying to enable has the following config file, located at /etc/apache2/sites-available/Powermon

LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so

User p_user
Group p_group
FastCgiServer /home/p_user/Powermon/runp.fcgi -idle-timeout 300 -processes 5

<VirtualHost *:80>
    ServerName powermon
    DocumentRoot /home/p_user/Powermon/app/static
    Alias /static /home/p_user/Powermon/app/static

    AddHandler fastcgi-script fcgi
    ScriptAlias / /home/p_user/Powermon/runp.fcgi

    ErrorLog /home/p_user/Powermon/logs/powermon_error_log

    <Location />
        SetHandler fastcgi-script
    </Location>
</VirtualHost>

Within sites-enabled I saw

000-default -> ../sites-available/default

So I added

010-powermon -> ../sites-available/Powermon

And when I run apache2ctl -S I see

VirtualHost configuration:
wildcard NameVirtualHosts and _default_servers:
*:80            is a NameVirtualHost
    default server dhcp-ip-address.mycompany.com (/etc/apache2/sites-enabled/000-default:1)
    port 80 namevhost dhcp-ip-address.mycompany.com (/etc/apache2/sites-enabled/000-default:1)
    port 80 namevhost powermon (/etc/apache2/sites-enabled/010-powermon:7)
Syntax OK

So currently when I go to machine-name/ in a browser, I can navigate my home directory and look at files as needed. Ideally I want to be able to go to machine-name/powermon and see my app running.

2 Answers 2

0

You say you want to setup Apache virtual hosts, but then you say this:

So currently when I go to machine-name/ in a browser, I can navigate my home directory and look at files as needed. Ideally I want to be able to go to machine-name/powermon and see my app running.

A path on a host is not a virtual host. Your config is set as follows: Traffic to powermon goes to one config. Traffic to dhcp-ip-address.mycompany.com goes to another config.

So the only way that an Apache virtual host setup would work is you go to this URL and get one thing:

dhcp-ip-address.mycompany.com

Then go to this URL & get another thing:

powermon

The only way to really achieve this via Apache virtual host setup is to alter your web browsing client’s /etc/hosts file like this. Let’s assume these virtual hosts are on a server with the IP address 123.456.78.90. Open up your hosts file—I am on a Mac so this is how I would do it—via nano like this:

sudo nano /etc/hosts

And add this line to the bottom of the file:

123.456.78.90 powermon

Now when you point your web browser to:

http://powermon

You will get the Apache virtual host setup you have in place.

But again, you are mixing up the concept of a server path with a server virtual host. So you need to iron that out before you do anything else. Also, your virtual host config for powermon seems disjointed. The items outside of <VirtualHost *:80> should go inside. Otherwise those config options just get used by the server-wide default config anyway. And the User & Group settings seem kludgy as well. The scripts should be set to be usable by the Apache user & group. Not the other way around. But assuming good faith, this is how I would structure it:

User p_user Group p_group

ServerName powermon DocumentRoot /home/p_user/Powermon/app/static Alias /static /home/p_user/Powermon/app/static

    LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so

    FastCgiServer /home/p_user/Powermon/runp.fcgi -idle-timeout 300 -processes 5

    AddHandler fastcgi-script fcgi
    ScriptAlias / /home/p_user/Powermon/runp.fcgi

    ErrorLog /home/p_user/Powermon/logs/powermon_error_log

    <Location />
        SetHandler fastcgi-script
    </Location>

</VirtualHost>
2
  • Thanks for your very detailed explanation! I haven't gotten it up quite yet, but I think I have a good idea of what to do. Just to add, compiling the config you posted, I got an error User cannot occur within <VirtualHost> section.
    – polkid
    Apr 8, 2014 at 22:51
  • @polkid, Okay, that error makes sense. But then also confuses the user/group setup for a virtual host. It might be better to set the p_user and p_group to match the Apache server user & group instead. The server dictates user/group for scripts. Edited my answer to reflect this. Apr 8, 2014 at 23:54
-1

Are you sure, you created soft link to file: /etc/apache2/sites-available/Powermon ?

Some, like:

cd /etc/apache2/sites-enabled/
ln -s ../sites-available/Powermon
1
  • His output for apache2ctl -S clearly shows it enabled: port 80 namevhost powermon (/etc/apache2/sites-enabled/010-powermon:7) Apr 8, 2014 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .