-2

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 ?

najmulx
  • 21
  • 6
  • @bluto: there is no error which I could see. I'm trying to insert the values via POST method and then checking for successful insertion. On unsuccessful insertion, I'm displaying an error. Same code is working fine on Linux shared server dream host, issue is with was ec2. – najmulx Oct 21 '15 at 12:32
  • 1
    you can check in error log. path is: `/var/log/apache2/error.log` – Pathik Vejani Oct 21 '15 at 12:37
  • 1
    @bluto: Thanks for mentioning the path of the log file. I cud see in the log file, php warning. **Couldn't fetch mysqli in the** path and **Access denied for user ** – najmulx Oct 21 '15 at 12:45
  • @bluto: This issue, I will fix but any idea why the sms api is not working ? – najmulx Oct 21 '15 at 12:56
  • it is depends on which api is being used. – Pathik Vejani Oct 21 '15 at 12:59
  • @bluto: Both the issues got solved. There was a restriction in the server where my database file was residing. I had to explicitly add the server address from where the address was getting initiated. Regarding the SMS api, I had install mysqlnd and curl on the aws server. Thanks for your help for pointing the log files. – najmulx Oct 22 '15 at 12:13

1 Answers1

0

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

Community
  • 1
  • 1
najmulx
  • 21
  • 6