musichax0r
Programmer
Hi all,
I've written a php script/web page form which finds certain files and modifies them according to the user's choices. I currently have two different versions: One that can be executed through a web page form and one that can be run from the command line. My problem is one of user rights. Normally, it is not possible to make changes to files on the web server through a web page because the apache user doesn't have write permissions on any files. So, how can you get around this? Here are the ways that the script can be executed the way I understand it. One additional way not listed below is using the php POSIX functions to execute the script as a particluar user, but I am sure that most people's hosting companies don't allow this these functions. PLEASE correct me if I am wrong or if there is another or better way.
POSSIBILITIES:
1) Web Based Locally
Requirements:
a) Apache/mySQL/PHP installed on your local machine. Basically this must be a repication of your production web server environment.
b) Read/Write/Execute Access on all files.
- The apache user which is assigned to run all http connections must have full access rights to all files OR you must change the permissions to be 777 on all files.
- If you have created a user with full access rights, then you can upload your installation to production without having to modify any permissions. If not, and you changed permissions, you must change the permissions back to an acceptable production state.
2) Web Based Remote
Requirements:
a) Production web server environment (Apache/mySQL/PHP etc...)
b) Read/Write/Execute Access on all files.
- It is not possible to allow the apache user to have full access rights on a production server, so you must change the permissions to be 777 on all files
- This is acceptable ONLY on a test installation. Never "chmod 777" your production installation. You can perform the installation on a test site, and change the permissions back to an acceptable production state and THEN move it into production.
3) Shell Based Locally
Requirements:
a) A web server installed locally is NOT needed, however, mySQL and PHP are required.
b) The user running the script must have full access to all files. (NO need to chmod 777.)
NOTE: The user in this case is any user logged into Linux/Windows which has the appropriate access rights.
4) Shell Based Remote
Requirements:
a) Production web server environment (Apache/mySQL/PHP etc...)
b) The user running the script must have full access to all files. (NO need to chmod 777.)
NOTE: This user is significantly different than the user referred to in the "Web Based" version. The shell user is the user you were assigned by your hosting company and NOT the apache user which has been assigned to http connnections. Basically, this is the Linux/Windows user.
I've written a php script/web page form which finds certain files and modifies them according to the user's choices. I currently have two different versions: One that can be executed through a web page form and one that can be run from the command line. My problem is one of user rights. Normally, it is not possible to make changes to files on the web server through a web page because the apache user doesn't have write permissions on any files. So, how can you get around this? Here are the ways that the script can be executed the way I understand it. One additional way not listed below is using the php POSIX functions to execute the script as a particluar user, but I am sure that most people's hosting companies don't allow this these functions. PLEASE correct me if I am wrong or if there is another or better way.
POSSIBILITIES:
1) Web Based Locally
Requirements:
a) Apache/mySQL/PHP installed on your local machine. Basically this must be a repication of your production web server environment.
b) Read/Write/Execute Access on all files.
- The apache user which is assigned to run all http connections must have full access rights to all files OR you must change the permissions to be 777 on all files.
- If you have created a user with full access rights, then you can upload your installation to production without having to modify any permissions. If not, and you changed permissions, you must change the permissions back to an acceptable production state.
2) Web Based Remote
Requirements:
a) Production web server environment (Apache/mySQL/PHP etc...)
b) Read/Write/Execute Access on all files.
- It is not possible to allow the apache user to have full access rights on a production server, so you must change the permissions to be 777 on all files
- This is acceptable ONLY on a test installation. Never "chmod 777" your production installation. You can perform the installation on a test site, and change the permissions back to an acceptable production state and THEN move it into production.
3) Shell Based Locally
Requirements:
a) A web server installed locally is NOT needed, however, mySQL and PHP are required.
b) The user running the script must have full access to all files. (NO need to chmod 777.)
NOTE: The user in this case is any user logged into Linux/Windows which has the appropriate access rights.
4) Shell Based Remote
Requirements:
a) Production web server environment (Apache/mySQL/PHP etc...)
b) The user running the script must have full access to all files. (NO need to chmod 777.)
NOTE: This user is significantly different than the user referred to in the "Web Based" version. The shell user is the user you were assigned by your hosting company and NOT the apache user which has been assigned to http connnections. Basically, this is the Linux/Windows user.