2

Brand new WordPress install with Avade Theme installed on RPi 4 - works fine when I access it on http://203.0.113.111/index.php from an external connection, but if I remove the index.php I get nothing - connection refused.

Is this normal behaviour? Shouldn't I get redirected to the WP installs index page right away? I've forwarded port 80 in my router to the Pi's internal IP, so I can't get my head around this.

I even modified the .htaccess in /var/www/html with these lines:

DirectoryIndex index.html index.php

but ALAS - even though I think it should work just fine I don't get why I have to write the index.php in my web-browser. Of course a direct DNS forward could do the trick here, but common? That's just symptom-treatment, right?

Can anyone give me a pointer in the right direction?

EDIT: It's the same when I try to access my web servers internal IP from the LAN - I have to input index.php if I must reach the WP-site.

EDIT 2: from @kero's comment: I rewrote AllowOverride in Apache conf from None to ALL and restarted Apache but still nothing.

... still changes nothing after an Apache service restart.

  • Your webserver is not properly set up for this. Is your local .htaccess even used? (Meaning: Do you have AllowOverride activated in the Apache config?) – kero Jan 16 at 12:22
  • Please put all the information in the question (by editing) and don't post it as comments, this way everyone gets all the information by reading the question and doesn't have to look through the comments. – kero Jan 16 at 12:27
  • I can't seem to write the code-block in my edit's correctly when I edit my post - it get's all messed up. But I tried explaining :-) – IT Blacksmith Jan 16 at 12:37
  • @Jeppe The code-block you've used above looks OK. Either indent by 4 spaces or surround in 3 bacticks (GitHub style). Leave a blank line top/bottom. – MrWhite Jan 16 at 12:44
  • "I rewrote Allowoverride in Apache conf from None to ALL" - But where exactly did you do this? You shouldn't need to change anything. You may have changed the setting that controls the entire server - this is not advisable. You need to create another <Directory> block that specifically targets your DocumentRoot. Have you configured a <VirtualHost> or is this all in the main server config? – MrWhite Jan 16 at 12:46
2

Is this normal behaviour?

Yes. On a default Apache install, only index.html is set as the DirectoryIndex (the default setting).

Either in the appropriate <VirtualHost> container, or main server config you need to add a <Directory> section that specifically targets the defined document root directory.

For example:

DocumentRoot /var/www/html

<Directory "/var/www/html">
    # Allow public access to the site
    Require all granted

    # FollowSymLinks is required for mod_rewrite
    # (Although this is actually the default server setting)
    Options FollowSymLinks

    # Allow mod_dir to serve index.php by default
    DirectoryIndex index.php

    # Give full access to htaccess (optional)
    # Strictly speaking you only need "FileInfo" for mod_rewrite
    # - Alternatively place all your htaccess directives here...
    AllowOverride All
</Directory>

You will then need to restart Apache.

mod_dir also needs to be enabled, but this should be loaded by default.

  • Thanks for sharing... When you say "main server config" do mean in /etc/apache2/apache2.conf ? Because that code you wrote there is identical to mine, accept I have "Require all granted" written aswell. - again thanks for helping a self-taught newbie. – IT Blacksmith Jan 16 at 12:58
  • Well, it's whatever is the main server config file - different distros have different defaults, but that is probably correct. And yes, there will need to be a "Require all granted" directive in order to allow access to your site. – MrWhite Jan 16 at 13:04
  • 1
    "a self-taught newbie" - I think 99.9% of us are "self-taught"! ;) lol – MrWhite Jan 16 at 13:07
  • It sounds like you have pretty much got it right. The only other options I can think of is that... the directives are in the wrong place and/or there are other directives that are overriding this. Do you have any <VirtualHost> containers? Do you have an include (in the main server config) that includes additional configs? This is usual for virtual hosts/vHosts. (vHosts allow you to set up multiple websites on the same webserver - but once you start using vHosts then use vHosts for everything and avoid editing the main server config.) – MrWhite Jan 16 at 13:11
  • 1
    Interesting, I've just got hold of a RPi 4 myself, with a view to setting it up as a webserver - but I've not got round to doing that yet! – MrWhite Jan 16 at 13:45
1

I got it to work ! Yey!

The answer lay somewhere in the General settings of the wp-admin site and my dyn account. I delted my dyn record from their site temporarely. Then I edited the configuration of my wordpress-site and folder in wp-admin. I changed it to the external IP and then it worked without index.php right away. Then I changed the values back to my dyndns account: http://godset.raspberryip.com and VOILA - no index.php needs to be written and everything works. Had to edit the site url though PHPmydamin since the WP-site was down due to this change I made.

Not sure what the problem was though... But thnks to all that helped.

  • 1
    Glad you got it resolved. I should have paid closer attention to the "connection refused" statement in your question - this perhaps suggests something other than DirectoryIndex (which would ordinarily return a 403 Forbidden if set incorrectly). However, the fact that http://<ip-address>/index.php worked and http://<ip-address>/ did not doesn't make much sense if it wasn't related in someway to DirectoryIndex. The "connection refused" error would be occurring before WP did anything and since you were requesting the IP directly, no DNS/Dyn was being used?! Maybe a caching issue?? – MrWhite Jan 16 at 23:23
  • Could be a caching problem - how would I know to check this if the problem returns? I haven't had any problem since with this issue and after fideling with a relatively beutiful theme I found, then I've realised that the RPi 4 4GB version is a quite quick webserver with the right tweaking and DEFINATELY a valid choice to host on my own fiber ISP-connection. – IT Blacksmith Jan 18 at 1:15
  • @MrWhite - if you have the chance then try and set your Rpi 4 up as a webserver.. But I wouldn't advise running unnessesary other servers such as Plex or a bit torrent Client if you want FULL speed and load times. it.sucks.dk is currently the hosted site on my Pi - how is the load times from your country? Are you able to tell me of it is any good? – IT Blacksmith Jan 18 at 1:27
  • Actually I will make.a.new thread about this - thanks MrWhite for your suggestions :) – IT Blacksmith Jan 18 at 1:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.