I'm buildig a simple web application in Laravel 8 using PHP 7.4 and Azure web services. The app runs perfectly on my local machine, but once I try to push my app to Azure I'm getting a PHP 500 error for all pages where some sort of querying is needed.
It turns out that I'm missing a pdo_mysql driver that hasn't been enabled when setting up our Linux server. I've been looking through all the Azure documentation and I can't seem to find how to turn this pdo extension on.
Strange thing is Azure provides us two terminals: the SSH terminal and a Bash terminal (Kudo remote execution terminal). When I run
php -m
in the SSH, the pdo_mysql module does show up in the list. I can also migrate my tables within the SSH. But once I run the same
php -m
command in the Bash terminal, the module is not showing. Migrating tables in that terminal is also not possible, because it says I'm missing the pdo_mysql driver. The Oryxbuilder that builds my application after each git deployment also notices that I'm missing the pdo_mysql driver and returns the same error.
So how can I enable this module in Azure? Can anyone please help me?
First of all i'd check to see if its enabled in the php.ini file, often located at /etc/php/{version}/cli/php.ini , cli may also be cgi or apache2.
Related
I am following the process as described here:
https://www.ibm.com/support/knowledgecenter/en/SSHRBY/com.ibm.swg.im.dashdb.doc/connecting/connect_connecting_php.html
I have completed the instalation and I have even run the validation command in shell
db2cli validate -dsn DashDB -connect -user bluadmin -passwd 'your_secret_password'
see output below
But still my www page crashes on the line
$conn = odbc_connect( $conn_string, "", "" );
becasue it does not recognize the odbc_connect function.
Any feedback and hopefully help is very welcome.
Your question is not about programming, but instead it is about configuration.
It is best if you detail your php version and your linux distro details fully every time you ask for help.
You already successfully configured db2dsdriver.cfg and successfully validated a CLI connection to the remote Db2 database. That is essential.
The next step is to ensure that both ODBC and PHP are configured appropriately.
It may help to verify all the following items:
Verify php-odbc is installed to match your version of php . Use the package-manager (e.g. yum or apt etc.) for your linux distro to install it, there's plenty of pages to help you with that.
Verify the php.ini has enabled: extension=odbc.so ( for Linux it seems this is not default with php7).
Verify that the command-line php -m shows that odbc is loaded
If you configured a unixODBC DSN then verify you can successfully connect to the DSN with isql command on linux (to verify that your odbc.ini and odbcinst.ini are properly configured with the Db2 driver and the DSN details). Use odbcinst -j to show the path to odbc.ini and odbcinst.ini for your distro. There's plenty of pages to show how to configure those files, and how to run the isql command line. Usage of a DSN is optional, but it can help with sanity checking and centralises the connection strings instead of having them replicated in php scripts.
verify the ibm_db2 driver is loaded and pdo_ibm (if using PDO interfaces) with the php -m command line.
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
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.
I know this question have been asked a thousand of times, but I can't find a solution. I'm running Symfony 2 with a PostgreSql database (php running in MAMP, and PG DB on an another port and install).
I was running well (could have install the DB using the app/console create cmd) however now I can't use it anymore for updating the schema. Got the error :
PDO Exception, could not find driver error
I tried everything:
Php.ini verification : OK
using the same in the CLI and phpInfo();
PDO verification in phpInfo : drivers enabled for pgSQL mySQL etc...
Restart Mamp + OSX apache server : OK
Found a solution,
I just made an alias in my .bash_profile to the php used by the server to be sure that the CLI will use the good one.
Alias PHP -> Mamp CLI
alias phpmamp='/Applications/MAMP/bin/php/php5.4.4/bin/php'
Now it works.
We are having almost the same issue as this person:
OCI8 functions not found when run by apache with php5
The difference between their issue and ours is that we only have one php.ini (/etc/php.ini). We are running PHP 5.3.5 with Apache 2.2.3 on CentOS 5.5. As you can see, their question was never really answered but I hope y'all can help up with ours. Thanks!
I have found the cause of the issue but I do not know how to permenantly solve it. Apparently, our test server is using SELinux set to "Enforce". Setting it to "Permissive" allows Apache/PHP to run the oci8 extension. My boss, however wants SELinux set back to "Enforce" for which I do not blame her. I'm going to look into creating an exception for Oracle/oci8.
Re. SELinux and OCI8 when running as an Apache module
Suggested solution from http://old.nabble.com/php-with-oci8-td16460446.html
you can customize your policy to allow this access using audit2allow
# grep http /var/log/audit/audit.log | audit2allow -M myhttp
# semodule -i myhttp.pp
This should allow you to run these oracle apps with SELinux in enforcing
mode.
There's also a thread about this on the oracle forums
Ensure that you have ORACLE_HOME, ORACLE_SID and LD_LIBRARY_PATH in the Apache envvars. Remember that Apache is running as a daemon, so it doesn't necessarily have access to the same environment variables as when you run your PHP scripts from the command line.
ORACLE_HOME=/u01/app/oracle/product/10.1
ORACLE_SID=orcl
export ORACLE_HOME ORACLE_SID
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
Depending where your database server is and how you connect to it you may also want to set TWO_TASK or TNS_ADMIN. To ensure the correct character set is used, you may also want to set NLS_LANG.
EDIT
I normally build PHP from source, so I have full control:
Assuming that the standard Oracle Client is running on the server, then my ./configure includes:
--with-pdo-oci=$ORACLE_HOME
On the couple of occasions when I've needed to build for the Oracle instant client, I've used
--with-pdo-oci=instantclient,/usr,10.2.0.3
in my ./configure line
Note that I use PDO_OCI rather than OCI8, but the ./configure should be similar
The other step that I take when deploying to a new server is to ensure that the apache user/group (as defined by the User and Group directives in httpd.conf... my apache runs as user "daemon") will have read and execute privilege to the files under ORACLE_HOME