I am working to build a small email client inside a web application. After doing some research I attempted to use the imap function. I got an error saying I was calling an undefined function, so again I researched and uncommented extension=php_imap.dll.
I then found I had to update php with the imap function and I did so. Now, the imap functions works in php interactive inside Terminal, but I can't get it to work in the browser. I'm assuming I have to somehow load it in the Apache Config files but I can't seem to find how to do so.
Any Ideas?
You'll need to restart Apache to reload the PHP module with the new configuration. The command line PHP starts a new PHP instance each time with the latest configuration, whereas the PHP extension running in Apache is separate, and only loads new configuration setting when Apache itself is restarted.
Assuming you're running on Windows based on the .dll extension, so apachectl restart or apache2ctl restart may work, or the installer you used may have a tray app or other GUI tool that can do it for you.
If running on Linux sudo service apache2 restart or sudo service httpd restart depending on distribution.
Related
I have an Ubuntu VM / Azure SQL DB combo where I have two sets of PHP files.
1) Some scripts that run from CRON jobs
2) A Yii2 Framework website
Both environments connect to an SQL Server database.
I have done all the steps to compile sqlsrv and added it to PHP's list of extensions. My scripts work great from the terminal, but on the website, I get an error:
could not find driver
My webserver is nginx, and it runs the website properly, but PDO does not connect to SQL Server.
I only have one PHP installation, but nevertheless used code to determine which is the right php.ini file in use and it has the right extensions directive.
A phpinfo() output also shows sqlsrv in the 'Registered PHP Streams' section.
My UFW firewall is inactive and I don't have SUSELinux. Nevertheless ports 22 and 80 are open. Even tried enabling it.
I am not sure what else to try. Help!
EDIT
I created a simple test file. When I run that through the terminal, it works, but when I do so via a browser, it doesn't.
EDIT 2
I installed Apache2 instead of nginx, and everything works now.
I think you need to try with just some "Hello world". If this not help type in terminal:
sudo apt-get install php-mysql
And restart your nginx server with:
sudo killall nginx && /usr/local/nginx/sbin/nginx
Followed a few tutorials but it just doesn't update.
I restarted the server many times with sudo service apache2 restart and sudo apachectl restart
I ran php --ini to check all the files being loaded
I checked each file to see if it is being overwritten
I made another override and checked if its being loaded
Used the phpinfo() function to check if its being updated
I'm using PHP Version 5.5.9-1ubuntu4.21
Its a virtual machine in virtualbox
the change that I'm trying to make is for php to allow more inputs in a post.
I don't know if I should post here or in Super User
Chances are you are modifying the php.ini of the CLI instead of the one for apache. It should be under:
/etc/php/$VERSION/apache2/php.ini
Then restart apache.
In my specific case I work with a CentOS 7 environment with both PHP-FPM 5.4 and 7.1 installed. I recently installed php-pecl-imagick and was wondering if a reload or restart was in order to make use of the service, or not at all. (and if httpd needed to be restarted/reloaded) The PHP manual doesn't seem to give an answer on this, and I've seen different recommendations in installation manuals.
You need to restart the apache service after PHP extensions are installed / uninstalled. If you have SSH communication, you can try the command below.
service http restart
// service (service name) restart
I want to use my Raspi as a webserver so I followed this guide that basically set me up with an apache server and accompanying php modules. This works for html webpages.
The config file seems to suggest this module is being loaded by the apache server, but obviously something is going wrong since some test.php file:
<?php phpinfo(); ?>
fails to produce any output. I have reinstalled apache and have verified the (as far as I can see) correct url's to but to no avail.
How do I get to see my precious php info?
Obviously I will supply required information.
In order to run php script with Apache web server, you have to install php package in your server and libapache module which is required by apache to run php scripts. You can use following command to install php
sudo apt-get install php5 libapache2-mod-php5
Hope it helps.
I've replalced the flashdrive with a clean raspbian and retried the process, and for some reason this time I do get the desired output. I have no idea what happened there.
I want to try the ZeroMQ, and I write two php file, service.php and client.php.
I use the linux terminal to run service php /web/test/service.php,it's ok, terminal print a "waiting for client connecting...".
but, I request my client.php through chrome explorer,error happened, I check my error.log,there is message "php fatal error: class 'ZMQContext' not found........"
and I use command php -m to check my php extension, zmq is already in that list.
The problem is that the ZMQ module is loaded in the PHP CLI (Command Line Interface) but it's not loaded into Apache. Therefore, service.php runs smoothly from the Command Line but client.php can't use ZMQContext because Apache does not load ZMQ.
There are two different .ini-files. These probably are (but can be different, depending on your distro):
/etc/php5/apache2/php.ini for Apache
/etc/php5/cli/php.ini for CLI
However, all .ini files from the /etc/php5/conf.d/ directory are loaded into both Apache and the CLI.
See also: PHP - An external Class/library is accessible from apache but not from phpunit (the exact opposite of your problem)
Check which php.ini files are loaded
Checking (with phpinfo) which php.ini files are loaded when requested via nginx (which probably means via php-fpm) - will almost certainly reveal that it loads different ini files than the cli. Assuming php-fpm usage, the following ini files are probably loaded:
/etc/php5/fpm/php.ini
/etc/php5/fpm/conf.d/*
and no zmq.ini file listed.
Loading zmq for php-fpm
Follow the instructions for installing zmq on php, and create an ini file for zeromq (or copy the one from /etc/php5/cli/conf.d/ since evidently it's loaded for cli usage):
# /etc/php5/conf.d/zeromq.ini
extension=zmq.so
Then restart php-fpm
sudo /etc/init.d/php5-fpm restart
And zeromq should be available for use.
A really easy way to solve this issue is to enable ZMQ globally (cli + Apache) with phpenmod
For example with php5
php5enmod zmq
service apache2 restart