Score:0

How to configure two applications on apache2

ng flag

What I would like to achieve is to get two separate links linking to two different applications.

http://hostname.com <--- wordpress

http://hostname.com/openproject/ <--- openproject or eventually http://openproject.hostname.com/ but this I guess would require actions on my VPS provider.

First application would be wordpress blog with configuration such as:

/etc/apache2/sites-enabled/wordpress.conf

<VirtualHost *:80>
        ServerAdmin admin@HOSTNAME_HERE.com
        DocumentRoot /var/www/HOSTNAME_HERE/wordpress/
        Redirect / https://HOSTNAME_HERE.com/
        <Directory /var/www/HOSTNAME_HERE/wordpress/>
                Options +FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/etc/apache2/conf-enabled/wordpress.conf

Alias /wordpress /var/www/HOSTNAME_HERE/wordpress
<Directory /var/www/HOSTNAME_HERE/wordpress>
    Options FollowSymLinks
    DirectoryIndex index.php
    <IfModule mod_php.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
    </IfModule>
</Directory>
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authz_core.c>
        <IfModule mod_authn_file.c>
            AuthType Basic
        </IfModule>
        Require valid-user
    </IfModule>
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Require all denied
</Directory>

available with SSL through

/etc/apache2/sites-enabled/default-ssl.conf

<IfModule mod_ssl.c>
        <VirtualHost *:443>
                ServerAdmin admin@HOSTNAME_HERE.com
                ServerName ip.address.of.hostname
                DocumentRoot /var/www/HOSTNAME_HERE/wordpress/
                <Directory /var/www/HOSTNAME_HERE/wordpress/>
                     Options +FollowSymLinks
                     AllowOverride All
                     Order allow,deny
                     allow from all
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                SSLProtocol         all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
                SSLCipherSuite      ECDHE-ECDSA-AES256-GCM-SHA384...
                SSLHonorCipherOrder on
                SSLCompression      off
                SSLSessionTickets   off
                SSLCertificateFile      /etc/apache2/ssl/certificate.crt
                SSLCertificateKeyFile /etc/apache2/ssl/pkey.key
                SSLCertificateChainFile /etc/apache2/ssl/chain-ca.crt
                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
        </VirtualHost>
</IfModule>

Second application would be openproject configured via:

etc/apache2/mods-enabled/passenger.load

LoadModule passenger_module /home/openproject/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/passenger-6.0.10/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /home/openproject/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/passenger-6.0.10
  PassengerDefaultRuby /home/openproject/.rbenv/versions/2.7.3/bin/ruby
</IfModule>

/etc/apache2/sites-enabled/openproject.conf

SetEnv EXECJS_RUNTIME Disabled
<VirtualHost *:8080>
   ServerName IP_ADDR_HERE
   DocumentRoot /home/openproject/openproject/public
   <Directory /home/openproject/openproject/public>
      AllowOverride all
      Options -MultiViews
      Require all granted
   </Directory>
   <Location /assets/>
     ExpiresActive On ExpiresDefault "access plus 1 year"
   </Location>
</VirtualHost>

Application is available without SSL on http://HOSTNAME_HERE.com:8080 and any configuration which I have tried would work to host this application on http://HOSTNAME_HERE.com/openproject/

configuration which I have tried on /etc/apache2/sites-enabled/openproject.conf

SetEnv EXECJS_RUNTIME Disabled
<VirtualHost *:80>
    ServerName IP_ADDR_HERE
    DocumentRoot /home/openproject/openproject/public
    ProxyPass /openproject/ http://127.0.0.1:6002/openproject/ retry=0
    ProxyPassReverse /openproject/ http://127.0.0.1:6002/openproject/
   <Directory /home/openproject/openproject/public>
      AllowOverride all
      Options -MultiViews
      Require all granted
   </Directory>
   <Location /assets/>
     ExpiresActive On ExpiresDefault "access plus 1 year"
   </Location>
</VirtualHost>

Another try:

SetEnv EXECJS_RUNTIME Disabled
<VirtualHost *:80>
   ServerName IP_ADDR_HERE
   DocumentRoot /home/openproject/openproject/public
   Alias /openproject/ /home/openproject/openproject/public
   <Directory /home/openproject/openproject/public>
      AllowOverride all
      Options -MultiViews
      Require all granted
   </Directory>
   <Location /assets/>
     ExpiresActive On ExpiresDefault "access plus 1 year"
   </Location>
</VirtualHost>

Another try:

SetEnv EXECJS_RUNTIME Disabled
<VirtualHost *:80>
   ServerName IP_ADDR_HERE/openproject/
   DocumentRoot /home/openproject/openproject/public

   <Directory /home/openproject/openproject/public>
      AllowOverride all
      Options -MultiViews
      Require all granted
   </Directory>
   <Location /assets/>
     ExpiresActive On ExpiresDefault "access plus 1 year"
   </Location>
</VirtualHost>

and nothing was working. I have received either 301 or 403 or 404 errors. Please help me with my setup.

PS application internally is running on 6002 port

digijay avatar
mx flag
Your config is missing any `ServerName HOSTNAME_HERE.com` so you won't be able to call your webserver by your domain name.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.