Limit resources to tenant in apache multi tenant configuration - php

I'm going to deploy a multi tenant cloud service based on LAMP stack.
Each user has his own third domain .myservice.com, thus its own virtual host in Apache.
I'm wondering if it is possible and how I could limit resources any single virtual host can absorbe, so that even in case of high load from an user, it's not allowed to slow down too much the whole machine.
It's not really a multi tenant software at the moment, as each customer has a separate database and currentlu I use separate web folders containing the same project file.
This is not the best solution, but it's not the subject of this question and probably in the next future I'm going to use a single web folder for ann the users, with separate databases.
I'm using the standard apache-php configuration so that all is running under www-data user.
I'd really appreciate any kind of help.
Thank you,
Michele

Have a look at techcello.com. They have built a SaaS framework in .NET covering all of your requirements from tenant on-boarding, subscription, billing, trial management, notifications, data backup and much more which can be used to kick-start any SaaS product.
As per you requirement you have complete control of your data since they just provide you the binaries and you need to host it yourself.

Related

How to handle infrastructure for the website in PHP which will be used many times?

I have a few PHP Laravel projects (restful API, admin app, client app). There is only one database which is used by API. The project is some kind of app which can be used by some companies. They have access to admin panel, client web page, they can use own API, they can make own users, permissions and so on. There is no problem if this project will be used by one client, but I'm going to sell this app to many people. I will be responsible for updates, hosting, configurations etc. I wonder how to make it the best way and I have a few ideas.
I thought about cloning the app on the server each time someone buys it from me. This requires setting up a new subdomain on the server and a lot of disk space. Not sure about it.
Or maybe cloning the app and sharing some files with symlinks like vendor, node_modules etc.
Another idea is to make it as a one project with many databases for different clients, but how to make it in Laravel in the best way? I will need some dynamic way to change the database connections (I want each client to have separate database), I'm not sure about conflicts with sessions, cache etc.
Maybe separate databases is a wrong idea, and it's better to have one database and make it as a one project and sell the access to project? But then I need to keep data of my client in one database.
What do you think?
Create this application as SaaS (software as a service). You can give them some default templates of front end or even client app (website and admin part), but keep all backend at your servers. Make REST endpoints, authenticate clients and give them functionality that they bought.
For example:
Client A bought calculator services from you. It authenticates, and makes GET call to /api/calculate/subtract/5/1. You give them response what your calculator does, for example 5-1 = 4. They can use your prepared templates for this data preview or create their own.
Client B bought calculator and storage services from you. You calculate same value, give it back, but also store it in your own database. So client B also can make call GET /api/storage/last_calculation and you give them 4, because client data stored in your database, he bought storage service too so he do not need to setup database for himself.
It is very simple example, but you should get the point.
For example simple scheme with separate database for each client:

Hosting WP app on server which already has Symfony2 app

I wrote an app for my customer in Symfony2 and we went public with that. However, I am learning right now that he had a separate Wordpress app within previous server to manage some separate product.
Now, he asks that we transfer that WP app on a new server. Being all security in mind, I cannot feel but nervous about potential impact here. I am to have the following URL setup:
www.myclientapp.com
www.myclientapp.com/some-wp
What are my options here? I can think of some, but any suggestion would be helpful.
Buy separate shared hosting and put WP there. Then do redirection from our website.
My VPS server runs with nginx and php-fpm. Can I utilize separate pools which would run under different user. I would need to review access privileges to Symfony's files.
In any case I would allocate separate mysql user and database. Those wold be enforced by strict privileges which prohibit access to my primary database.
Can you guys think of anything else?
My primary goal is: If WP is vulnerable, let it be. Under no circumstances I would allow it to compromise my Symfony2 app. I am primarily concerned about configuration files (app/config/*.yml) which contain sensitive data.
I will recommend that you use something like a sub-domain eg wp.symfony.com.
They may still be hosted on the same server, but using different virtual host directories.
With that, the apps will never see each other.
A way is running symfony under a different php-fpm user than the WP website and make sure the file/directory rights are set correctly. Then a WP exploit cannot write/read to the symfony files depending on the directory/file rights.
A better way is to use the php config open_basedir and isolate the two sites into their own "jails" this way PHP prevents including/reading files from other websites. See http://php.net/manual/en/ini.core.php#ini.open-basedir for more information.
For this to work the code should be separated into different directories, you can use nginx aliases or virtualhosts to point the domainname to the correct directory.

Design flow for Point Of Sale software for multiple location

I want to design POS application in php,mysql for multiple store location which are internally connected with each other. Sub Admin (each store manager) can manage store with new order placing, taking care of customers and tracking inventory.
Super Admin can watch each store activities in details like each store's sale, staff details, inventory etc.
What would be the best design flow for this? Cloud is best solution in my view but what would happen when there is no internet connection or slow connection. Is it possible to run desktop version on each PC which can interact with main server time to time. I am little confused here. This is big project so security is also other concern.
So in short want to design an application which can run stand alone and also can run with cloud.
Your help will be much appreciated..Thanks
If they're all interconnected anyway, can't you host the software on a web server on their network? It would still be behind their firewall and if you're feeling paranoid, you could keep a copy on an in-store server at each location that syncs with the network one. This would keep everything private and still provide a fail-safe, and you don't have to worry about setting up PHP on each terminal or packaging your interface as an app. The only hoop to jump through would be getting permission to set up a network server that runs PHP, but it shouldn't be too big of a deal.

How to deploy and configure many copies of an application to multiple domains on the same server

We are about to begin work on an application that will eventually be deployed many times on one server. I am hoping to build a nice interface so that one of my coworkers can easily create new deployments of this application. The idea is to create a wizard with a series of options that will configure basic properties of each particular copy of the app such as color scheme, domain name, etc. Each copy of the application may be further tweaked independently down the line. I would like to know what is the best way to manage the automatic creation of users, the updating of domain name info and the deploying of copies of an application, with the ability to maintain certain discrepancies between each of these copies (such as installed plugins, different CSS) as we update the application in the future.
What I'm asking is extremely similar to the way StackExchange 1.0 functioned, where a user could configure several options and a customized version of the StackExchange would soon be up and running. How is this accomplished?
One thing you can do is have the web server set a variable based on the domain name and path, and then you can check $_SERVER for the value and choose the configuration based on that. Or if the application will only be run once per domain then just check $_SERVER['HTTP_HOST'].

Enable ERP application to support multiple clients

The company has an ERP application that supports only once company using one database, how to make the application support multiple companies and multiple databases using the same code?
The application is a PHP and the database is MySQL.
Thanks.
It totally depends on the architecture of your application and your DB structure, if the refactor is too hard maybe the solution would be to have multiple instances of the ERP. Also as it is an ERP (with sensitive information of a company) you might have to install the instances in different servers, to ensure your clients won't be storing financial information with other companies in the same machine.
You can have one 'big' server virtualized. I'd suggest you to have a reverse proxy to redirect the requests from multiple subdomains to your virtualized guests. Also you can have a template of a virtualized server with Apache, PHP and your ERP installed ready to be installed in the virtualization host. When a client buy your product you just install and turn on that virtual guest and provide the client access.
You could re-install it on a second server. If you have a license to do that of course. What ERP application is it?
Edit:
For our ERP product, I use a segment of the url to distinguish the database. e.g.
http://myserver.com/company1/customers
versus
http://myserver.com/company2/customers
All urls that are embedded in documents are relative urls so they stay within the same company.

Categories