PHP application to replicate websites from single code source
I'm attempting to build an app开发者_如何学Clication in PHP to help me configure new websites.
New sites will always be based on a specific "codebase", containing all necessary web files. I want my PHP script to copy those web files from one domain's webspace to another domain's webspace. When I click a button, an empty webspace is populated with files from another domain. Both domains are on the same Linux/Apache server.
As an experiment, I tried using shell and exec commands in PHP to perform actions as "root". (I know this can open major security holes, so it's not my ideal method.) But I still had similar permission issues and couldn't get that method to work either.
But I'm running into permission/ownership issues when copying across domains. Maybe a CGI script is a better idea, but I'm not sure how to approach it.
Any advice is appreciated. Or, if you know of a better resource for this type of information, please point me toward it. I'm sure this sort of "website setup" application has been built before.
Thanks!
i'm also doing something like this. Only difference is that i'm not making copies of the core files. the system has one core and only specific files are copied.
if you want to copy files then you have to take in consideration the following:
an easy (less secured way) is to use the same user for all websites
otherwise (in case you want to provide different accesses) - you must create a different owner for each website. you must set the owner/group for the copied files (this will be done by root).
for the new website setup: either main domain will run as root, and then it will be able to execute a new website creation, or if you dont want your main domain to be root, you can do the following: create a cronjob (or php script that runs in a loop under CLI), that will be executed by root. it will check some database record every 2 minutes for example, and you can add from your main domain a record with setup info for new hosted website (or just execute some script that gains root access and does it without cron).
the script that creates this can be done in php. it can be done in any language you wish, it doesn't really matter as long as it gets the correct access.
in my case i'm using the same user since they are all my websites. disadvantage is that OS won't create restrictions, my php code will (i'm losing the advantage of users/groups permissions between different websites).
notice that open_basedir can cause you some hassle, make sure you exclude correct paths (or disable it).
also, there are some minor differences between fastCGI and suPHP (i believe it won't cause you too much trouble).
精彩评论