I'm having some difficulty setting up Nginx with PHP and MYSQL on mac, where I cannot make any connection to the database. If I spawn a server using php -S, I can connect without problem. However Nginx running on port 8080 is unable to connect at all.
I've installed (and now uninstalled) php with brew, which might be an issue because it looks like PHP comes installed on mac. Running php -v shows me running on 7.1.16, but the brew installed version was 7.2+. I have PHP-FPM running on localhost:9000.
I've checked my php.ini files, but I only see extensions for mysqli and pdo_mysql, which I've tried to enable but still no luck.
Thanks for any help.
Related
I created a droplet in DigitalOcean (LAMP on Ubuntu 20.04)
Installed WP PHP files using WinSCP
Run it on PUTTY
Checked site on web browser
I received a message saying "PDO Driver for SQLite is missing"
Found solutions online and here's what I've tried:
Find php.ini & uncomment (remove ;) on extension=pdo_mysql & extension=pdo_sqlite
Restarted apache on PuTTY by using this command sudo service apache2 restart
But didn't work
Any tips please?
I downloaded the installer version of Xampp version 8.1.6-0 for Mac and went to the manager-osx widget to start the Apache and MySQL servers but neither would start.
I then tried using the command sudo apachectl start and then created an index.php file and put it in htdocs, and then tried to open it using http://localhost/index.php as well as http://localhost:8080/index.php and both times it said the server could not be reached.
I've actually downloaded Xamp in the past and was able to reach the server but wasn't able to get php scripts to run, but now for some reason I can't even get the server to run.
I made sure to download the installer and not the virtual machine version. I'm running Monterey version 12.4.
I tried the solutions here but they didn't seem to work. I checked my activity monitor and nothing is running on port 80.
I also installed MAMP from here and tried to start Apache but it displayed the error:
"Apache couldn't be started. Please check your MAMP installation and
configuration."
Any help would be appreciated as I just want to run PHP.
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've been searching and trying for quite a while to find an answer, so will finally ask here.
I have a UBUNTU install from Turnkey LINUX, PHP Ver 5.6.23.
I have compiled and enabled mssql.so as I require to connect to a MSSQL server.
My simple connect PHP script is so:
$server = 'rslocal';
$connect = mssql_connect($server, 'sqluser', 'sqlpassword');
if (!$connect) {
echo 'can not connect';
}
I can run the above PHP script from the command line and it is successful.
I can also run the FreeTDS tsql utility and connect and query the server from the command line
When I run it from the browser through Apache, it tells me
Fatal error: Call to undefined function mssql_connect() ...
I have checked that php --ini (cli) and phpinfo() (browser) both report the same ini file in use.
I am not running SELinux so the setbool commands are not relevant here, however the problems stated by others where SELinux WAS the issue are exactly the same as mine, so perhaps this is a place to start.
My feeling is that it is a security policy or something stopping the extension from loading any function that wants to communicate with an outside server, but I am stuck.
Any help would be appreciated.
I found the "answer". On this distro, Ubuntu 14.x, the command
sudo apachectl restart
doesn't seem to be enough to reload php. The php.ini change, specifically adding extension=mssql.so had not been not applied when run through apache. This raises the question how to "hard" restart Apache so php.ini changes take, but that's a different question. I only noticed that it worked after a reboot.
I've installed Apache 2.2 and PHP 32bit on a Windows 7 64bit.
I configured properly PHP to run as a module and works like a charm.
Then I've installed MySQL Server 5.1 64bit.
After activating mysql or mysqli, php runs as expected but when I connect to localhost with the browser, the php script cannot connect to the database using mysql_connetc() and it generate a timeout error.
Running phpinfo() it says that the mysql modules are running with no errors.
I've tried to uninistall mysql server win64 and reinstall the same version but for win32.
The same happens.
Googling around I found this post on the mysql forum
http://forums.mysql.com/read.php?11,366955,366962#msg-366962
http://forums.mysql.com/read.php?11,366955,378099#msg-378099
Basically if you do not set in the host file that localhost is 127.0.0.1 windows 7 uses IPV6 address by default for localhost resulting in a connection error.
Adding this to the host file solve the problem:
127.0.0.1 localhost
Have you added appropriate firewall exceptions? can you connect to mysql using the command-line tool or similar?