On a CentOS 7 Virtual Machine, I have a PHP script running in Apache. That PHP script requires a PHP extension which I cannot install on the Virtual Machine. However, I have found a Docker image which contains the extension I need.
Now, how do I proceed from here?
Is it somehow possible to "tunnel" the PHP extension from inside the Docker to its host?
Or is it wise to make a detour over the command line? I.e. in the outer PHP script, call a system command which runs the Docker image, which runs a PHP script with the extension I need.
possible? yeah, make some api doing the required actions inside the VM, serialize the result, and deserialize it where your main app is running. the serialization process may be done with serialize() or json_encode() or var_export(), the transfer protocol can trivially be implemented using HTTP or HTTPS (just use apache or nginx?). PS, you may want to add some authentication or ip whitelist.
am curious why you can't install the extension on your main system tho, i guess it's' a windows<->linux compatibility issue?
Related
I have a hosting plan through Godaddy that only supports python 2.6.6. I have been able to install python 2.7 and 3.6 through SSH and run scripts, pip, no problems.
When I try and run a PHP script that calls a python script from SSH, it works just fine using my new python installs, but when I open the PHP script in a browser, it will only run 2.6.6.
Why is this? Is there a way to get around this without getting a VPS?
I think what is happening here is that you are able to manually run Python3 from your SSH session by calling it directly.
However, your PHP installation probably isn't aware that you have more than one instance of Python installed. At a guess, your PHP installation is defaulting to it's environment path (or other predetermined library directory) where it can find a Python installation (this installation being the original 2.7).
I'm not sure how you are calling your Python scripts but there is an answer here: Calling specific version of python from PHP that talks about changing the python version in the script.
Another possible solution is to add the directory containing Python3 to your $PATH variable. Word of warning, if this is a shared system this might be disabled or potentially COULD get you in some trouble. Since altering the path might start other python scripts (belonging to other people) being called by Python3, which could break them (due to deprecated syntax etc)
When you want to start messing with system configuration, you're getting into VPS territory rather than shared hosting.
I have found a sneaky way around this. I used SSH2 PHP extension to call the python3.
I know this is a newbie question, but i want to study php. i have phpeclipse and its running well, the problem is when i run a simple html file with the default server the page says cant display this page and thats it. i dont know if i need to install a new server or is there something wrong with the server configurations. ive tried installing tomcat on my computer but i cant see it under windows->preferences->server->runtime enviroments->add. iv also tried under the same page to fetch geronimo v2.2 and 3.0 and the dependencies were wernt satisfied. iv also tried the repository for zend debugger. what do i need to do in order to compile and see php and html pages with php eclipse?
You don't need to compile PHP.
Depending on your operating system and PHP version there are a few options.
As of PHP 5.4+ you can run your application using PHP's built in server, on the command line, if you cd into your website root directory (i.e. where the index file is) and then run the following
php -S localhost:8989
Then if you navigate to http://localhost:8989 in your browser you should see your application.
If you are unable to run the inbuilt web server, you need to look at Apache2. Most PHP websites run inside the Apache 2 web server. You will generally need a *AMP (WAMP/LAMP) environment.
L/W (Linux / Windows)
A pache (Web server)
M ySQL (Database)
P HP
Hope this is enough of a pointer ;)
I am making a script to backup configs for firewalls. One thing I want to do is scp files from ScreenOS devices, but I get a blank line from the CLI.
What I need to do in build this functionality into an already existing web interface, so I need to be able to run this command from within PHP.
I have looked at shell_exec, system, etc, but im haivng issues at the CLI level running the commands.
Any help is appreciated.
I have been in the field for years. This is actually a bug with ScreenOS devices that are version 6.5 or less.
There is an article, Gotcha - SCP Returns To Prompt, which documents this bug and walks you through configuring a separate install of OpenSSH which includes the SCP fix to support older ScreenOS devices.
As for your web interface, once you get this bug fixed, map your shell_exec command to this new scp binary, and you will be all set.
I have an existing linux server, with PHP already installed. I just need to add in the php_ldap module. I do not have root/sudo access (no yum/apt-get), what is the best way to get it installed?
Unfortunately there is none. Even if you get sources and compile it, you will still need to modify apache configuration to get it loaded. I suggest to talk to the admin of the server.
He didn't said that he use apache. Theoretically, if the sources of web-server and php is compiled as the user running the web-server, that should works.
I think it cannot be done without root privilege. If you cannot talk to your client you can look for a php library replacement instead. For example there is a JSON script replaceing the JSON extension.
I've just started reading about php, it needs me to install php, apache and MySql to run any php script. can any one suggest me a simplest method to install php, apache and MySql so that i can sun those php script.
I've tried the zip files from php.net, Are those required to run the script offline for practicing the script? what do i do with them? i felt the things given on the same site a bit complex, and was unable to run the script. please help.
I'm assuming you're using Windows - get wamp - it has exactly what you need:
Apache
MySQL
PHP
Wamp comes with a nifty tray controller app which you can use to access the most common tasks, like restarting services, editing config, etc.
Equivalent to Artem's post, just a different organization which packages it differently. And my preference. It is called XAMPP.
If you are using Windows, you could install XAMPP to have the environment setup for you. You'll then need to learn how to bring up the server (basically executing the XAMPP control panel program), copy your PHP scripts into the correct directories (for XAMPP, it'd be C:/[xampp installation dir]/htdocs), access MySQL and creating the necessary MySQL databases (you could access the MySQL via the included PhpMyAdmin).
You can probably refer to a tutorial here (it's a YouTube video, BTW).
Don't have enough rep to comment but wanted to add something to Artem's recommendation of Wampserver. It's what I use on my windows machine, and one of the nicest things about it I find is the ability to have multiple versions of versions of apache, php and mysql installed alongside each other as plug-ins and then select which to have running at any time. It makes it easy for me to emulate the eventual hosting environment for any given project.