I have a LAMP/WAMP application that runs successfully on nine different machines. A windows PC and multiple centos5, centos6, and centos7 linux servers. They all share a common source tree.
I just installed ubuntu 20.04 on a new machine. When I try to run this application it fails because PHP won't allow relative include(), require(), etc. paths. This is PHP 7.3.24.
This function call and others like it work everywhere else but fail on ubuntu:
include("../include/app_fns.php");
When I recode this with full paths it seems to work, but there are 114 files and 129 instances of these kinds of relative paths I would have to edit. I can do that, but the full path isn't the same on all the machines where this app is installed, so the code would no longer be compatible will all machines. That's unacceptable.
There has to be some way to tell PHP to act like it does everywhere else. I've tried include_path() changes. The changes show up in phpinfo, but they seem to be ignored and the errors persist. Any suggestions? I really want this to work on ubuntu, but I'll have to install centos7 on this machine if I can't solve this problem.
Related
Is there any way to remotely use clamav to scan uploading files in php web scripts, as iv'e tried many options available out there but none seemingly works, as mostly clamav is available for linux, ubuntu based systems.
Errors i always encounter are clamd.sock not found or missing, or connection to host died etc.
and it cant load autoload file as well.
I started trying to create a website which uses PHP on an old computer (previously used by another programmer).
I wanted to test my PHP code without uploading it each time, so I downloaded Apache and installed it. I was starting to set Apache up when I discovered this computer already had Apache on it.
Now I had multiple versions of Apache, so I went into add/remove programs and got rid of Apache (which only showed up once in the list).
Unfortunately windows decided it would uninstall the old version and keep mine which was not functioning properly. Also for whatever reason it seemed to have kept a good few files from the old version, but not enough that I could actually use it in any way. I believe it just had some configurations files.
I thought I would copy my files from the new version into the old version and not replace anything so hopefully I would be able to run under the older configurations, but that didn't work.
At this point I just wanted to cut my losses, so I put all the versions of Apache in an archive so there was no way the computer could be using them. I also removed Apache from the windows startup and rebooted the computer after configuring one single version of the newer copy of Apache to supposedly run PHP.
The problem is upon startup I could immediately log in to localhost and apache was already running. Also when I opened Apache manually from the files I had left unzipped, it only gives me the option to start Apache (not an option to stop or restart implying it is not running) and when I click it, it says "The requested operation has failed!" which is less than helpful.
So anyway, I just want to be able to run PHP locally and now I don't feel like I can even successfully uninstall and start from scratch anymore. Does anyone know what I have to do to get this to work? Sorry for the long description, I wove such a tangled knot.
One way to solve is use a XAMP (Apache + MySQL + PHP) client like XAMPP http://www.apachefriends.org/en/xampp.html brings it all set up for you to use. The problem of conflict can be caused by any IDE (Netbeans for example) that already carries a version of Apache.
Try to configure config files of Apache case exist.
Assumption: Running Windows OS for development and linux for production environment.
My recommendation is to not mix the Windows and Linux worlds as while they can be made to behave after lots of work, it is usually more pain than good.
Instead, as a humble windows and linux user, download and install Virtualbox [https://www.virtualbox.org/wiki/Downloads], a free open source virtualisation tool.
Then download a linux distribution of your choice and install that into a new virtual machine.
Configure the linux tools inside linux and leave your windows machine relatively untouched.
A useful linux service to install would be Samba - windows file sharing - you can use this to edit your code in windows using any IDE of your choice, while saving directly to linux and testing through linux. When happy, upload from the linux system (again like any other file uploader) and all will be well.
If you are deploying to a linux based environment in your production service then this will help you avoid common mistakes such as case-sensitivity trouble and many others.
Building and running this system is free and it will help teach you more about the linux environment you are deploying to also.
Equally, when you don't have the virtual machine booted, there's no services lying around exposing your computer to possible local network threats and consuming resources - as opposed to installing Apache on Windows where it will be using some resources all the time.
I have a PHP script that uses some simple extensions(curl, http_pecl, ...). I installed in my machine using macports and it worked fine. I tried to get this to run on another machine, but for some reason the set up is different, and the php extensions refuse to install. My question is, is it possible to bundle php extensions with the file itself so that it is standalone? im guessing to include the extensions with the file itself, but im not sure how to do that.
Both the machines are running Mac OSX Lion, so that takes away the OS constraint if there is one.
Certainly not possible. Whatever extensions your script requires must be manually installed by an administrator. An alternative such as you describe would have colossal reliability and security problems.
In the past, I used WAMPserver on windows to parse PHP for me. This is a pre-configured package, focussed on working with MySQL.
When I tried to run PostgreSQL, I got error messages that said that my version of PHP wasn't compiled to work with PostgreSQL.
So, I've recently uninstalled WAMP and every associated with it. I've downloaded Apache 2.2.11 with openSSL, installed as admin(you know, run the command prompt as administrator, cd to the directory where the download was done and have it executed, so the install was done as admin).
That's that. I now have Apache installed, "it works" shows up, so I'm that far.
Now I'm wondering, do I download the exe and install, or the zip, or something else.
What is the best thing to do to make sure that the PHP on my system can handle everything I can ever throw at it?
Also, PHP first, or MySQL/Postgre first.
And lastly, what about PEAR? I need PEAR installed, which isn't standard on Windows. I'm guessing the pear.bat file in the PHP downloads will do that for me?
EDIT: I see one close vote, yet no comment as to why. It makes me wonder how people who are so lazy and rude got to have somany points.
I would recommend downloading the zip package, as configuring php is not really that difficult, and it allows you to add features as needed.
As for whether first to install php or MySQL/PostgreSQL, - it does not really matter. You can install them in any order.
Your guess regarding PEAR is quite correct
i haven't used wamp before, so i can't comment on that
i do however use xampp which sounds very similar
in xampp if i want to enable postgres support i edit the php.ini file and uncomment the postgres section of the ini file, same with any of the extensions that i need
perhaps this might be an alternative you can try if you get stuck
There are many ways to setup a HTTP server/PHP/database machine. Sometimes the behaviour of your development setup will differ from the live server's.
I would recommend finding out the setup your web host is using, then getting a vmware appliance image that fits that as close as possible and get any additional software using it's package manager (which is easier that installing stuff on Windows).
Setup a file sharing link between the VM and the host, make sure you can view the VM's port 80 in a browser running in your host OS and you're set.
I wrote a script that compiles LaTeX code through pdftex. The trouble is that pdftex only runs on linux.
I am accomplishing this task with the use of shell_exec().
I don’t really have the ability to set up a linux box as a web server. I have my client computer, but it is behind a firewall that I do not control. I do have control of my work server which is running SBS 2003 with a Windows 2000 virtual machine running apache and php. To my knowledge, you can’t install pdftex in Windows, and if you could it wouldn’t work with shell_exec().
Is there way to work around this with cygwin? I could install pdftex in cygwin, and then configure php to run shell_exec() commands inside of cygwin. If this is possible, could somebody point me in the right direction?
Also, I wonder if there is another course of action. I wouldn’t mind buying hosting, but any shared hosting plan isn’t going to support the app. It would have to be a virtual or dedicated hosting plan; something I can’t afford.
For anyone who is wondering about running shell_exec() through Cygwin, check out this link to a comment in the PHP manual:
http://us.php.net/manual/en/function.shell-exec.php#68647
$result = shell_exec("C:\cygwin\bin\bash.exe --login -c '/cygdrive/c/cygwin/bin/convert.exe --version'");
The key is the "--login" option which appends all the required common
cygwin binary and library paths to $PATH. Without this option some of
the cygwin binaries that links to other libraries ( Like ImageMagick
binaries which links to X11 ) will not work and you may see errors
like "cygX11-6.dll not found, Could not start convert.exe"
pdfTeX runs just fine on Windows, without requiring Cygwin. Try MiKTeX.