I'm a newbie in aws and have created an ec2 instance on ubuntu server with php, mysql and apache installed where I have hosted couple of html files along with other scripting php files. The website is working fine. I have created a webservice which has to be consumed in different clients. The purpose of this webservice is to insert some values in a remote db table.
a) www.abc.com/client/add.php returns success and I cud see the values getting updated in the db table
The above webservice is working fine on a test server but when I had uploaded the same set of files on aws ec2, the webservice is giving me an error.
b) www.abc.com/client/add.php returns failure. I have checked the db configuration file, connection strings for remote host is correct.
I am also facing similar issue in integrating sms api to push sms to consumers cell. On Test server, my code is working fine and sms are pushed but same piece of code is not working on aws ec2.
I suspect, it is related to the rules in ec2 security group because of which it cannot connect to the remote mysql host and to the sms gateway.
Can any of you help me in assigning the proper rules ?
Currently I have assigned the below privileges for Inbound rules
type HTTP, port 80 for all
type Mysql port 3306 for all
All traffic for all
type SSh, port 22 for all
Do I have to assign any outbound rule as well ?
Firstly thanking #bluto for pointing me to the log files where I was able to see the errors and fix them.
My aws inbound and outbound rules were appropriate.
From the log files, I identified mysql_connect(): Access denied for user.
To fix this I had to explicitly assign the host IP address in allowable host section of the db webserver.
For the second issue wherein my SMS api was not working, I identified the error in log file
PHP Fatal error: Call to undefined method mysqli_stmt::get_result().
To fix this, I came to know that mysqlnd is required to execute Bind_result() & fetch() which was missing in my aws ubuntu server.
http://php.net/manual/en/mysqli-stmt.get-result.php
I had to install mysqlnd by the following command.
apt-get install php5-mysqlnd
Pls remember that installing mysqlnd will break your appcode. For it to work, I added the following line in the end of of php.ini file. The path of php.ini file can be find by output of php.info()
extension=mysqlnd.so
After successful installation, I saw that curl needs to be installed in the server as I was getting an error. I installed it by the below command. Ensure to restart the apache server after the installation
sudo apt-get install php5-curl
References:
Call to undefined method mysqli_stmt::get_result
https://askubuntu.com/questions/386887/install-curl-ubuntu-12-04
Related
I've created an application in php that sends texts out to people using the twilio api. It works perfectly in XAMPP but the php code doesn't run in Azure. Everytime I call it I get an error message saying "Failed to load resource: the server responded with a status of 500 (Internal Server Error)".
Is there a way I can solve this problem without having to create my own virtual server?
Usually, when we get 500 response, it means we get some errors on server scripts. And we can set the display_errors=On in PHP runtime on our Azure Web Apps for easy troubleshooting. Refer to https://azure.microsoft.com/en-in/documentation/articles/web-sites-php-configure/#how-to-change-the-built-in-php-configurations for details.
And you may check whether your application on Azure Web Apps has successfully installed the twilio lib. You can leverage composer to configure the sdk in composer.json, then when you deploy your application to Azure via Git, Azure service will install the dependencies in composer.json file automatically during the deployment task.
You can leverage require 'vendor/autoload.php' to load all the dependencies.
At the first time during the test, I got the following error:
Fatal error: Uncaught exception Services_Twilio_TinyHttpException with message SSL certificate problem...
So it may be the issue on your side too, you can add the certificate in PHP on Azure Web Apps, please refer to https://blogs.msdn.microsoft.com/azureossds/2015/06/12/verify-peer-certificate-from-php-curl-for-azure-apps/ for detailed steps.
Otherwise, you can simply edit TinyHttp.php in twilio lib:
add CURLOPT_SSL_VERIFYPEER => FALSE, at $opts array.
Refer to Twilio PHP - SSL certificate: self signed certificate in certificate chain for the same issue.
They have many possibles:
Your Azure running PHP in ISS Server, then you need convert your .htaccess file to web.config, simple, just go to website in IIS and on import your .htaccess file, IIS will convert your .htaccess in web.config.
Permissions on folder you are running.
PHP versions, check your PHP version on xampp and compare to PHP version on Azure. Your code can be compatible in your PHP Xampp but not in PHP Azure.
Extensions PHP, it is possible that your xampp has extensions for PHP enable that your Azure not are enable, like file_info, etc...
I just started up an Azure server and have been trying to access it for a while and am having a hard time doing so.
I installed zPanel on my 12.04 Azure Ubuntu server (like cPanel: Apache, MySQL, PHP, etc) and made sure Apache was working and pointed a domain to the server IP and gave it to zPanel's installer to config.
I tried accessing the server through direct IP, through the domain and even pinging it. I keep getting Request timed out.
I'm using the "Resource Manager" in Azure and can't find a way to specifically allow port 80, so I'm assuming it's enabled already, but that's the only reason I can think of for not being able to access the server. Any ideas?
Try to add the specifical port on the Azure old portal or new portal, please see the pictures below.
Fig 1. Add the endpoints(ports) on Azure old portal
Fig 2. Add the endpoints(ports) on Azure new portal
Hope it helps. Best Regards.
Not sure if what I am attempting to do is possible or not. I just launched my very first EC2 instance running Ubuntu 12.04 and successfully installed Laravel 4. I have the database working just fine on the EC2 instance and I am able to connect to it with MySQL Workbench on my local machine using a .pem SSH key.
I will be using EC2 to handle certain aspects of a product that I am developing to ensure improved reliability - client side users will be interacting with this primarily through CURL. I want to be able to have my non-EC2 website, also running Laravel 4, use the MySQL database that I set up on my EC2 instance.
I tried changing my app/config/database.php file to include the EC2 instance IP address and MySQL credentials, when Laravel attempts to connect it returns a timeout error.
I modified my.cfn and commented out bind-address = 127.0.0.1, I do not seem to have the skip-network that I have seen mentioned. Still no joy.
Any suggestions?
In side MySQL (PhpMyAdmin if you installed it) -> Users overview -> Edit your user with Host is
%
That is mean, you can connect to MySQL in anywhere with command
mysql_connect($IpOfYourHost, $UserAbove, $Password)
Maybe this helps you. :)
Resolved
I changed bind-address to 0.0.0.0, created a new MySQL user - 'user'#'%', and had my host whitelist the IP. Done!
Need basic help configuring Google App Engine SDK on a Windows 7 system to use a local install of MySQL. The GAE install is vanilla (GAE 1.8.8, Python 2.7.6, PHP 5.4), with MySQL 5.6.15 also installed. I am able to use the MySQL console, so MySQL is running. PHP is also running.
When I run a short PHP script consisting almost entirely of this line:
$dbconn = mysql_connect('localhost','root','rootpwd');
this is the error message I get:
Warning: mysql_connect(): No connection could be made because the target machine actively refused it.
My question: What settings do I need to add or change to allow my PHP scripts to connect to MySQL?
My root username and password are correct, as verified by my ability to access MySQL through the console. There are some difference between the GAE SDK setup and that of a WAMP server, which I also have installed on the same machine but which is not running now. Is there still likely to be a conflict between the freshly installed MySQL instance and the one on the WAMP server? Are there some environment variables (in Windows, in the SDK, or elsewhere) that I need to set?
I'm fairly sure this question has been asked before, but the answers I am seeing are either more complex than I can believe would be necessary, or simply gloss over the details of configuring the connection. Any help would be appreciated.
FIGURED IT OUT... Apparently my script was being pointed to the MySQL instance from the WAMP server, which was not running when I tried to connect in the script. As soon as I started that MySQL instance, the script connected to it.
So the moral of the story is... if you already have a MySQL instance installed outside of the GAE SDK, as long as that service is running your GAE PHP script will find it, and there's no need to install another MySQL instance just for the Google SDK.
You must allow external connection.
I don't know the path, but, apparently, the GAE connects to localhost not directly.
You can change the "localhost" by "127.0.0.1" to test it, or to "::1".
Some links to try change MySql external connections rules.
http://www.thegeekstuff.com/2010/08/allow-mysql-client-connection/
How to allow remote connection to mysql
I am using the Heroku app to host a facebook application since Facebook is changing how they have their applications set up, again. However I need to connect to the MySQL Externally from my cPanel VPS and I am not able to connect correctly. I have tried using the darkprospect.net(host domain), ultimate-battle-online.com (primary domain of user) and 184.154.20.170 as well as those plus the combination of added port 3306 and none have worked. I previously needed to make sure that I added the right domain to the right file but right now it's just not connecting. Right now get this error when using mysql_connect() function:
Lost connection to MySQL server at 'reading initial communication packet', system error: 110
Again, thank you for any ideas that you may have!
EDIT: I found out that it was an issue with the buildpack that is the default for PHP apps, since I develop on a VPS with PHP 5.4.7 I was using parameters that were tuned for it and were not very supportive on their bundle of vanilla PHP and Apache.
I was able to create a new Heroku buildpack that was able to support all of the features that my application was needing. Because I was developing on my VPS in PHP 5.4.7 my configurations were designed for more of the new features and with the Heroku's basic Buildpack only having PHP 5.3.10 there were unseen errors in background logs that were halting the connection process. Additionally CSF Firewall was configured only for UDP income 3306 and I was able to add it to UTP as well and that seemed to resolve the Connection Timed Out error that was the final error after I made a better buildpack for myself.