Laravel Forge - multiple sites on the same server - php

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!

Related

Main website and Subdomain Mobile Website (facing user directories issue)

I have main website on one domain and now I am working for m.domain.com (mobile sub-domain).
On my main website users register themselves and a directory is automatically created in website.
Now as I am working on different directory for m.domain, users register themselves and directory is created in m.domain, but it is not created in main website. So i am stuck.
I want to have common user's directories even when they login from main domain or m.domain.com
Here's image:
Do not use different directories for your domains.
You have (at least) two options:
configure your web server so that both domains (domain.com and m.domain.com) point to the same directory (e.g. virtual hosts - refer to your web server documentation)
configure URL redirects, so that any m.domain.com/page.php actually opens domain.com/page.php?mobile=1, where mobile=1 is a GET parameters.
In both cases, you have one set of PHP scripts, and the script can deliver the main/mobile content dependent on how it was called (either m.domain.com or due to a mobile GET parameter).

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.

Building a SaaS application in CodeIgniter like Shopify with custom domain alias

I am working on a SaaS application. We take Shopify / Magento Go etc as reference.
I used CodeIgniter PHP framework.
SaaS Methodology - Multiple database, single code-base
Our SaaS architecture is as follows:
when a customer signup a database is build with his name and contain his specific databases.
when a customer signup he get a sub-domain (Ex: test1.example.com)
The customer can add his own domain that points to the system defined sub-domain. (Ex: test1.example.com to www.mydomain.com )
How to achieve this functionality?
For this you have to go through few configuration options.
Configure DNS: Create sub-domain with *. (ask you host)
You have to configure apache or .htaccess to point all requests coming to your domain point to same directory.
Database Setting: Try to learn how to use multiple database in codeigniter.
That's all. Enjoy!
I think that you should look for the term: " codeigniter multi Tennant app " and as said before, managing too many database isn't a solution!
You can achive proposed SAAS application this way,
There will be 1 database for application itself, and another N number of databases for clients, each new client will have new database.
Allow signup to your clients by asking basic details + subdomain to choose like blogspot do, subdomains taken by existing clients wont be allowed to reuse
When client signup successfully, one separate DB will be created and they will landed to their dashboard. Here one DB server will be fine but should have enough space and other parameter set to handle multiple databases.
Now dahsboard onwards, user will able to see list of functionality to use along with some predefined set of content that will be shared between user and loaded from "app DB". Whatever they do add will goes to their own independent DB
Here codebase will be deployed at one code server and main domain will be mapped to that so login/singup etc will be happen here and user's identification will happen at login level.
App DB: This DB will be responsible to store app level master data, i.e. Client's profile + login details, other admin related stuff which they meant to share to their clients. In case of shopify kind of app, themes, layout, templates can be master stuff that will store into this DB.
User DB: Only user's created, added content and its sub content should be stored. Whatever we can call user's ownership should be stored here.
Note: If its paid service, then you can use good payment gateway like stripe or chargebee to manage all your plans, subscriptions, email notification, dunning, payments log, payment success/failure, payment invoices.
WRT to subdomain and custom domain concept, you can do this using virtual hosting mechanism, you can do with apache as well as nginx server.
- Subdomain: Create config files as per server, put on proper place and any created subdomain will bind to particular pysical virtual directory
- Customdomain: Can create physical directory same as subdomain along with config files but in this case, you will need to ask your client to do DNS binding with our IP addess
In both this case when request comes to our server, server will check if config file and physical directory available tp hit then it will redirect user to destiny forlder.

Run app.mydomain.com as mydomain.com/app on Heroku

I have a PHP app running on Heroku (app.herokuapp.com) and it is currently being pointed to app.mydomain.com. My question would be:
Is it possible to run app.mydomain.com at mydomain.com/app? Basically I would like the app to run in a subfolder as opposed to a subdomain.
Any help is greatly appreciated.
Thank you!
You cannot in a clean way (you could with iframes, but shouldn't go that way) point your application to a subdirectory in an other application.
That is because when not using the x.herokuapp.com domain name, you need to use custom domains. These relies on DNS entries to point to an application or an other.
And you cannot create DNS entries for a subdirectory.
What you could do though, is package one application at example.com, inside which you display whatever you want for the / url, and you load your application at the /app url.

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