Can't view re-uploaded php web files in my Linux server - php

I used to have a Windows OS server where i uploaded some old php web files to it. I could then access them, edit them, and view them online via my host name.
After much debating and reasoning, we had to change the OS of the server from Windows to Linux. After the change had been completed, a backup of the server was uploaded to the new Linux installation where all my old files were kept.
I could view these files online as I used to do when the server had windows OS.
The only thing I did encounter was the following:
a) I downloaded my files from the server using putty,
b) I deleted the old copy in my Linux server,
c) I then re-uploaded the same file that used to be in the server without making absolutely no change whatsoever to it, to the exact place where it was,
d) When I try to access it via its web address like I did earlier, it throws an error message saying..."The page isn't working".
I don't know much about Linux and there fore I am stuck. I don't know what the problem is. I can't understand why I can view all the files via their web address if they were placed there from the backup, but when I download them, delete their file from the server and then re-upload the exact same downloaded file to the exact place where it used to work, I get an error message.
Extra info: I connect to this Linux server from a windows OS machine using putty.

I found the problem. Since I migrated from a Windows OS server to a Linux Cent OS server, I didn't know that you had to configure the privileges of each folder in order to be accessed from the web. By default, my uploaded files where tagged by ownership of "user". The server was configured to only display files that were tagged by ownership of "root". The way I solved this was by typing the following command in the terminal.
NOTE: "You have to be in the folder where the file you are going to change ownership is."
sudo chown root:root filename.php
sudo -> Execute in admin mode
chown -> Change ownership of file to...
root:root -> ... root instead of user
filename.php -> the name of my file
Executing this corrected the error. Hope it helps someone else since I coudn't find anything related.

Related

IIS does not allow run .exe file using excec command on PHP

I have a code on PHP that was working in a server but we migrate that code to another server and now that code is not working, specifically we want to run an .exe file using PHP with the instruction exec
I debug the script and it looks be working properly and the IUSR user and IIS_IUSR have the correct permissions and actually the exe file is running, but, when it run it need generate some files that is the part that cause the issues, the program are trying to create files on the AppPool directory for example like this:
C:\MyPath\somewebsite.com\8áª\MyProgram\
Where C:\MyPath\somewebsite.com\ is the AppPool root directory and MyProgram\ is the directory that the app is creating
Where \8᪠is generated randomly and changes all the time that we try to run the program, debugging with Process Monitor I can get an error: PATH NOT FOUND and/or NAME INVALID, on the previous server we modify the user on the IIS to run the script (that was on IIS 6 now we are on IIS 8.5) and that files was created on the home directory of the user AND without the random directory, for example:
C:\Users\MyUser\MyProgram\
where MyUser is the user that we assigned, but on that new server we get the files on the AppPool directory no matter if we change the user
I think that we can solve that if we was able to define a path for the IUSR user and set it as "home" path but I cannot found where to modify the IUSR user, I know that is a build-in user that IIS create but I'm not sure if I can edit that settings for that user.
I already mention that we used IIS but just as an extra data, we are running that over Windows Server 2012 R2
Any suggestion?
You topic / question is:
IIS does not allow run .exe file using excec command on PHP
which is the correct behavior! You don't want to run .exe files through PHP, really. You have to give the IUSR execute permissions on cmd.exe first, meany you might as well give all your virtual users administrator permissions.
lot of time after but, PHP side was ok, the problem was on the .exe file, the exe file create some files that was used for the same exe program, but it uses relative paths so when the process run makes that did not found the files generated and this caused the errors

Permission usert Tomcat7 for send files to apache2 folder (httpdocs)

UPDATE 28/07/2016
Help me please.
My problem is I have a ubuntu server with the following configuration
In summary ::
my internal server (tomcat 7) .war owner user does not have permission to create, modify, ... folders, upload files (but yes, to read all this).
my module in plesk is apache (is not whether it would be better, CGI, or FAST-CGI).
I've tried everything, changed owners folders permissions for adding groups, more users, I modified mod_jk, I changed server.conf, worker.properties, tomcat.users, catalina.policy, ........
And I can not get the user and owner (tomcat7) .war, achieve create, modify, delete folders, upload files etc ...
However from the local tomcat, which makes the request when the user is www-data, you can do all.
can someone please help me with some idea?Thanks.
I finally had to switch to a windows server because of problems with plesk and ubuntu.
and voila, everything working properly

Write access not permitted in Windows 7 for CakePHP app

I primarily use Mac OSX for programming and then test it in windows periodically. I just installed XAMPP on a Windows 7 computer and I'm getting the following errors
Warning: _cake_core_cache was unable to write 'cake_dev_en-us' to File cache in C:\Program Files\xampp\htdocs\testproj\lib\Cake\Cache\Cache.php
Warning: C:\Program Files\xampp\htdocs\testproj\lib\Cake\Cache\persistent is not writable in C:\Program Files\xampp\htdocs\testproj\lib\Cake\Cache\Engine\FileEngine.php
I opened up the testproj folder properties and unchecked Read Only and applied it to all folders/subfolders. I tried to open the Cake application again and the same error message was displaying so I checked the folder properties again and it had a square in the Read-Only box, not a check mark. Does that signify anything? I'm not sure what exactly the square means instead of a check mark.
I am signed into the administrator account on this computer. Is there some kind of command similar to chmod -R 777 for windows?
Thanks
Update - I changed the installation from Program Files to C:\xampp... and I still get the errors. I then created a partition and installed xampp to G:\xampp... and the error still exists
Using C:\ and especially the Program Files folder is a really bad idea for developing with PHP on Windows. Use another partition or at least a folder outside of system internal folders.
There is a reason WAMP and most tools by default try to install themselves in C:\wamp\ etc.
Edit: also try to avoid folder names with spaces in them like the windows-stupid "Program Files" default folder. And mind your casing, even if that is not directly visible in Windows, it will otherwise kill your app when going live with it on a unix server.

PHP can't move (write) uploaded files to mounted network drive

We develop our PHP-based web applications by editing our working files in a shared, local directory on each of our windows machines. The (linux) staging server then mounts our shared drives and serves them each under subdomains. E.g. joe.work.com would serve Joe's working directory. We then access our own staging sites by editing our hosts file to point the subdomain to the staging server...and all of that works great!
We're now running into the issue that PHP doesn't seem to have permission to move uploaded files from the tmp directory to a directory inside of the mounted directory (which is actually the shared windows drive...?).
The working directory on the windows machines are set to allow everyone rw, and I have tried putting 777 on the mounted directory in the staging machine, but I am still get permission denied.
The shared drive, say, \\joes_machine\joes_working_dir mounts on the staging server to /var/mnt/joe. The file upload needs to be moved to /images/common.
Albeit slightly dumbed down for this example, I'm not doing anything fancy code-wise:
$working_directory = '/var/mnt/joe';
$image_directory = '/images/common/';
$full_filename = $working_directory . $image_directory . $filename;
if(move_uploaded_file($_FILES['photo']['tmp_name'], $full_filename))
// do some other stuff
My error of course is:
Message: move_uploaded_file(/var/mnt/joe/images/common/resulting_filename.jpg):
failed to open stream: Permission denied
Message: move_uploaded_file(): Unable to move '/tmp/phpjsEfBc' to
'/var/mnt/joe/images/common/resulting_filename.jpg'
What am I not understanding about file permissions pertaining to a windows shared drive being mounted over the network by linux and PHP needing to write to it? I can't seem to find the hang up!
Once we hit production, we won't be using the schema, but if there's a simple solution to be able to continue in our current development environment, then that would be ideal!
After a few hours of facerolling, I finally found what I was missing. The issue was that the credentials supplied couldn't write to the mounted directory as expected. The way I was able to fix this was by editing the mount command as follows:
mount -t cifs //shared/directory /mount/target
-o rw,username=connectionuser,password=password,uid=48
so, username and password are to be the windows credentials used to connect to the drive, but uid specifies the unique identifier of the local user on the staging server that apache runs as so that it may write to the mounted directory.
previously, i had not specified the uid of the local user, so when apache was trying to write to the mounted directory, it was trying to use the windows credentials (that couldn't write on the 'local' drive)
hope this is helpful!

How to set read/write permissions in Apache on a Windows computer

I am building a web page with Apache2.2, PHP5.2.2 on a Windows XP computer in a localhost configuration. I'm developing app/pages/submitProcessor.php to validate photo uploads from users. It validates file existance, size, mime type, drops unwanted characters, assigns a new file name, and uses move_uploaded_file() to store the file in app/uploads. I read in PHP - Question about uploading & uploaded image file that this photo storage file should be write only from app/pages/submitProcessor.php and it would be nice if it were read only from code within app/pages.
I've read a lot of info, and being pretty new to this, I still don't understand how to set read/write permissions in Windows XP in something resembling my configuration. I'm completely confused by 777, 775, 755, php.ini vs httpd.config and linux vs Windows. I'm also not comfortable with command line stuff, and would prefer to edit the appropriate file, if that is possible. How do I configure Apache so any file in app/uploads will not be executable, will write only from app/pages/submitProcessor.php, and read from app/pages/display or others in app/pages . . . or at least I'd like to get close to that. Not executable in the app/upload directory is pretty important to me.
If you are running Apache as a Service (the default setup for stand-alone & WAMP Apache installations), then that Apache Service is running under Windows' LocalSystem account.
This Windows account already has full read and write ('777') permissions on most local paths.
So when you read instructions to chmod 777 this, chmod 755 that, etc, ... you can ignore those parts of the instructions. Apache already can read-from and writeout-to those directories (unless it's a UNC path of a networked drive).
Setting File Permissions with chmod on Windows for Apache and PHP
I'm not 100% positive if that was the account on Windows XP (it is on Vista and up), but the behavior was the same.
In Windows, access to directories/folders is set by right clicking the directory, and reading through the selections provided by the various tabs to set access and specific uses of the directory. Its not as fine-grained as CHMOD, but it was good enough for my purposes at the moment.

Categories