I am developing APIs in node js and have hosted the application on amazon EC2. In a third party API it is required to host a php page on our server and give its public url back to them. Is there another way to host it apart from a LAMP setup? Anything apart from EC2 is also fine but please take into consideration that this is a single page having some logic and nothing else will be there in PHP.
I work with node and php. I would recommend NGINX. It's configuration files are really simple and it's much lighter-weight than apache.
You can simply create a redirect/rewrite directive in NGINX that will pass your php page to the node server instead and be done. For this usecase, you wouldn't actually even need to install or configure the PHP backend.
http://nginx.org/en/docs/beginners_guide.html#proxy
You might also check AWS domain management tools (AWS Route 53). There may be a way to directly rewrite the incoming PHP request to go to your node app instead without installing any webserver on your EC2.
Yes, there are other web-servers available apart from apache: For instance Nginx plus or Lighttpd, both are fine and lightweight alternatives to host your PHP files on EC2.
Though, it's not clear to me why don't you like the LAMP setup. Maybe Apache+PHP, without MySQL, would be enough for you?
Related
Currently, I developing a WordPress plugin with React frontend.
I tried to connect my backend (PHP) running on a virtual host with webpack devserver with hot module replacement (HMR).
Is there any config how to do it.
note: I tried with devserver proxy but cant figure it out.
Thanks in advance.
Getting HMR is always complicated for custom setup like these. Theoretically, this is pretty simple. You simply need to run the webpack-dev-server with the HMR module. On your PHP file, make sure it uses the JS file generated from webpack-dev-server. The code to refresh is bundled in the JS file so it should work.
However, the devil is in the details. You'll need to make sure the communication between your page and webpack-dev-server works without issue. Monitor your websocket network request and make sure they communicate as expected.
An issue you'll probably encounter is security since the websocket connection is expecting a different host. In this case, you can use config from the following answer: I am getting an "Invalid Host header" message when connecting to webpack-dev-server remotely
Another issue could be that the JS file tries to connect to the wrong location. Eg: It thinks that your host is where the websocket connection is. If this is the case, you can use the public setting. See here for documentation: https://webpack.js.org/configuration/dev-server/#devserverpublic
To me this is akin to running with a reverse proxy. You can see this discussion to understand the problem: https://github.com/webpack/webpack-dev-server/issues/804
There might be other problems. You just need to check the websocket connection and make sure they communicate without problems
How you refer to the generated js file is a separate problem. A simple example would be setting the port to 8081 and bundling the js file into bundle.js. Then in your php code, refer to it as http://localhost:8081/bundle.js
I'm pretty new in this part of programming so any help would be appreciated.
I've made an app and now I want to allow the user to buy via Braintree. I have implemented it with help of some tutorials using PHP SDK, tested on phone using XAMPP and ngrok. It works perfectly (generates token, makes a payment using testing cards) but now I want to move it online. Just simply move that folder from XAMPP instalation folder somewhere online so I (and all other useres) don't need to use ngrok.
Actually, want to replace
final String API_GET_TOKEN = "https:/smthng-random.ngrok.io/braintree/main.php";
final String API_PAY = "http://smthng-random.ngrok.io//braintree/pay.php";
with
final String API_GET_TOKEN = "https:/WHATEVER/main.php";
final String API_GET_PAY = "https:/WHATEVER/pay.php";
so that can give me the same what I've got with xampp and ngrok.
Thanks in advance
btw: PHP is not my better side of programming so it would be great just to move those 2 files (main.php & pay.php) just like they are :) And I've just found that firebase might be option but just exploring for now :)
I think your request is unclear - it's not REST API advice at all, it's about deploying an application to a live environment.
You have successfully installed your web development environment locally (XAMP, nginx) and now it's time to go live.
You basically need a Linux server capable of running, well, apache mysql, php (get where that XAMP comes from?)
This is only an overview, search how to do each of the topics I'll describe:
1. Find a host. (You should go to the shared, vps hostings if you're inexperienced, otherwise, there are way better hosts like linode, digital ocean and AWS, but those can be a little more challenging for beginners.
2. Buy a domain
3. Point the domain's DNS to your host's IP address or NS
4. Now, upload those files you mentioned to the servers public folder. Servers public folders might differ, specially from shared / vps hostings to full-blown Linux instances. If you go the "cloud" way (digital ocean, etc) usually you'll drop the files at /var/www/html
You'll have to set up virtual hosts if you decide to go for the full blown Linux instances
The files should be accessible now. Make sure versions are consistent between your machine and your servers.
I'm developing a SPA that runs on Backbone.js locally and setting server up with Grunt for livereload . I did a REST api with PHP for my app which i also run locally. Now i have a problem with cross domain policy since my servers are on different ports. I tried to combine two servers on one port both from apache and from grunt but i'm not sure if it is at all possible. How should i deal with this problem? i would like to develop my app locally and use the livereload features of grunt.
I propose installing nginx to act as reverse proxy. It can serve static files from one directory (aka frontend), and server side generated scripts (aka backend) from other server.
It serves backend, if the request do not corresponds to the file existing in frontend directory.
This is config example for it - https://github.com/vodolaz095/hunt/blob/master/examples/serverConfigsExamples/nginx.conf
It serves static html, css, js files from directory /home/nap/static and backend from the localhost:3000, and both of them are accessible on localhost:80 as the one server.
I hope this is what you need.
So i ended up using grunt-connect-proxy which did just what i needed.
I am totally confused on how to host a Dynamic website created using PHP and MySQL in Amazon Cloud.
I went through Amazon S3 and I hosted a static website there!
Then I tried Amazon EC2 and I learned some aspects about the concept of VPC. I thought that the dynamic websites are hosting in Amazon Cloud using EC2. I followed some steps and they taught me how to launch a website using Drupal (But, I didn't want that !! )
No other tutorials on EC2 to deploy my web application was not found.
Then I found AWS Elastic Beanstalk, I uploaded a simple PHP document and I can see that deployed successfully.
But Still, I am not satisfied. Because, I don't know which is the correct way to deploy my PHP application.
So can anyone direct me on Deploying a PHP MySQL Application in AWS ?
Depends on your needs. Elastic Beanstalk might be a good option for many apps, but I chose EC2 for my app's backend (using PHP, MySQL and S3 for storage).
Quick steps to get you up and running:
Log into the AWS Mangement Console and start a new EC instance (Windows server 2012 R2 Base > t2.micro should be good enough for a start!)
At step "6. Configure Security Group", add Rules for at least HTTP, HTTPS and RDP (so you can connnect via Remote Desktop)
Connect to your new instance via Remote Desktop and install a decent browser (Enable File Downloads in IE's Security Settings and download Chrome or Firefox)
Open the Windows Firewall and add rules for the same ports you opened in the Security Group of your Instance in the AWS Management Console. (Right-click on “Inbound Rules”, then select “New Rule…”)
Download and install XAMPP (I put it in C:\xampp)
Open the XAMPP Control panel and install Apache and MySQL as services (so they will start automatically when your instance launches); make sure everything is started up.
Now put your files in C:\xampp\htdocs\ and you're ready to go!
Bonus Steps:
Set up Filezilla FTP Server (and open the required ports in both the instance's security group and the Windows Firewall) so you can upload/download files without having to go through Remote Desktop.
Get an Elastic IP and assign it to your instance, so it's IP address will never change.
Get an SSL certificate so you can use HTTPS
The answer depends on the load that you are expecting and the resources you have to handle all the administration tasks.
If you expect heavy or variable loads, there are many reasons why not to deploy a production PHP + MySQL application on a EC2.
Here are some of the benefits of deploying to Elastic Beanstalk instead of a manual configured EC2:
You get version control of each deployment.
You can scale up or down automatically if you need more/less instances to handle new load.
You get a load-balancer in front of your EC2s instances with a bunch of out-of-the-box "recommended" configurations.
Regarding MySQL, if you go for an Amazon RDS instance you can handle replication, monitorization and automatic backups with pretty low effort. A lot of the configurations you would need to tweak are now available through parameter-groups.
On the other hand, if you want to have full control of everything that is going on on your server (that means you have time to monitor, backup and do maintenance tasks, which is not my case :), or if you do not plan to have much traffic, or if you want the less expensive option, you should go with a low cost EC2 instance.
In my experience, (after 2 years of working on AWS with 10 production applications, I'm kind of a regular AWS user) pretty much every customization or change I needed on both RDS and EBS I was able to tweak it and get it working, so I'm pretty satisfied with choosing the EBS+RDS option.
Below are two links i found which are helpful to Create and Update an Application with AWS Elastic Beanstalk
https://aws.amazon.com/getting-started/tutorials/launch-an-app/
https://aws.amazon.com/getting-started/tutorials/update-an-app/
It seems like there are two ways to go, and the determining factor is whether you want to host on your own computer, or through a webhost.
If I have an IDE, a webhost server I subscribe to, and an FTP client to transfer my files to the server, then I don't need to install PHP, MySQL, and XAMP, right?
I know XAMP allows me make my computer website server.
When I install PHP, am I installing the intepreter for my computer/server to parse the .php files? (and same for MySQL?)
If I pay for web hosting, then their servers already have PHP and MySQL parsers, and all I need to do is upload my text files, right?
Thanks in advance
U just cant simply put the files in server without developing them.and if you want to develop any website or any webapp then u need to make your system a local server where you can execute your server side languages like php.XAMP is a short form for mysql,apache and php for windows.and 'website server' is not the proper word.use LOCALHOST instead because only u will have access to your server unless you are connected via LAN or WAN.so i can summarize the above in few points keeping in mind that you want to develop your website.
step 1:install XAMP
step 2:develop and test your scripts.
Step 3:if everything works fine than host your site in the webserver for everybody to see it.