Error 404 on PHP Require calls, caused by case-sensitive difference - php

I believe I've browsed a ton of different sites, blogs, and whatnots.
My PHP Website works great on my MAMP Stack in my computer (Working on a MAC, please don't judge).
The thing is, whenever I roll my website to my Production Server, running Ubuntu 18.04 (Regular LAMP Stack) I keep getting errors 404 when trying to use the site.
I've analyzed the paths, and the files do exist, however, in my code it's being required as
/Tools/Php/initialScript.php
and the actual path looks like
```/Tools/PHP/initialScript.php````
I've already enabled mod_speling in my server, and restarted the whole thing a few times (more than I care to admit).
Does mod_speling even work for PHP require function?
Any guidance at this point would be appreciated.

Interesting that you mention it works on Mac. Mac paths as far as I know are case-insensitive. Case in point, do cd /to/SoMe/pAth and it will work just fine. On the other hand, Linux is case sensitive.
I would personally just not play loose with case and treat things as though they were case sensitive. Is there something keeping that from being possible?

Related

Debian 8 multiple PHP are these safe methods?

At work i want to upgrade our system to PHP7. It is currently at PHP5.6.
We have a different folder structure, as we have all our code in the /home/user directory.
I am not a server guy, i only code. But i know some linux basics.
I came across phpbrew. Is it safe for me to use? as we have a different folder structure then most have.
I dont want to mess up my development server, so it is important for me that i can switch back to 5.6. The server is running debian 8 and we use apache2.
I also came across this article:
https://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu
Is this a safe way to do what i want?
Any other suggestions are also welcome!
Thanks in advance!
The process described in that link looks plausible. Possibly other online resources might confirm it. Why not make a quick VM and try it out?
Is your current dev server a VM? You could clone it, then make the changes and run both in parallel. If not, you could shut it down briefly, image it, and then use the image to build a VM or another physical box.
That way you've got any custom server setup copied across reliably with minimal effort, and you can test PHP7 along with that stuff, with no risk to the current environment. That would be my advice.

Php application moved to another server Windows 2012 with IIS 7, but not working

I have been asked to move a PHP application to another environment. I set up PHP installation, and moved 2 PHP applications and. got that working.
But one application I moved is not working... it just renders a blank screen.
When I say Localhost/ApplicationName, it lists the application folders and PHP files in it. When I click on it, the browser goes blank.
Can somebody point out a step-by step trouble shooting ways to test this?
there are a lot of ways a php file can return a blank page
first make sure the file did work on the previous environment, if it didn't then it's a different issue entirely
do the following in order of what you suspect to be most probable:
you can go into the php.ini file, and set the error variables to the development defaults, then check if it returns any usable errors
^this is what I use all the time for fatal issues, always set it back to it's original afterwards though
or check the errorlogs, as JimL suggested
if it worked on the previous env then you need to find out what the differences are between both environments.
things like, php.ini setting, IIS vs apache or whatever http server, linux vs windows
check if any of the php pages return anything at all (for example, in firefox, rightclick+inspect element, then use the network tab)
if it's a 500 error, the file probably has an error (and the server is configured to return 500 on an error)
if the file isn't too large, you can go through the file and use common programming sense to see if you can easily spot the error (stuff like links to nonexisting files, etc, shouldn't be too hard even without php experience)
when it links to files, also check if the notation is correct for the windows IIS
feel free to give more information in your OP, or in a comment, if you find out any information, and I'll do my best to help
disclaimer, I have no specific IIS knowledge, I work with apache (both windows and linux)

Sugar CRM saves index.php file after migrating to new server

i transferred a website over to a new server. as far as i can tell, everything came with it. databases, SSL, everything. It was a cpanel package script:
/scripts/pkgacct fileserv
its Sugar CRM. it still works on the old server, but when i try to use it on the new server, it just downloads index.php
and leaves me at a blank screen. any ideas? i was thinking possibly a PHP or Apache module or something, but I've never set up sugar CRM myself, and in setup guides, i couldn't find any special modules or anything that I need.
this is a problem i've dealt with before, but all the typical fixes aren't working. there are other websites running, so PHP and apache are working just fine. I edited .htaccess and everything too. but any suggestions at all would be very helpful. assume i've done absolutely nothing so far, just in case I missed something obvious.
Yeah it's probably apache, either A) the new server does not have PHP installed and apache does not have the module installed either or B) apache does not have the module installed to execute php scripts.
I think the comment under your question is heading in the right direction:
PHP code is not being executed, instead code shows on the page

MAC OSX Php Developmet. XAMP vs MAMP vs Entropy.ch (Marc Liyanage)

I do Php and MySQL development on a small scale on my Mac. When first researching it all a few years back, I came across Marc Liyanage's Apache build (entropy.ch). Since that's all I knew, I installed it and have been using it ever since.
I hear a lot about XAMP and MAMP these days. Now I'm not a Linux guy really. I can get around the terminal, and use MySQL via the terminal, but I'm not too UNIX savy in general. I find that I'm stumped when I have to install packages for Apache / Php via the command line.
My question is: is the interface / installation / maintenance in XAMP / MAMP simpler or more intuitive, than the entropy.ch build? (As in, more interfaces and less UNIX code to build things)?
How about any other differences?
I can't say I've ever seen or used Marc Liyanage's Apache build, but can attest that both XAMPP and MAMP are extremely easy to install and use and neither require any command line commands to setup.
I use XAMPP daily, and tried MAMP for a while but saw nothing better or worse about it so just kept using XAMPP. If you find yourself needing to extend Apache and install additional modules then you might need the command line to do so, but I've never needed to.
The only frustration I've ever had with either is default location for site files being with the application folder. It's not too difficult to change or work around, but it's annoying if you're used to having them in the sites folder.
XAMPP and MAMP are pretty well self contained and neither should affect your existing setup if oyu give them a test drive.
I have found MAMP to be simpler and more intuitive. XAMPP is almost exactly the same, but it doesn't seem as "mac"-like.
I have never even heard of entropy.ch so I can not comment on the differences, but if you havent tried MAMP yet you should take a look. Its incredibly easy.

Cross platform PHP caveats?

I've been given an existing PHP application that was originally deployed on a LAMP host.
Because most of our team are .Net developers, our boss wants it deployed in a windows environment.
Is it madness to expect this to just work?
Here's some additional info of the LAMP host:
Linux 2.4.32
PHP 5.2.6
No non-default modules
In my experience, it can be done and works fine.
The most important things I'd keep in mind are:
Use Apache on Windows, don't use IIS (even if it's possible)
Make sure you use unix style slashes for directories. Those work on both platforms.
Be very careful with case sensitivity. Since Windows is not case sensitive (though it is case preserving), if you include a file and spell it with the wrong case, it will work on Windows and fail on Linux.
Heck even just migrating from one hosted server to a different one usually requires SOME tweaking and adjustments. I don't imagine having to do it in a Windows environment would be much different. I was invloved in the migration of a large PHP app just last week and we (3 people) were able to get things going in about half a day.
It depends what's being done in the application. Two areas to look into though are where the app looks for files in the file system (using Linux specific paths?) and finding windows builds of any php modules (from PECL in particular).
Be very careful that at no point is exec called. A lot of extremely lazy code is written that will use this, and for obvious reasons it may not port well.
Some what i've experienced over the years:
Too old/new DB driver for PHP
Path problems
Change from 32 bit to 64 bit system or vice versa affects PHP internal integer handling (bit calculations returns weird results suddenly)
Locale and localization issues
Missing functions (manual have usually notes that it won't work or behaves differentially in windows)
File name casing
And always check and double check that Apache modules and PHP modules are atleast the same version as in old system.
It's also not too bad to run GNU/Linux virtualized on top of Windows with for example VMWare if code doesn't seem to like running in Windows.

Categories