run PHP and Nodejs app together in a cPanel account - php

I have installed Nodejs on my cPanel Cloudlinux server.
I created a Nodejs app (Nuxt.js) for my website frotend via Software > Setup Node.js App in my cPanel account and linked it to my website root (example.com/)
Now I want to create an API PHP service (Laravel) for my website backend and place it in my example.com/api directory which it returns JSON from this address. But when I visit this url, it returns my Nodejs app page which I created before for website root.
In fact, I want the publci_html/api folder to be exclude from rendering via Nodejs server.
Is it possible?
Or should I commit some changes in .htaccess file?
Regards

I suggest you create api.domain.com as a subdomain so you can use api.domain.com (public_html/api) for the Laravel application without any problem.
But if you have .httacess in the root directory and Node.js use rewrite rules, you can also add RewriteRule code to excluding :
RewriteRule ^(api)($|/) - [L]

Related

Laravel Forge - multiple sites on the same server

I have over the past months tried to learn myself about php/laravel. I have made some laravel hobby apps which i was thinking of putting on a server, so i could use them.
I am using digitalocean for the server and laravel forge for easy deployment.
My problem is that on laravel forge it says that i can add sites, but how do i add more than one site?
There is three fields to fill in: Root Domain, Project Type and Web Directory. What do i type in these fields and how do i access the site afterwards?
Root Domain: This is the domain (web address) that you want to be associated with your site (e.g. example.com).
Project Type: This is the type of application that you're wanting to be hosting. In your case it will be General PHP / Laravel.
Web directory: This is the folder of your app that you want to use as the web root. In your case this should be public/ (unless you've moved/renamed the directory or you've moved you index.php out of that directory which I don't recommend). It is generally good practice to have your web root in a sub directory so that you can easily prevent access to sensitive information by placing it in the root directory or you app.
With a Laravel site you should almost always only have to fill out the root domain field as the rest are set for Laravel by default.
Forge comes with a "default" site set up so that you can access your site with just your ip address of the server, however, if/once you've got your domain it is recommended that you delete this and then add your site/app with the domain.
To add another site you would just need to:
Point the A record of your domain to the IP address of your forge server
Fill out the form for adding a new site (in Forge)
On the next page set up forge to pull your app from your git repo.
This tutorial should give you a quick overview: https://laracasts.com/series/server-management-with-forge/episodes/13
It is part of a series should you want/need more information but please note that some of the videos are over 2 years old so some minor things might be a bit different.
Hope this helps!

How to password protect a website directory on a free default Azure app service plan?

I have a PHP/MySQL website running on an Azure free default app service plan. I have an admin directory on the site and I want to password protect it so that it's not publicly accessible. I normally work on Linux/Apache and this is pretty easy to do with .htaccess or cpanel.
This blog post here:
http://blogs.msdn.com/b/silverlining/archive/2011/11/23/packaging-a-custom-php-installation-for-windows-azure.aspx
seems like the way everyone's recommending to do it, but I'm having trouble following it. One of the main issues is that he assumes I set my app up using scaffolds but instead I created a free default app using the Azure web portal. So my directory structure at the start looks like this:
/site
/diagnostics
/wwwroot
/locks
/deployments
/LogFiles
...
What are the instructions to password protect a directory on my website using this starting point?
You can use Azure easy auth,but the whole site will be password protected:
https://azure.microsoft.com/en-us/blog/azure-websites-authentication-authorization/
You can use forms auth: http://blogs.msdn.com/b/silverlining/archive/2012/01/09/how-to-password-protect-a-php-website-directory-in-azure.aspx
Or you can use this HttpAuthenticationModule dll: https://github.com/nabehiro/HttpAuthModule#usage-for-php
You should be able to modify the web.config to restrict the path to be the /admin path.

Set url to level above installation directory Wordpress

I don't know if it is even possible so that's why I put my question here.
We have a webserver running a PHP application build within the Yii-framework and we have also integrated Wordpress into that application.
The root contains the Yii-application and a dir with the wordpress installation. Now I would like to know if it's possible to create a page and have it a url outside it's installation dir.
An example:
domain.com shows the Yii application index
domain.com/blog shows the Wordpress homepage
Now I want to create domain.com/foobar and the page foobar comes from Wordpress.
Is it possible and how?
Kind regards,
Pim
Your server will have been setup with your domain name. I don't know if you are using a hosted service, or a cloud based option, but either way you should be able to tell your web server to load different index.php files based on the URL.
Every single web request comes through your web server. You can tell your web server to load different php files depending on the http request URL.
For example, when you setup your sever with domain.com you would have had to (or in most cases its the default) tell your web server to route all domian.com requests to /public/index.php
Following this logic, if you want to load a different index.php file from a different URL, you just have to set this up in your web server. So domain.com/foobar would point to /some/directory/public/index.php
The way you do this very much depends on your server and if you have some server admin software installed e.g. cPanel.

Deploy AngularJs app an Zend Framework 2.2 app in same url

I have developed a website with PHP Zend Framework 2.2 backend (API) and an AngularJS / Bootstrap front end.
In local mode, I am using 2 apache virtual host to run this website and it works fine.
But, now, I have to deploy the website in a production like environment (OVH) and all my content must be placed under the same folder (/www).
What is the best way to do that ?
use subdomain : one for back : back.mywebsite.fr and one for front : mywebsite.fr : do you know how to do in OVH
merge my AngularJS app into zend-framework/public directory ? (I will choose this solution only if there is no other solution because it means I have to modify my code)
install the AngularJS on the root folder and add a specific routes into app.js in order to allow back end HTTP calls ? (In local mode with grunt, I am already using node proxy but I don't know how to do that with AngularJS only)
other way ?
Thanks a lot

Magento Multi Site on Amazon Cloud

I'm trying to migrate our Magento to Amazon Cloud.
Currently we have this setup:
www.xyz.com (/var/www/vhosts/xyz.com/httpdocs)
This is where Magento is setup:
www.abc.com
This is where our Wordpress is setup:
www.abc.com/store/
This is a multi store setup to use the code in xyz.com with index.php calling the Magento app.
Initially, I was thinking of using 1 EC2 instance for Magento and another EC2 instances for the Wordpress. Then I would setup 2 Elastic IPs to the 2 instances and then point abc.com and xyz.com to their EIPs accordingly.
However, I can't think of a way for the /store/ folder under abc.com to use the same source code for Magento.
Could anyone advise?
Thanks.
I'm not quite sure about your needs but I would recommend to have store.abc.com as subdomain - this way you can link xyz.com and store.abc.com to the same folder and keep abc.com to the main wordpress folder. But again need to look deeper into the setup. we just transferred one of the store to amazon AWS.
Your only option is a Proxy. Everything else (Like mod_rewrite / Alias) will do a header redirect, and expose the target address to the user.
However, Apache's proxying doesn't seem to be that complicated. The most basic example is
ProxyPass /mirror/foo/ http://backend.example.com/
Note that a proxy will of course double your traffic, because every byte requested will have to be fetched from the remote machine.
Source: Sub Directory to a different server

Categories