Red Hat 9 server can't write PHP script, problem in httpd.conf file?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yes, I have tried changing my Servername to my IP address, but that doesn't work. I also have the </VirtualHost> at the end of my http yes. Forgot to mention that, sorry.
But now I have discovered I did something very wrong! You've asked earlier in this thread what the content of my resolv.conf was. I said this was the IP address: 212.52.1.10, but I've discovered that's my DNS! I had it all the time!
So, here is the correct information:
my IP address: 10.21.100.152
my DNS: 212.52.1.10
So, do I have to change my resolv.conf like this?:
**********************************
*search localdomain* (delete this right?)
127.0.0.1
10.21.100.152
*blank line*
(where do I have to put my DNS?)
**********************************
And where in the http.conf file do I have to fill in my DNS address? In the ServerName of NameVirtualHost?
Oh yes, I think that the 10.21.11.152 is inrelevant for me, because I don't need a connection with internet, because the server is for the local network here in the company (intranet).
It's important to have the word "nameserver" at the beginning right before the IP address. And yes, you want to try deleting the "localdomain" line. Of course, my suggestion was to simply comment this line by putting a # symbol at the beginning of the line until you're sure you don't need it.
You don't actually define the DNS anywhere in the httpd.conf file. It looks at resolv.conf automatically when it needs to lookup a name in DNS and convert it to an IP address.
By the way... I was looking back at your first post, and I noticed something odd. You said that everything was working fine in internet explorer except for one PHP script. Is this still true? Are you able to browse sites in your browser that are being served from apache?
Also, you said...
Quote:
(it writes the PHP file locally on the server but not when you view it with an connection from outside)
So it's not entirely for your LAN... it will also need outside access for this PHP script, right? Just making sure I understand everything correctly.
Yes indeed. That's why I made this thread in the first place, because of that PHP write problem.
I can still browse through my hosted files on internet explorer on any computer here in the company, except it doesn't write that specific PHP file. It does, however, write the PHP locally on my Linux server.
I have changed the resolv.conf like you said, but still... when I restart httpd I still get the same error (*Failed to resolve server name to 10.21.100.152 (Check DNS) or specify an explicite server name*).
Sounds like the user you are running PHP as on your system has write privileges to the relevant directory, but everybody else (i. e. ppl surfing the site from "outside") do not.
Let me explain like this how I fixed such a problem on my Apache installation:
I had a directory called /htdocs/php/pgsi/company
inside of which I wanted PHP to copy / delete files. It absolutely refused to work until I did (as root):
which gives all users the permission to write in that directory.
Note - this is not the ideal solution - this is a potential BIG security whole since anybody can now also delete files in the particular directory, and ruin your website (I think...)
But in the short term your PHP scripts should now not have any problems writing into the directory chmod'ed like I showed above.
Donboy: Thanks again! It doesn't work, unfortunately....
Rylan: Thanks for the information! However, when I put that commando on my /var/www/html/tijlsite/prikbord, it doesn't work... The php file still doesn't write....
It looks to me like it's actually working. Better look around and see where the output may be going. Perhaps you're writing to a mysql database? Maybe to a text file somewhere? The messages in your logs are showing a return code of 200, which is success.
Hard for me to advise any better because I have no idea what the script looks like or what its doing, but from the apache side it looks like everything is working as it should be.
Maybe you should create a very very simple PHP script like "Hello world" and be sure that works. When you're done, start adding functionality, like maybe have it write a simple file on your server into a directory you can find easily and you know it's got the right permissions. Make the path to the file (in your script) hard coded so there are no mistakes about the path it's writing to or the file it's writing to.
Yes, you're right. It's writing data to a txt file. But there's nothing in the txt file.
Oh, by the way, I asked the person who wrote the php file if it writes to a mysql database. This is not the case. But he said something else: there's another PHP file who controls the visitor counter. This is working properly!
So, you can ask yourself: if apache is working, what can it be? A fault in the code? Can't imagine because it works on another server (Apache on Windows NT).
Hmmm, well, like I said, without seeing the script, I really have no idea. Maybe it's something about the difference between unix and windows. Maybe it's a permissions thing. Maybe you need write permission on the file and all directories that lead up to it. Maybe you want to post this question in a PHP forum so it can have the attention of the PHP gurus.
I would like to be able to say that we've totally ruled out all apache problems, but I can't really say that without sitting at your machine myself and looking around. I keep getting this feeling like maybe it's writing to a different error log that you haven't been checking.
Like I said, if you're getting no errors in apache logs, then it means the PHP script returned true and succeeded in everything it tried to do. That would mean there are no apache errors and all of the problem lies within your script.
Yes, well... today was my last day at my company (I had my work placement there, which has now ended). They won't be doing anything with the Red Hat server anymore. Thank you very very much for the help anyway!
I will set up my own Red Hat server at home one day, and will see if I get the same probleme with another PHP file. Anyway, I know what to do by then. THANKS!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.