Im running a Drupal Multisite environment on a lamp (debian, apache, php, mysql) server.
My current workflow for a new project is:
Activate a subdomain on my company site (let's say the project will be foo.com, i activate foo.example.com)
Becose of plesk (that's a bit drupal unfriendly) my step are:
Create the new subdomain in plesk, php running in fastcgi mode
Create the database
Delete httpdocs folder, recreate it and make the sites folder
Make a simbolic link to every file into /var/www/vhosts/drupal folder (drupal code base) excapt of sites and tmp folders, robots.txt and .htacces files (that usually will be customized per domain)
Make the folder foo.example.com inside sites, symbolic link to /var/www/vhosts/drupal/sites/all folder, and then back a symbolic link from sites/foo.com to /var/www/vhosts/drupal/sites/foo.example.com (in order to make drush see all the domains to some multisite tasks, like crontab)
Install, configure drupal in the subdomain, doing everythings needed to complete the project
At this point, i need to switch the project from the subdomain to the final domain, foo.com, that will reside o my server too.
I dont like much some kind of other hacks like domain redirects, i want the final project to be a 'clean' (for what clean mean in a multisite environment).
Actually i do those steps:
Creating the domain (via plesk) and database;
Copy the subdomain httpdocs to the full domain httpdocs (cp -a /var/www/vhosts/example.com/subdomains/foo/httpdocs /var/www/vhosts/foo.com/httpdocs)
Change owner and group of httpdocs to match the domain's owner and group
Login into drupal, change webiste info, and filesystem paths.
This let me do what i want, but i have some trouble with node's html contents; espacially for those that contain links, images, and files, that (even if IMCE is configurated to use relative path), will point to /sites/foo.example.com/files/[...] instead of /sites/foo.com/files/[...].. this happen for cck filefields too.
As i said, i need a clean solution, i know i could make a symbolic link from /sites/foo.example.com to /sites/foo.com but i really dont like this way.
So far, i tryed to search/replace all the occourrence into the database sql dump:
sed 's/foo.example.com/foo.com/g' dump.sql > foo.com.sql
But this seem to brake somethings; I get many errors in boostrap file (in the cache unserialize step, even if i cleared all the cache before and after the db export/import) and looks like some utf-8 encoding get broken.
I know the best deal will be to set the development area on a local server, but i need my customer to reach it from outside.. and our adsl situation (static IP and so on) is a bit wired.
Any idea?
p.s: sorry for my bad english, if my question is not clear enought let me know and i'll provide more details)
Your steps are basically what I do, but I am not using Plesk or doing a multisite installation. I just create a new vhost in a VPS instance, and cp -a the docroot, and reconfigure for a new database DSN.
Regarding the SQL problems, I typically edit the SQL dump in a UTF-8 clean editor to prevent that problem. On Windows, I use Notepad++.
I then restore the database, clean all caches, edit settings, and run cron. I will also typically rebuild the search index.
This sequence normally works.
The bootstrap problem likely has to do with the variables table. When you serialize a string (or something with an string), the length gets stored, too. I will do the search and replace, then open up MySQL Query Browser, and search for rows in variable table with the domain name, and fix the lengths by hand. The other option is to determine which option is being stored, and then recreate the setting.
Related
I followed this tutorial and it describes how to connect to a database using an Android app.
I need to create a folder structure similar to the one below:
My Question is where in a real server should the proposed files be placed?
I have a path of Home Directory/My Domain/....(folders)... so do I place that structure inside or outside My Domain folder.., and if outside how I am going to access them if I use the following?
require_once 'OUTSIDEFOLDER/include/Config.php';
Shouldn't I be blocked by permissions?
My Question is where in a real server should place the proposed files?
You must place your file.php in the www folder.
For example, if you have a WAMP server installed, you must place all your files (e.g. file.php, etc) in a path like c:\{wampPathInstalled}\www\mywebsite, where {wampPathInstalled} is the path where WAMP is installed on the C drive (or if it is another drive, use that drive letter instead).
You can access the scripts by running http://localhost/mywebsite/myfile.php in a browser.
Tell me what is your real server (IIS or other) & I can indicate where the best place is in your case.
if you use plesk, your response must be in this link.
Well ideally for productions websites I would create a directory for every site hosted and place at a location that will require sudo privileges for modifying, reading or deleting files. Therefore the directory could be inside /var/www or you could create one inside /var/data. I would always place all the configuration information for a site in a separate config file, this file will then be included in only files that requires that information. Furthermore implement your application using MVC approach where the application is served through one common router and also provide appropriate permissions to directories based on things they are doing avoid unnecessary read, write, execute permissions everywhere to your app. Hope this helps
My WordPress files are downloading instead of executing on the server. I have tried changing the server but that does not solve the issue. I am sure it is happening from my WordPress files as the hosting runs other WordPress files smoothly.
I wish I could could provide the code but that isn't needed. Please guide me. Thanks.
I have only seen this happen when:
1) PHP is turned off or not installed on the server
2) The server needs to be reset
3) File names are not correct
4) The redirect script is not redirecting as it should
5) Links are not valid
The good news is most of these can be solved by you/your host. Call your host to ask them for help on verifying the PHP install/process. If everything is good (for instance, if you have another site on the same server that is working fine) then you need to verify file names. As this is WordPress and the file names are all pretty standard this isn't exactly likely but make sure there are no unwanted spaces and the file names are "something.php". With WordPress you may see a bunch of parameters passed through the URL so "something.php?blah=blah" Is fine too (no space between php and ?).
Check the link you are clicking. The file names might be good but the link may be bad. It might be as simple as fixing all the link URLs. From what I recall of WordPress, there is a built in method of linking to pages within the same WP site. I believe these are all based off the URL in the database so you may want to verify the URL in the database/config file to verify WP is sending them to the correct place. If they are not stored in the database and are instead, coded directly into the content, you may have to manually update every link to the correct URL.
Finally, if it is script or wordpress related you may want to consider a fresh WordPress install. The good thing about WordPress is all the good stuff is in the data base:
1) Make a backup of the data base
2) Trash your WP install completely
3) download and install new WP with desired plugins and themes
4) Restore database
If the last step breaks the server again, check URLs within the database: http://codex.wordpress.org/Changing_The_Site_URL
Your Host can usually help in backing up and restoring WP databases. Even godaddy (who does not support it) will often help you walk through the process (you really want to call the hosting team. As an ex-godaddy employee, those guys are the experts).
If this isn't enough information, please provide a link to the site. It will allow me to do some quick troubleshooting to determine the overall issue.
EDIT: Help for verifying php install
Create a php file with the following contents:
<?php phpinfo(); ?>
And upload it to your site
This will make information about your PHP install easily accessible
Note: DO NOT LEAVE THIS FILE UP PERMANENTLY AND DO NOT POST A LINK PUBLICLY, YOU DO NOT WANT RANDOM PEOPLE ON THE INTERNET ACCESSING THIS INFORMATION
If you can access the file and it loads up a bunch of information in a purple (I believe it is purple) table, your PHP install is up and running. If the file just downloads like the rest, contact your hosting provider.
I have a website which has a lot of confidential data and code which I have custom made. I have hired a developer to do the designing and some simple PHP integration for me.
To prevent him from seeing all files, I made a test environment in one of subfolders like mywebsite.com/testfolder
Now I want him to access the db_test.php, function.php and parameter.php files which are located in the root folder such that he can just include them while executing the scripts (example mywebsite.com/testfolder/mainfile.php) and not download them (with php script or by any other means). The idea is to prevent him to see the code and just use the stuff as it is.
This would also mean that his access to the root folder should be also completely restricted except for the above mentioned files.
I have created a test database and a separate user for him so the database bit is secured.
I have also created a ftp user which can just access the testfolder through ftp
What I am concerned about is that he might run a php script that will give all secrets in the root folder.
I have myself been able to list and download files by running a simple php script from testfolder.
Please suggest how to make this work as I am planning to have a virtual team who will work on the website which will have restricted access to various different resources.
RULE NUMBER ONE: never develop on a live project.
you may create a development environment (=web site) somewhere else, put some meaningless files and/or databases there and allow your developers full access. then, from time to time, you update your working copy from the repository (you have setup hg/git repo, haven't you), review and test the changes and only then upload files to your main web site.
I'm attempting to build an application 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).
starting new project where users can register and system will automatically install cms system for users registered domain and need to solve dynamic setting of the server (apache).
Registration information and info about the associations between domains and actual paths to the cms installation on the server will be stored in Mysql database.
Is there an easy way to configure apache to connect for all unknown domains to a specific php script, which will look into the database and provide the actual path to the relevant cms - apache will than use this info to correctly handle the request?
I think, that "easier" solution might be to use PHP to write the domains/paths/config to a file and force apache to use this file to handle requests - however as I expect, that the number of the domains might be higher and case that some domain will be deleted will not be rare - the file might become full of unwanted rules soon and hard to optimize, also apache restart would be needed in order to use changed file etc..therefore the question about dynamic solution - that might be much easier to manage (for me and for the admin system itself).
Yes - use a wildcard vhost in apache, and mod_rewrite to direct all URLs to your front controller (or use the 404 document handler).
C.