logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache2 only partially loading a page
Author
Obsdark



Joined: 22 Apr 2021
Posts: 12

PostPosted: Fri 14 Jul '23 22:08    Post subject: Apache2 only partially loading a page Reply with quote

Hello there,

I uploaded a laravel 10 project to an ubuntu 22 server with apache2, the thing is, just the starting position is showed by the laravel, the other ones are not and aren't even found at all by the apache.

the relevant parts of the apache2 config file are: https://hastebin.com/share/ohejewoyil.php

I suspect the apache2 is unable to find them but i don't know how to correct it, any suggestions or help?

Have a nice day
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Mon 17 Jul '23 12:54    Post subject: Reply with quote

IIRC Lavaravel requires the use of .htaccess files.
So instead of Options None You may allow overrides

Code:
Options AllowOverride
.
Back to top
Obsdark



Joined: 22 Apr 2021
Posts: 12

PostPosted: Tue 18 Jul '23 0:35    Post subject: Reply with quote

Could you develop a little bit more?

Like, i just remove the "None" of the three related segments?

How can i apply what you suggest?

I ask this because i do remove all the "None" in the three blocks and it doesn't work
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Tue 18 Jul '23 11:51    Post subject: Reply with quote

replace the Options None with Options AllowOverride.
After that restart httpd (apache)

Code:

<VirtualHost *:80>
    DocumentRoot /var/www/html/VirtualDocs/public
    ServerName VirtualDocs.test
    <Directory "/var/www/html/VirtualDocs/public">
        allow from all
        Options AllowOverride
        Require all granted
    </Directory>
</VirtualHost>
Back to top
Obsdark



Joined: 22 Apr 2021
Posts: 12

PostPosted: Wed 19 Jul '23 1:49    Post subject: Reply with quote

Doesn't work, it returns this error:

is an Ubuntu 22 if that matters at all

https://hastebin.com/share/paxigimacu.vbnet
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 20 Jul '23 8:33    Post subject: Reply with quote

"allow from all" can be removed, that is the old syntax. "Require all granted" does the job in version 2.4.

Sorry, for the mistake.

Correct is
Code:


<VirtualHost *:80>
    DocumentRoot /var/www/html/VirtualDocs/public
    ServerName VirtualDocs.test
    <Directory "/var/www/html/VirtualDocs/public">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
Back to top
Obsdark



Joined: 22 Apr 2021
Posts: 12

PostPosted: Thu 20 Jul '23 18:39    Post subject: Reply with quote

It doesn't work

I mean, it doesn't drop any error that stop it from work like before but doesn't fix the main issue that bring me here either, and the issue itself is very weird, let me show you with images maybe that help to have a clear picture about it:

This is the arriving page:

https://imgur.com/a/8e4XpiQ

This is Any other page after that:

https://imgur.com/a/VVPci47

And let me assure you than both pages work perfectly in local.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Sat 22 Jul '23 13:59    Post subject: Reply with quote

It seems like mod rewrite is no loaded.
Back to top
Obsdark



Joined: 22 Apr 2021
Posts: 12

PostPosted: Mon 24 Jul '23 17:37    Post subject: Reply with quote

Can you develop a little bit what do you mean by that?

And how can i fix it?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 27 Jul '23 8:22    Post subject: Reply with quote

The 404 URLs are redirected to the index.php since those are only virtual paths that don't exist as files on the system. Like your "contracto" URL.

So you may try to enable mod_rewrite

Code:

sudo a2enmod rewrite
sudo systemctl restart apache2
Back to top
Obsdark



Joined: 22 Apr 2021
Posts: 12

PostPosted: Sun 30 Jul '23 17:59    Post subject: Reply with quote

James Blond wrote:
The 404 URLs are redirected to the index.php since those are only virtual paths that don't exist as files on the system. Like your "contracto" URL.

So you may try to enable mod_rewrite

Code:

sudo a2enmod rewrite
sudo systemctl restart apache2


ĦThanks a lot!

It works like a Charm

I just came back here to say thank you about this.

Can i ask if may there is a way to set the virtualhost in order to publish two laravels at the same time?

Considering the virtualhost you already see here.

And again, thanks a lot, ĦIt Works!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Mon 31 Jul '23 11:40    Post subject: Reply with quote

The easiest way is to add another vhost.
Back to top
Obsdark



Joined: 22 Apr 2021
Posts: 12

PostPosted: Mon 31 Jul '23 23:39    Post subject: Reply with quote

Try that, i experiment a little bit trying with another port and it doesn't work even when that port is actually open

https://hastebin.com/share/awirumufef.php

Any suggestions on how to do it?

Is there a way to do it by the name?

What other approaches do you know and recommend?
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 348
Location: UK

PostPosted: Tue 01 Aug '23 21:47    Post subject: Reply with quote

As James has said, you need to add another VirtualHost entry with appropriate ServerName directive(s), which looking at your hastebin shared configuration, you have done. Presume you added a second listen entry for port 81, so what does "httpd -S" produce? For me I get:

Code:
C:\Apache24\bin>httpd -S
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   VirtualDocs.test (C:/Apache24/conf/httpd.conf:567)
*:81                   Appmunimarket.test (C:/Apache24/conf/httpd.conf:577)
ServerRoot: "C:/Apache24"
Main DocumentRoot: "C:/Apache24/htdocs"
Main ErrorLog: "C:/Apache24/logs/error.log"
Mutex default: dir="C:/Apache24/logs/" mechanism=default
PidFile: "C:/Apache24/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: SRVROOT=C:/Apache24

and the sites work as expected, provided your name services (DNS or local hosts file) resolve the site names for the browser.

If you read the VirtualHost documentation https://httpd.apache.org/docs/current/mod/core.html#virtualhost, you'll note that the first VirtualHost block for a given port, is also the default entry, if a specific ServerName match isn't found in a subsequent VirtualHost block.

Either way, the whole point of VirtualHosts, is you don't need to use different ports for multiple sites, so I suggest you check your Apache configuration and logs for more clues.
Back to top
Obsdark



Joined: 22 Apr 2021
Posts: 12

PostPosted: Wed 02 Aug '23 13:24    Post subject: Reply with quote

Ok perfect, i dig a little bit through the docs you send me but i have some question

How can i set the thing in order to being able to connect through a ServerName (or ServerAlias if apply) without the use of a DNS?

Is there even a way?

Is there a special way to indicate this to the browser so i can go to that other side instead of the default?

The VirtualHosts so far https://nopaste.linux-dev.org/?1338976

Bear in mind i'm in ubuntu 22 (if relevant)
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 348
Location: UK

PostPosted: Thu 03 Aug '23 20:37    Post subject: Reply with quote

Apologies, I should have noted you were on Ubuntu, not Windows.

So in which file have you placed your two VirtualHost entries? If it's /etc/apache2/apache2.conf, then you've not followed the recommended layout for configuration files on Ubuntu (Debian) - see the comments at the top of the apache2.conf file.

Split (move) your two vhost entries into suitably named site files, e.g.
    /etc/apache2/sites-available/www.certera.test.conf
    and
    /etc/apache2/sites-available/other.certera.test.conf

Enable the sites and reload the Apache configuration
Code:
$ sudo su -
# a2ensite www.certera.test.conf
# a2ensite other.certera.test.conf
# systemctl reload apache2

Verify the configuration is what you expect

Code:
# source /etc/apache2/envvars
# /usr/sbin/apache2 -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80      is a NameVirtualHost
   default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
   port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
   port 80 namevhost other.certera.test (/etc/apache2/sites-enabled/other.certera.test.conf:1)
   port 80 namevhost www.certera.test (/etc/apache2/sites-enabled/www.certera.test.conf:1
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE USR LIB CGI BIN
User: name="www-data" id=33
Group: name="www-data" id=33

Apache will determine which VirtualHost configuration to use based on the host header passed through the http request.
So you don't have to have DNS entries to test this type of configuration, as long as the browser is able to resolve the http host to know where to send the request. Edit the appropriate local hosts file (Linux or Windows) and add entries for your test sites.
Back to top
Obsdark



Joined: 22 Apr 2021
Posts: 12

PostPosted: Mon 07 Aug '23 21:46    Post subject: Reply with quote

Given this as the document today: https://nopaste.linux-dev.org/?1338986

So, let me get this straight just to clarify

You say than i need to put one of those in one document and the other in another one, both of them in the folder sites-available as this:

/etc/apache2/sites-available/www.certera.test.conf

/etc/apache2/sites-available/other.certera.test.conf

and with nothing else

Then, i just write this commands:

$ sudo su -
# a2ensite www.certera.test.conf
# a2ensite other.certera.test.conf
# systemctl reload apache2

And that should be it?

If not and i miss something, i'll apreciate an indication about what i miss, or if it from that point on i need to do something else, i apreciate if you clarify it to me.

Another question:

How should i indicate in the url to enter one or the other project given the case than it is one ip?

For instance, if ip were, i don't know, 111.222.333.444, how can i connect to www.certera.test and to other.certera.test?

I ask this because i assume if i'm outside of that machine and/or network, like in the general internet for instance, i cannot connect directly using those urls without having that url linked through the DNS network of the internet to it am i right?

And if i'm wrong and i can, how exactly should i write it in the url bar on the navigator to enter one or the other projects?

Thank you for your time
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 348
Location: UK

PostPosted: Mon 07 Aug '23 23:27    Post subject: Reply with quote

To clarify and confirm:
    1) Remove your two VirtualHost entries from apache2.conf
    2) Split them into two separate files as described in the sites-available directory. I simply chose file names based on your ServerName entries.
    3) Yes, run the commands as listed to enable those virtual host sites and restart Apache.
The "apache2 -S" command as shown should then confirm those virtual host sites are functional.

Re your second question, I tried to explain that you can use local host file entries to test your sites in the absence of official DNS entries on the internet.

So, if your Apache server IP is 111.222.333.444 then add test entries to /etc/hosts file on a (local) client machine where your test browser is, e.g.
    # Test site entries.
    #
    111.222.333.444 www.certera.test
    111.222.333.444 other.certera.test
That client browser should then be able to resolve requests such as http://www.certera.test, to the appropriate IP address, and connect to your Apache server. Apache will look at the host header in the HTTP request, pass the request to the corresponding virtual host site, and then return the appropriate content.

As you say, to access the sites remotely, you'll need appropriate external (routeable) IP DNS entries, as well as exposing your Apache server to the Internet.

There are numerous documents on the Internet covering the networking principles involved here, but such details and assistance in this area are beyond the scope of this site, which is primarily concerned with Apache web server and its configuration.

Good luck.
Back to top


Reply to topic   Topic: Apache2 only partially loading a page View previous topic :: View next topic
Post new topic   Forum Index -> Apache