I want to archive this username.mydomain.com for each new user register with application and each user has its own database.
Its actually inventory application developed in codeigniter, so user registration will be only done by admin.
One application installation for all sub domain(usersname) should points to same server directory, later application will select database according to subdomain so how can i archive this.
In order to achieve what you want, is to follow the following steps:
DNS Configuration
Apache Configuration
Testing out your server configuration
Setting up CodeIgniter
Creating controllers & Views
Extending created controllers
All of the steps are nicely detailed in Atchyut Sekhar's article on tutsplus.com # https://code.tutsplus.com/tutorials/basecamp-style-subdomains-with-codeigniter--net-16330
Hope that helps!
Best,
-Rush
Related
I am creating a cloud based application in laravel/php.
I have a functionality where user can have their website at user.myapp.com and it works (with subdomain and model binding).
I now want to go one step further, and allow users to add their own custom domain names. So their website will be reachable at user-domain.com rather than (or as well as) user.myapp.com.
I want to understand how to do this. I'm using Laravel framework which is based on php and apache.
What kind of server do I need? Can I use shared hosting?
What configs do I need to do in order for this to work?
What DNS record the user must create to put things together?
You can do this with any kind of server. You can make a route that is caught by any domain and in the controller of this route, you can query the database to know what website should be displayed for that domain.
You can get the domain name of the current request using app('request')->root();
I want to build Laravel CMS with following requirements:
Admin (manage all sites/database).
Multi-sites (running on sub-domains, manage own database) each with API access.
Same Codebase (can be replicated if needed).
Same Database with different data for each site.
Can you please let me know how to setup this environment using Laravel 5.4.
Thanks.
This project has been finished now. So posting my own solution for the question.
Following are points to take care:
I've used Laravel 5.4 (later upgraded to 5.5).
For multi tenancy used Landlord extension for Laravel.
Server is configured to listen for wild-card sub-domains.
Each site is running on sub-domain.
Using single database with site-id (tenant-id) under each DB table.
Whenever server gets request, sub-domain is matched with tenant id in the middleware & load all the records for that tenant only.
I've hope this might help someone else.
For build a Laravel CMS with following requirements you need use:
You can set an Admin Role with policies and gates or uses entrust
For Multi-sites, You can used something like https://github.com/hyn/multi-tenant, so If you use multitenant you can
Multi-sites (running on sub-domains, manage own database) each with
API access. Same Codebase (can be replicated if needed). Same
Database with different data for each site.
For config subdomain you can read the official documentation https://laravel.com/docs/5.4/routing#route-group-sub-domain-routing
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!
I'm designing a small web service which does make use of user profiles.
Now, I want the specific user profiles to be available under domain.tld/u/USERID (/u/USER_ID/index.php to be specific)
The naiive way to do this would be to make a directory for each user. However, there has to be another solution as many grand scale sites use a similar structure.
Instead: I want to use one index.php, I actually update with the user information of the requested profile.
I've only started working on web hosting / php with this project.
I'm assuming this is a problem I need to address using the web server config? I'm running apache2 currently.
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.