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.
Related
I'm writing a web app on my system using PHP5, but the app needs to be compatible with PHP4. Is there any way to emulate PHP4, or at least issue warnings?
Thanks.
As a general rule, if you avoid functions and arguments that were added in PHP5 (as shown in the documentation for each function), then it should work just fine with PHP4. PHP is good at backwards-compatibility like that.
There is no way to emulate PHP4 that I'm aware of. You need to run your code in a real PHP4 environment. Here's what I'd suggest:
Grab an old distro which includes a PHP4 package. Apparently, Ubuntu Dapper (6.06) does.
Install it into a VM (VirtualBox or VMWare) on your box.
Create a shared directory for the VM which points to your app dir on the real box.
Inside your VM, create a symlink from the webroot to the mount point of the shared directory.
Once that is done, you can more or less forget about the VM. All you need to do is keep it running. Change your code in your app dir as before. You can run it from your browser with the IP of the virtual machine.
(Perhaps you could even install an old version of XDebug in the VM and do proper remote debugging from within your IDE. But I don't know if XDebug is compatible with PHP4 at all.)
No, there isn't. You will have to install PHP 4 on the machine to provide the runtime environment. Or, even better, convince the client that PHP 4 in 2012 is... outdated.
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 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.
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 need to install or use php on a windows 2003 server that already has php 5.2.0.0 installed due (I think) to setting up symantec backup exec. I don't want to interfere with backup exec's php.ini settings - and would rather be able to control my own configuration of php.
searching for php shows that php.exe and other php files are currently installed in
c:\program files\symantec\backup exec\
I'm almost certain that installing the current version of php 5.2.8 to c:\php would be disastrous or calamitous in some way.
There is no PHPRC entry in the server properties > environment variables and I'm pretty sure that the php.exe location is not included in the PATH variable. ...unless the actuall install location is different from the c:\program files\symantec\backup exec\ dir.
Any suggestions on how to proceed?
I'm almost certain that installing the current version of php 5.2.8 to c:\php would be disastrous or calamitous in some way.
What makes you say that :) I've run separate PHP versions on the same machine side by side and not run into bother.
AFAIK the Symantec install should not conflict with your own installation, nor should the separate php.ini files conflict with each other.
[Response to comment]
First thing to note is that I have no experience of Backup Exec or what it uses PHP for. I'm guessing it uses it for its own internal stuff and doesn't spread itself over the OS. Test this by searching for php.ini and php DLLs on the file system. I'm betting it's all quite self contained. PHP searches for the config file as noted here: PHP Site . As you note, BE hasn't set the PHPRC variable. Check it hasn't used those Registry entries either. On a different tack, has BE installed an admin site already on IIS? If so, check the IIS Web Service Extensions to make sure it hasn't already registered the PHP ISAPI dll or PHP CGI exe. IF not, I think you should be okay for your new install.
To be on the safe side, do a manual PHP install as illustrated here: PHP Site. That way, you know exactly what you have installed, and can easily remove the files again if they cause a problem. I can't imagine a problem here that would require you to reinstall BE.