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.
Related
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?
I am using an open source library ( http://hybridauth.sourceforge.net ) that does not support the PECL OAuth extension of PHP. If you try to run code with it, it says "Exception: Hybridauth Library not compatible with installed PECL OAuth extension. Please disable it."
Easier said than done.
I am hosting my site via Amazon AWS Elastic Beanstalk ( https://aws.amazon.com/elasticbeanstalk/ ). I chose this solution because it allows you to get started quickly with no configuration, no SSH, no custom AMI, ...
Which means I can't easily modify the original php.ini file or delete the extension file.
Is there an easier way? Disabling an extension on the fly? Via a php method? Via an htaccess file? A trick?
No, you cannot disable extensions via PHP method call. In the past you could add it (with dl()), but even then, you was not able to remove any added without playing with ini file.
The short version: No, not in any practical sense.
If you have runkit available you should be able to remove the functions or objects that the module defines, but it really depends on why HybridAuth have trouble working when the PECL OAuth extension is installed. This is not suggested for anything close to a production environment.
You can ssh into your instance very easily if you have your pem key. Just go to the ec2 console, select your instance and click "connect" in the toolbar to get the address. Then you can modify any of the files on the server.
I am using a shared host. PHP is compiled with --disable-sysvshm. I get the following error while running a script:
Fatal error: Call to undefined function shm_attach() in ...
Is there any way to enable it without re-compiling php?
There is, but as a regular user, you can't do it. You'll need admin access.
If you have root access, then your package manager should have the extension available if it doesn't come built into PHP. For SuSE, it's looking like a php-sysvshm package would do it. If there's no package, you'll still need to rebuild, but it's doable.
If you don't have the access you'd need to build PHP or install packages, you won't be able to build or install, let alone load, extensions (which are pretty much the only way you can add functionality without replacing your existing PHP). In that case, you'll need to talk to your web host and see if they will install it for you. If they won't, then that's pretty much it.
Is there a pure PHP implementation of SQLite that will run on PHP 5.1.6? I am working on an application that would benefit from being able to store data in a relational database, but the server that it has to run on is stuck with PHP 5.1.6 and has been configured "'--without-sqlite"
I have no control over this server; cannot recompile, upgrade or otherwise modify PHP aside from using .htaccess files. Hosting externally is also not an option, unfortunately. MySQL may be possible but would be a nightmare trying to get their IT to create a database for me. (It took them 6 weeks to get .htaccess files enabled because of red tape and other things)
Am I out of luck? My fall back is to write everything to flat files but I really would rather not do that.
EDIT: Fixed typo. PHP does not have the SQLite extension and was configured "'--without-sqlite" according to the output of phpinfo()
Actually, you could easily download and install sqlite in your userspace, whether on windows or on a linux remote shell doesn t usually matter unless your host is unusually restrictive, if that is the case you should change service provider.
Once sqlite is installed, you can one of the available pear extensions or pecl extension to allow easy access through php.
Tutorial and code examples for the pear solution here.
I'm writing a small app that needs to have a super easy install process. Version one used a csv file instead of a database, so priority #1 for v2 is getting sqlite going instead. I've used sqlite a lot with Ruby, and love it, but this is my first time using it with PHP.
Basically, in order to get SQlite3 to be able to insert into the db, I needed to make both the database.sqlite3 file and the folder containing it owned by the apache user. From reading the docs, this seems normal.
However, apache isn't always going to be running as the same user. Here, it's 'http', but I know on Ubuntu it's 'www-data', right?
So, is there a good way to detect the username Apache is running as, and changing it, or am I going about this wrong? It needs to be something I can just put in the install script, as the people who use this app don't know or care anything about tiny details like this.
Thanks.
I believe you're going at it from the wrong side: you need the SQLite db to be writable by the PHP script, as I understand the matter, and this might not be the same as the Apache user.
If PHP is installed as an Apache module it will inherit the Apache user, but a much more common case on shared servers is to have PHP set up as CGI under suphp or phpsuexec, so the scripts run with the permissions of the user himself.
I'd suggest you write an install.php script to create the folder and the database, so both will inherit the script's permissions, no matter which user it is. Look into the manual for mkdir() and sqlite_open(). If nothing else works there's always chmod().
As you specifically cite SQLite v. 3 you may want to check the server version with phpversion(); in PHP 5.3 sqlite_* functions do work with version 3, PHP 5.2 and below understand version 2 instead. To use version 3 in PHP 5.2 you must use pdo_sqlite.