Without it you are flying blind.
You need to see what’s going wrong with PHP, this will tell you.
At the very least set PHP to display errors during development (only).
Yes, I’m changing settings in php.ini right now, but anyway I’ll install this Xdebug as well.
Well, I’ve just had a fairly active chat about this on another forum. Bottom line - I don’t think I’m going to get to the bottom of what’s going on here, because it must be something obscure and weird, so I’m going to try setting things up on another VM, with just Apache, to avoid complications. And I guess maybe I’ll have a go with Nginx on another VM at some other time, but not now! It’s summer, after all.
This is what @rpkamp has been saying. Using Apache and Nginx together is an unnecessary complication.
It’s much better to choose one or the other for any given project.
It doesn’t mean you can’t use the other on different project. I use both, but never together.
Yeah, OK, massive overkill. I get it! Anyway, I’ve learned a lot these last two weeks, so no worries. And now I have things working OK with Apache and PHP, on a slightly more up to date VM. Of course I’ve got more questions now. One specific one that I haven’t figured out yet. I guess I’ll post about it.
To fix PHP on your NGinX/Apache setup:
- Verify Configs:
sudo nginx -t
sudo apache2ctl configtest - Check PHP-FPM:
sudo systemctl status php8.0-fpm
sudo ls -l /run/php/php8.0-fpm.sock - Check Logs:
sudo tail -f /var/log/nginx/error.log
sudo tail -f /var/log/apache2/error.log
sudo tail -f /var/log/php8.0-fpm.log - Test PHP:
echo “<?php phpinfo(); ?>” > /var/www/localhost/info.php
curl -Ik https://localhost/info.php - Restart Services:
sudo systemctl restart nginx
sudo systemctl restart apache2
sudo systemctl restart php8.0-fpm
Check if PHP works now.
Hi. I did all that stuff one million times Ultimately I probably ended up with some other obscure problem that got created in the midst of all that. Total mystery. Which is why I decided just to clone and update the VM, and to simplify things by using only Apache. That’s fine for now!
Well, the update is that I was finding it really annoying to tinker with multiple sites in/on Apache. Something very strange was happening, which I think I maybe understand now, but not quite sure. Feel free to confirm or deny.
So I had each site on a different port, of course - 80, 81, 82, 83… but it didn’t occur to me that the redirects to HTTPS would also need to be on different ports for each site. I didn’t see that anywhere on tutorials that I found, so I’m not sure if that’s supposed to be necessary, but anyway the weird behaviour that I saw makes me think that. What was happening was that all the sites worked fine when I sent them to the full URL with https, but without that, or with http://, they all redirected to the localthost page (which had the first of the http ports, 80 of course). The really weird thing was that the redirects worked for all the sites in private/incognito windows of the two browsers I’m testing in, but even if I cleared the cache not in a regular window. No idea whether the reason I’m assuming is the correct one, but it doesn’t give me the greatest confidence in Apache.
And so I decided to go back to the original “plan” (not a plan - let’s call it a “journey”), i.e. to use Nginx as a reverse proxy. I know that it’s all really complicated to start with, and at first I didn’t understand what I was doing or even why I was doing, but I think it’s worth it, if only to understand how the whole shebang works. And ultimately it is all really simple, as long as the settings don’t get too baroque. If you have a static site that won’t use PHP it’s simple enough to let Nginx take care of it, and there’s no need for separate ports for each site. That’s great. And then if you want the power of Apache for a PHP/SQL site or something similar, redirect to Apache on 8080, 8081, etc (or whatever range you choose). So far so good. It’s working for me.
I think that what was going wrong with my setup in the first place was that I was asking ChatGPT a million questions and it was reciprocating with a million answers, leading to ever greater confusion. It was introducing PHP settings into the Nginx configs and then when that wasn’t working it was sending me off to change all kinds of PHP settings, in php.ini and whatever else. None of it worked, and it all became intractable. The trouble is that the AI responds to your question, but doesn’t hold in its “mind” that there needs to be a global strategy understanding what you’re trying to do. Well, that’s all obvious enough, I suppose. Not complaining, by the way - it’s really useful to get instant answers to the questions, but the important thing is to “remind” it sometimes of what the overall goal is, because otherwise it just shoots you off in every possible direction.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.