I'm trying to set up a PostgreSQL db with a REST(php) gate. I want to access this database the standard REST way (using GET and Headers), from a C# application.
Currently I am using a standard web hoster that has a MySQL database, but I want to jump ship to PostgreSQL.
Am I right in thinking Amazon's EC2 servers a good choice to do this? I just need a server with PostgreSQL installed and a bunch of php scripts (for REST).
Thanks
EC2 would work fine, or you could use an RDS PostgreSQL instance, and just run the PHP scripts on a small EC2 instance.
Check out restSQL. It's an open-source, ultra-lightweight persistence layer, with out of the box PostgreSQL support.
It's written in Java but you can use its HTTP API by deploying the service in a standard JEE container, e.g. Tomcat, or as a Docker container. The latest versions are on bundled as images on docker hub.
You can take it for a spin using the sandboxed instance and explore the docs at http://restsql.org.
Related
Hope someone can point me. Google doesn't yield much that's simple to understand (there's stuff like Pheanstalk, etc), and Amazon's own Beanstalk documentation as always is woefully arcane presuming that we use Laravel or Symfony2.
We have a simple set of 10 PHP scripts that constitute our entire "website", with fast functional programming. In our testing this has been much faster than doing the same things with needless OOP. Anyway, with PHP 7, we're very happy with the simple functional code we have.
We could go the EC2 route. Two EC2 servers load balanced by ELB. Both EC2 servers just have Nginx running with PHP-FPM, and calling the RDS stuff for data (ElastiCache for some caching speed for read-only queries).
However, the idea is to lower management costs for EC2 by relying on Beanstalk for the simple processing that's needed in these 10 PHP scripts.
Are we thinking the right way? Is it simple to "upload" scripts to Beanstalk in the way we do in EC2 via SSH or SFTP? Or is that only programatically available via git etc?
You can easily replicate your EC2 environment to Elastic Beanstalk using Docker containers.
Create a Docker container that contains required packages (nginx etc), any configuration files, and your PHP scripts. Then you'd deploy the container to Beanstalk.
With Beanstalk, you can define environment variables that are passed to underlying EC2 instances where you application is running. Typically, one would use environment variables to pass, for example, the RDS hostname, username, and password to the Beanstalk application.
Additionally, you can store the Dockerfile, configuration files, and scripts in your git repository for version control, and fetch them whenever you create the container.
See AWS documentation about deploying beanstalk application from Docker containers.
I have a cloud service on Azure and on that cloud service, I have 2 VMs. And I have apache, php, mysql, phpmyadmin installed on both. Both the VMs lie on the same availability set as well.
If my cloud service dns is hello.cloudapp.net and I access phpmyadmin by going to hello.cloudapp.net/phpmyadmin and create a database, which VM will it create a database on?
One of the two, depending on whichever one the load balancer decides to send you to.
The problem is having a separate instance of MySQL local to each VM. Instead, you need something that will create a shared data context between the two instances; MySQL Cluster looks promising.
As availability set just makes sure that your application is not affected by single points of failure, like the network switch or the power unit of a rack of servers. And you have 2 same VMs in a cloud service, so load balancer may create different data in these instances of MySQL V. So you have to handle such as synchronization in MySQL, such as MySQL Cluster as #Ic. said.
As another approach, we can create a new VM Installed MySQL database in a new cloud service as data tier.
Of cause, as an alternative approach, you can use the 3th part service, i.e. ClaerDB which tends to take care of most of these things for you.
After many hours of reading documentation and messing around with Amazon Web Services. I am unable to figure out how to host a PHP page.
Currently I am using the S3 service for a basic website, but I know that this service does not support dynamic pages. I was able to use the Elastic Beanstalk to make the Sample Application running PHP. But i have really no idea how to use it. I read up on some other services but they don't seem to do what I want or they are just way to confusing.
So what I want to be able to do is host a website with amazon that has dynamic PHP pages. Is this possible and what services do you use?
For a PHP app, you really have two choices in AWS.
Elastic Beanstalk is a service that takes your code, and manages the runtime environment for you - once you've set it up, it's very easy to deploy, and you don't have to worry about managing servers - AWS does pretty much everything for you. You have less control over the environment, but if your server will run in EB then this is a pretty easy path.
EC2 is closer to conventional hosting. You need to decide how your servers are configured & deployed (what packages get installed, what version of linux, instance size, etc), your system architecture (do you have separate instances for cache or database, whether or not you need a load balancer, etc) and how you manage availability and scalability (multiple zones, multiple data centers, auto scaling rules, etc).
Now, those are all things that you can use - you dont have to. If you're just trying to learn about php in AWS, you can start with a single EC2 instance, deploy your code, and get it running in a few minutes without worring about any of the stuff in the previous paragraph. Just create an instance from the Amazon Linux AMI, install apache & php, open the appropriate ports in the firewall (AKA the EC2 security group), deploy your code, and you should be up & running.
Your Php must run on EC2 machines.
Amazon provides great tools to make life easy (Beanstalk, ECS for Docker ...) but at the end, you own EC2 machines.
There is no a such thing where you can put your Php code without worrying about anything else ;-(
If you are having problems hosting PHP sites on AWS then you can go with a service provider like Cloudways. They provide managed AWS servers with one click installs of PHP frameworks and CMS.
I am looking for a way to automatically turn off/on a microinstance on session based intervals. I need to be able to do this to automate when I am paying for the EC2 server. Does anyone know of any ways to do this using PHP or some other backend technology
You can always start and stop instances using the AWS command line tools (i.e. make a BASH script to do this) or by using the AWS PHP SDK. Of course the problem is that you will need some separate server on which you can run a cron or similar to execute your start/stop scripts.
Zend Framework 1.x have some classes to work with Amazon EC2 (Zend_Service_Amazon_Ec2).
What would be a better choice for making a database driven
Adobe AIR(Desktop) application?
Using PHP+MySql with AIR
OR
Using SQLite
If I choose SQLite, then I cannot reuse my code for
an online application.
If I choose 1, I have to block few port numbers on User's machine.
Also, I am using XAMPP for providing the user with PHP and MySql, so
XAMPP opens up a command window as long as it's running. And, users
get confused about what's that window for? It makes the end user
experience slightly confusing.
I'd definitely use SQLite as its included in Air.
May I suggest; write your code in two sections. The UI which uses a JSON feed to populate itself, and the API to provide the JSON data. When it comes to port the application to the web you can use the same UI but with a rewritten API.
Whatever you do, don't open up a command window while the program is running. If you do that, your customers will uninstall like there's no tomorrow.
As far as mysql vs sqlite, the standard approach is - if it communicates remotely, feel free to use mysql, but if you're installing the db on the client, you should use an embedded standalone db (sqlite).
How complex do you expect your app to be that you can't use sqlite (besides not being able to reuse some of the code that you mentioned)?
If XAMPP is too confusing for your client, install Apache and MySQL as standalones. It's essentially the same thing and you'll have more control over what's running in Apache/MySQL. Plus you won't get an annoying command window (though, to be quite honest, I don't recall a window that I couldn't minimize to the tray when I ran XAMMP).
My suggestion is use Sqllite as your local database and writes a synchronization API that will synchronize the local sqllite database with the server side database-MySql. So according to your client you can use the system. If the client is standalone then Sqllite will serve otherwise the MySql will serve. Only thing you have to decide in both this is how to use the synchronization api.
Just check the Sample Application