So I ran into something I'm just hoping I can get some understanding on. There is a clean Centos machine with a clean install of PHP. It had the mongoDB driver installed as well. When accessing the web app through the browser, it kept complaining the mongo client didn't exist. All of the installation procedures were followed, php.ini contained extension=mongo.so, and httpd restarted. PHP info() did not contain the Mongo conf. What ended up working was adding a mongo.ini file to the /etc/php.d directory with the extension=mongo.so written to it.
I'm getting a sneaky suspicion php.ini wasn't being loaded correctly, but I don't understand why. The reason I'm thinking this is, for one, it worked after adding mongo.ini. Second, there are mismatched PHP info() outputs from the CLI and browser gui.
and from the GUI
Both of these were snapped seconds apart. No configuration changes or restarts were made. For some reason the CLI output says the loaded configuration file was /etc/php.ini which was expected. The browser GUI however shows (none). What is going on here? Is this why the extension=mongo.so was never loading from the php.ini file?
versions
Apache/2.4.6
PHP/5.4.16
CentOS Linux release 7.3.1611
[someUser#someServer etc]# find / -name php.ini
/etc/php.ini
Is SO even the proper place for this? or should I move to a different forum?
update
After reading Grigory Ilizirov's comments, and doing some research, I think the question is answered if he wants to post it. Looks like the php configs for apache wasn't being loaded. I had just assumed the /etc/php.ini file was all that was needed to be edited. Now I just need to figure out how the heck I'm going to do that.
update 2
Reverted back to a clean install and did everything again. This time around, same results from the CLI and web GUI as before, but now mongo wouldn't load at all despite being added in /etc/php.d/mongo.ini. suspect SELinux is interferring with apache. mongo.ini is no longer showing in the additional .ini file sections. Disabling SELinux and rebooting allows it to load to apache.
FINAL
This is indeed an SELinux issue. Now then, does this belong on SO for future users?
You need to make sure your PHP have installed MongoDB extension.try use PHP -m see if you have MongoDB installed.
Then Download source code from https://github.com/mongodb/mongo-php-driver-legacy.
follow these steps to install the extension:
tar zxvf mongo-x.x.x.tgz -C ../
cd mongo-x.x.x/
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make clean
make
make install
extension=mongo.so //add this line to php.ini
after install try run PHP -m again, see if extension installed success.
for more info, you should read PHP doc.http://php.net/manual/en/mongo.installation.php#mongo.installation.fedora
It was indeed SELinux interfering with Apache's access to the PHP configuration file. Adding the security context fixed it.
semanage fcontext -at httpd_sys_content_t '/etc/php.ini'
semanage fcontext -at httpd_sys_content_t '/etc/php.d/(/.*)?'
restorecon -Rv /etc/
systemctl restart httpd
Related
I have mamp installed and am using windows 10. I have attached an image of the configurations, the error, and some of the things I've done to diagnose why. I don't know why I am continuously getting this composer error. I am updating my php.ini file, which had openssl commented out. I removed the semicolon on extension_dir (was already removed), and on extension=php_openssl.dll. I have noticed that when I type in php -m in my command prompt, I am not seeing open ssl, and I'm not sure how to enable that, if that is the possible issue.
If there can be any light shed on this, let me know, I understand this issue is answered hundreds of times over, but I have done what was required from those answers, and got no where.
Image clarifications: The error
Here is where I am checking the configurations with php -m and it's not showing openssl, correct me if I'm mistaken.
My phpinfo(); with also me doing php -ini, it's showing php isn't set, but it is when I run the phpinfo method, i'm assuming because this method is being run through mamp allowing it to set the correct parameters.
You have to make sure that the command-line PHP loads an ini file somehow. The easiest is probably to copy c:\MAMP\conf\php7.0.0\php.ini to wherever your php.exe is located. To find that out you can use where php which should return you the full path to it. Copy the ini file in that directory and it should find it and load the module (although you might have to adjust the extension_dir depending on how it is set).
See http://php.net/manual/en/configuration.file.php if you want more details on how the ini file is located.
you only need to copy php.ini from the conf directory to your php directory and it will work fine.
just copy php.ini from
MAMP/conf/php(version of your php)/php.ini
to
MAMP/bin/php/php(version of your php)
then try in command line `php composer.phar install'
for install composer and enable openssl extension, copy your php.conf in MAMP\conf\php{php-version} for MAMP\bin\php\php{php-version} and edit php.conf changing ;extension=php_openssl.dll for extension=php_openssl.dll.
Then try installing normally.
Running Windows 10 with MAMP PRO. Copy the version php.ini file to the folder that has the php.exe. In my case, I copied MAMP/conf/php7.2.1/php.ini file to MAMP/bin/php7.2.1/ folder.
Restarted MAMP PRO 4.
Ran the command line, replacing some-dir with my new Drupal 8 project.
composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction
Worked beautifully!
I am attempting to install ionCube on my VPS from DigitalOcean and I have ran the install and selected the appropriate options but then it simply returns a screen with the header of ionCube but then it has a banner saying "IMPORTANT: Ensure that This Script Is Removed When No Longer Required" followed by a single line of writing that says "ionCube Loader Wizard" and does nothing. In addition the application that it using ionCube says it is still not installed.
The empty Wizard page might indicate that a few PHP functions are disabled, though without the output of your phpinfo(); I can only guess.
DigitalOcean themselves have instructions on how to install the Loader, which can be found here. These are applicable to most VPS with slight alterations. A rough summary in case the link isn't available:
Get and unpack the newest Loader on your server: (if you are not on DigitalOcean please choose your own Loaders here)
32bit:
wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
tar xvfz ioncube_loaders_lin_x86.tar.gz
64bit:
wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xvfz ioncube_loaders_lin_x86-64.tar.gz
Find out your extensions directory:
php -i | grep extension_dir
Which will yield something like
extension_dir => /usr/lib/php5/20090626+lfs => /usr/lib/php5/20090626+lfs
Copy the Loader to the extensions directory:
PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")
sudo cp "ioncube/ioncube_loader_lin_${PHP_VERSION}.so" /your/extensions/dir
For example with the previous output:
PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")
sudo cp "ioncube/ioncube_loader_lin_${PHP_VERSION}.so" /usr/lib/php5/20090626+lfs/
Add the zend_extension entry to your php.ini. This step is not described in the DigitalOcean tutorial, it seems that their PHP is set up to load any extension in the extensions directory I assume, so this might not be necessary for you.
Find out where your php.ini file is (or better yet, plugin directory):
php -i | grep "Loaded Config"
php -i | grep "Scan this dir"
You will get something like this:
Loaded Configuration File => /etc/php.ini
Scan this dir for additional .ini files => /etc/php.d
You can either add this entry to the top of your php.ini (in this case in /etc/php.ini), or add a new file 00-ioncube in your ini directory (in this case /etc/php.d/00-ioncube with this content:
zend_extension = "<path to your ioncube loader>"
As an example with PHP 5.5 and the previous path:
zend_extension = "/usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.4.so"
Restart your webservers:
service apache2 restart
service php5-fpm restart
Do remember to delete the ionCube Loader Script you installed from your server, since this might pose a security risk if left on the server.
In case something goes wrong, check the output your phpinfo();, verify that you have the correct Loaders installed (pay attention to thread safety, architecture and PHP version) and get the Loaders manually from here, and again make sure to choose the right one.
If it still does not work, check your error.log (typically in /var/log/apache2/error.log or /var/log/httpd/error_log) to see if the Loader is being picked up. The ionCube Support is also available should there be any problems.
I created a new project with Laravel, then I put it in the corresponding path for apache could execute, then I write the URL in a browser to open the project and I get the following message
Mcrypt PHP extension required.
I installed mcrypt with this command
brew install homebrew/php/php55-mcrypt
and work fine when I create a new project in laravel
I was searching and I found this tutorial but still withouth work
Open /etc/php.ini and add the line below at the end extension=mcrypt.so.
If there is no php.ini file, then you need to make one from php.ini.default in the same location like so: sudo cp /etc/php.ini.default /etc/php.ini
allow write capability sudo chmod u+w /etc/php.ini
Then add the line as above in your favourite text editor: sudo nano /etc/php.ini
add in the line: extension=mcrypt.so
Restart Apache sudo apachectl restart
but still without work, what can I do?
While it's always good to do PHP stuff on a local server, you will almost always run into the issue of getting everything set up correctly if you don't know what you're doing. My advice, use a service already provided for you.
Using Homestead (Laravel's Dev Environment) will help in getting projects setup very quickly. It'll also have all the PHP modules (e.g. mcrypt) already configured.
I'd take a look at Homestead: Laravel Homestead
Try visiting: Install mcrypt for php on Mac OSX 10.10 Yosemite
OR
Just see your phpinfo(); it will give you the status for mcrypt.
OR
Try updating your php version. Visit: Update PHP
See, if that helps you.
I'll make this quick.
I installed Oracle 11g (with appropriate database, users, etc), Apache 2.4.6, and PHP 5.5.4 on a Fedora 19 system.
I wanted to connect PHP to Oracle. What I really wanted to do was to download MDB2_Driver_oci8, which I thought would be easy, but before I can do such a thing, PHP needs to have that plug-in enabled, so here's what I did:
Tried to install oci8 via the following: pecl install oci8
When that didn't exactly work the first few times, I figured out I, for some reason, needed "Development tools" - via yum groupinstall "Development Tools"
Then I figured out later that PHP actually doesn't do oci8 - it's PHP Devel. So, I had to install that too, via yum install php-devel.
And then, I finally got to install oci8. It asked for the Oracle Directory, and that was that. But it said the following:
Configuration option 'php_ini' is not set to php.ini location
You should add 'extensions=oci8.so' to php.ini
First, I did a locate oci8.so - found it in /usr/lib64/php/modules/
Second, I added what it told me to, to the php.ini file.
Third, I checked the usual php_info() test page - no mention of OCI8. Uh-oh.
Fourth, running both php -i and php -m listed oci8 as one of the modules. Weird.
In desperation, I went ahead and downloaded the MDB2_Driver_oci8. Maybe that will fix things. Nope.
When I loaded my PHP Webpage, it returned the following:
Error message: extension oci8 is not compiled into PHP
As well as: MDB2 error: not found
Strange. And then I decided to check the error logs:
PHP Startup - unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
And now I'm stuck. I tried going into the php.ini, and found that the extension_dir was commented out. I put it back in, which only seemed to break stuff.
Things of note:
I followed this (link) guide on how to configure PHP and install oci8.
./configure --with-oci8 doesn't work. Fedora says no such directory.
As both the webpage files and the actual server reside on the same PC, I did not install the Oracle Client files.
The extension_dir is commented out by default in the php.ini.
This is just one of my problems in a long line of problems concerning the replication of an already existing and working, but dying, setup. It seems whenever I want to solve a problem, I have to do X first. And by doing X, I uncover another problem, which I have to solve by doing Y, which has its own problems, etc, etc.
Any help would be much appreciated. Thanks.
I know this question is a bit old - but I'm writing this here incase others come looking for the solution.
PHP Extensions Directory
To get your PHP extensions directory, run this command
php-config --extension-dir
ORACLE configuration
When you run the config command for oracle, you need to provide it with your Oracle Home directory (this assumes you have installed ORACLE XE):
./configure -with-oci8=shared,$ORACLE_HOME/xe
SELinux policy
You need to adapt your SELinux policy to support what you are trying to achieve. Disabling it completely is not recommended.
On your Fedora system, try running:
which audit2allow
If you receive an error that indicates it cannot find audit2allow then you need to install this package:
yum install policycoreutils-python
Once you have this package, you can pipe your audit log files into audit2allow to have it create your policy file:
grep httpd /var/log/audit/audit.log | audit2allow -m httpd > http.te
This will create the file http.te that is human readable for you to review what the policy additions are that it will make to your SELinux configuration. If you are OK with the modifications, then run these commands (note the capital M in the following command vs. the lowercase m previously)
grep httpd /var/log/audit/audit.log | audit2allow -M httpd
semodule -i httpd.pp
This may take a few seconds to run - you can verify the policy has been installed by running:
semodule -l | grep httpd
You will need to restart httpd so that it can try to load the oci8.so plugin
service httpd restart
HTH
After reading a lot on the internet, I found this page, that indicates I should disable SELinux, and reboot.
That did the trick.
I'm trying to install zend debugger in my Ubuntu 9.04 machine, I've done it in win. but not in linux, I hope you could help me, this is what I've done:
1)Copied the file ZendDebugger.so to /etc/php5/apache2 (didn't choose this folder for anything in special).
2)Added this lines to php.ini:
zend_extension="/etc/php5/apache2/ZendDebugger.so" zend_debugger.allow_hosts=127.0.0.1,127.0.1.1,localhost,*
zend_debugger.expose_remotely=always
I've also tried without quotes(zend_extension=/etc/php5/apache2/ZendDebugger.so)
3)Copied file dummy.php to /var/www
And then restarted Apache but I didn't see the information about Zend Debugger in the phpinfo(), the only related thing I found there was report_zend_debug On.
Thanks in advance
I found much more easy to install Xdebug in my Ubuntu machine.
sudo mv /etc/php5/apache2/ZendDebugger.so /usr/lib/php5/20060613/ZendDebugger.so
This is where your memcache.so, apc.so, etc. are located. Unless you modified your php extensions directory that is where new exts should go.
In php.ini:
zend_extension=/usr/lib/php5/20060613/ZendDebugger.so
cd to that directory and chmod a-x ZendDebugger.so to remove executable bits from the .so.
sudo /etc/init.d/apache2 stop
In another terminal window, tail -f /var/log/error.log and clear console so it is easy to see new log entries coming in (cmd-k on macos).
Then:
sudo /etc/init.d/apache2 start
If there are no errors in error.log, check phpinfo() and see if the debugger section shows up.
You might get errors in the configuration of other php extensions that occur further up in php.ini (e.g., xcache or eaccellerator) that will make loading stuff further down in php.ini problematic.
This is a baseline setup and should work if there are no other problems.
You can also try to install Zend Server Community Edition
You'll get Zend Debugger enabled by default, along with some other nice features. There is a link to the deb repository available through the download page.
I followed the same steps that you did with the same result. In the end the problem was that I was trying to load a 32bit binary with apache running in 64bit mode base (as described in this post) I was able to get it running immediately by doing the following.
stopping apache
executing sudo arch -i386 /usr/sbin/httpd
restarting apache.
After replacing the 32bit binary with the 64bit binary everything worked as expected with no special apache handling. There was also some facepalming involved, but it did not affect the overall outcome.