1

I bought a VPS for my new project running apache.
On it I have 2 websites on the same domain.
The first one is Ruby on Rails /var/www/html
The second one is Wordpress /var/www/blog

I want Wordpress to act like a subdirectory of ruby ( /blog).
Ruby on Rails website works, but if i go to /blog it just says that the page im looking is not available(with RoR 404 template)

Conf for RoR:

<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile /etc/apache2/certificate/apache-certificate.crt
        SSLCertificateKeyFile /etc/apache2/certificate/apache.key
  
</VirtualHost>

Conf for Wordpress:

<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/blog
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile /etc/apache2/certificate/apache-certificate.crt
        SSLCertificateKeyFile /etc/apache2/certificate/apache.key
        Alias /blog /var/www/blog
</VirtualHost>

Maybe the solution is a htacces file in /var/www. Can you pleasep point me? Thank you !

1 Answer 1

0

On it I have 2 websites on the same domain.

Well, you actually have 1 website (1 domain). It's just that you have WordPress in a subdirectory of that 1 website. Consequently, you should only have 1 <VirtualHost> container, not 2 - which is where you would seem to be going wrong here.

The second <VirtualHost> is not being used and should be removed.

You need to move the Alias /blog /var/www/blog directive into the first <VirtualHost> container and allow access to this directory by including the following inside the vHost container:

# WordPress
<Directory /var/www/blog>
    # Permit access to this area
    Require all granted

    # Allow per-directory overrides if want to use WP htaccess file
    AllowOverride All
</Directory>

I assume you must already have something similar for /var/www/html/public?

You should really include a ServerName directive inside this vHost container, otherwise, this is just acting as the "default" by being defined first. For example:

# Declare the hostname that this vHost defines
ServerName example.com

And then define a "default" vHost container before this that catches non-canonical requests.

8
  • This is my defaultconf:
    – Adelle
    Commented Jun 2, 2021 at 0:48
  • This is my defaultconf: <VirtualHost *:443> ServerName fdcb.site Alias /blog /var/www/blog ServerAdmin webmaster@localhost DocumentRoot /var/www/html/public SSLEngine on SSLCertificateFile /etc/apache2/certificate/apache-certificate.crt SSLCertificateKeyFile /etc/apache2/certificate/apache.key # WordPress <Directory /var/www/blog> # Permit access to this area Require all granted # Allow per-directory overrides if want to use WP htaccess file AllowOverride All </Directory> </VirtualHost>
    – Adelle
    Commented Jun 2, 2021 at 0:54
  • i created a file fdcb.site/blog/a.php and it is accesible, but index.php is not. i have disabled htaccess file, tried some things inside it, but again, i dont have the skills. have to say i tried many methods just to bypass server settings. tried to make it run in public, installed wordpress from terminal. came here after many hours of failing. Thank you for your help
    – Adelle
    Commented Jun 2, 2021 at 1:03
  • @Adelle "i created a file fdcb.site/blog/a.php and it is accessible" - and a.php is physically located at /var/www/blog/a.php? In that case, this would seem to have answered your question. (In which case you should mark it as "accepted" - tick/checkmark on the left below the voting arrows. Once you have 15+ rep then you can also upvote answers you find useful. Thanks, much appreciated. :)
    – MrWhite
    Commented Jun 2, 2021 at 1:24
  • @Adelle "but index.php is not" - presumably you mean when accessing the /blog/ subdirectory? This is a different problem. For index.php to be served when requesting a directory, you need to set DirectoryIndex index.php in the appropriate <Directory> container.
    – MrWhite
    Commented Jun 2, 2021 at 1:27

You must log in to answer this question.

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