It seems that gallery2 is heavily dependent on the username on the server, with this being hard-written into the code on setup.
This means that if the user is changed, that we then have to search through multitudes of files to find all instances.
Surely the file path could be found using PHP so that the script can run independently of specific usernames.
Even if the script does require a specific name, surely it can be put into a config file so that there is just one instance that needs amending. The username could be placed into a PHP constant for use throughout the software.
Posts: 16504
I am making an assumption here that you're talking about g2data and ownership of files on the file system, see my comments below. Of course if you're not talking about file ownership of g2data, please clarify what you're asking about.
In short, this may help:
http://codex.gallery2.org/Downloads:Cleanup_Script
Possibly, contacting your host to have them change ownership, or searching google on how to use tools like chmod or chown and how to use one or both of those recursively.
No and no. No it's not dependent on the username of the server in any way, well other than the user the server runs as, is the owner of the files, there is no getting around this at all, well I guess there is, run FAT32..... No, it's not "hard-written" anywhere in the code at any time, ever.
Huh?
Nope, not possible for any PHP script ever written (or perl or python or c or <insert name of programming language here>. If the webserver is running as the user "nobody" then any process it runs or executes runs as that user without some custom setups. Well it's possible, if the user the server or script is running as, has permission to change ownership, but usually that's not the case and certainly shouldn't be the case for any user of a shared server.
How? PHP by default runs as the user the web server is ran as. Every host is setup completely differently for this. Some run Apache as "nobody", others as "99", others as "www-data", others run a chrooted-jailed type environment where Apache runs as your user account. Then there is php-cgiwrap setups where php can be run as a cgi and as your user account, but Apache runs as a different user. Then there are suexec environments where cgi and ssi stuff is run as your user account instead of the default user your host has Apache running as.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 7
The username is written into the code on setup. When I migrated the website to a different user I then had to do a search to find all the places within the code that the username had been written into the path.
It was in main.php, config.php, index.php, and a few other files as well. File paths were specifically coded as "home/oldusername/domain.com/gallery-user/filename.php".
In my.domain.com/someone/index.php the code was:
define('GALLERY_CONFIG_DIR', dirname(__FILE__));
require('/home/old-user-name/my.domain.com/index.php');
So the path *was* hard-written into the code.
The error I was getting was:
Warning: require(/home/old-user-name/my.domain.com/index.php) [function.require]: failed to open stream: Permission denied in /home/new-user-name/my.domain.com/someone/index.php on line 3
Fatal error: require() [function.require]: Failed opening required '/home/old-user-name/my.domain.com/index.php' (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/new-user-name/my.domain.com/someone/index.php on line 3
I have no idea why you are talking about username 'nobody'. I always get to define my own user names that the website will be housed in. Of course, for the majority of people this may not be the case, because they are using CPanel. I am hosted on Dreamhost, so I can choose my own user names.
When gallery is installed, it would be better to have a query, perhaps in the config file, e.g. define( 'PATH_BASE', dir(__FILE__) ); Then for all references that require a path, use PATH_BASE . "relative/path";
Wordpress uses the following code in their config file:
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
Easy-peasy - then I can migrate my website without everything breaking.
Posts: 16504
O0000000000000H, well you never said what you were trying to do. Editing config.php should be all you need to do. Make sure you followed these instructions:
FAQ: How can I move my gallery installation from one server to another?
There's like 1 or 2 things to edit. G3 makes it even easier, there's nothing that needs to be edited.
There is a reason we have the text you deleted inserted into new posts asking for information...
FAQ: What information is required when I ask for help in the forums?
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 7
Wasn't migrating in the sense meant by that article. The website is still on the same server. All I did was change it to a different username.
Question: What do I need to do if I change the username a Wordpress website is installed on?
Answer: nothing at all. The website continues to function as though nothing had happened.
Wordpress uses dirname(__FILE__) to find the path, no matter where the website is.
Actually, there are 6 files altogether:
config.php
embed.php
index.php
main.php
/lib/support/index.php
/upgrade/index.php
Whatever...
I wasn't asking for help. I only wrote this for feedback to the people who maintain the code.
Posts: 16504
Actually, there is only one file you need to change, config.php
G2 is no long in development, so these changes are not going to happen.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 1642
Gallery DOES NOT care what the server username is and besides, I can not find one single place where the server path, username included or not, is hard coded anywhere on my G2.3.1 installation (apart from path to g2data). As you have failed to provide the necessary information about your installation, it is not clear whether you are using a current version or an outdated one.
My index.php does not contain any "require('/server/path/index.php');" ... Why would index.php require itself?
Sorry, but there is nothing wrong with the way the application has been configured in this instance and there are no changes required.
--
dakanji.com
Posts: 7
Gallery 2.3.1
For each sub-installation for different gallery-users
www.domain.com/gallery-userID/config.php
define('GALLERY_CONFIG_DIR', dirname(__FILE__));
require('/home/username/website/config.php');
www.domain.com/gallery-userID/embed.php
define('GALLERY_CONFIG_DIR', dirname(__FILE__));
require('/home/username/website/embed.php');
www.domain.com/gallery-userID/index.php
define('GALLERY_CONFIG_DIR', dirname(__FILE__));
require('/home/username/website/index.php');
www.domain.com/gallery-userID/main.php
define('GALLERY_CONFIG_DIR', dirname(__FILE__));
require('/home/username/website/main.php');
www.domain.com/gallery-userID/lib/support/index.php
define('GALLERY_CONFIG_DIR', dirname(__FILE__));
require('/home/username/website/lib/support/index.php');
www.domain.com/gallery-userID/upgrade/index.php
define('GALLERY_CONFIG_DIR', dirname(__FILE__));
require('/home/username/website/upgrade/index.php');
6 files all with the path hard-coded.
4 users to change - 24 files altogether.
Posts: 7
Anyhow, since you are no longer maintaining the code, I guess it doesn't matter. Unless, Gallery3 installs new gallery-user areas in the same way ...
Posts: 1642
Nothing needs changing here as you are talking about a multisite installation where the individual sub installations can be located anywhere on the server and need to know the server path to the main installation.
As for the G2 code, I am sure glaring errors will get fixed (ultimately) if pointed out. This, however, does not count as any sort of error and is just an unavoidable consequence of:
Why don't you set up your websites so that they are served out of a location that does not include the username in the server path if you want to go about changing the server username after installing things? There is nothing stopping you from setting up your server to use any other server path you want, "/var/html/sites/domain?" if you often get the urge to go changing the server username.
As an exercise for you, try installing a similar multisite configuration (one main code base with sub installations sharing this) in WP or any other application, change a component of the server path to the main installation (in your case, username will always do) and see what happens.
I know I shouldn't have responded to this but we all have our weaknesses.
--
dakanji.com