windows 2016, php dns query fails unless first run as admin - php

Been trying to figure out an issue not being able to use php's dns_get_record when called in a webpage under IIS. Thru some trial an error i figured out it was a permission issue. I think I confirmed this when i temporarily added the app pool user the webpage was running under as part of the admin user group. Suddenly it started working. And surprisingly, it kept working even after i removed the app pool user from the admin group. I have 2 versions of php installed on the server. It was not working on either version. And now it works on both versions.
My guess at this point is that it wants to write to some temp/cache file and as a user it has permission to write to the file, but does not have permission to create the file. When i added it to the admin group it was able to create the file. This is purely a guess on my part.
Since i don't know the exact cause, i can't be sure it's really fixed. So would really appreciate if anyone might have a better idea of what's going on and how i can make sure it's fixed permanently.
Update1: some additional info - after removing admin rights on the app pool user, i can restart the app pool or even restart IIS through the IIS control panel and it keeps working. But, if i restart IIS using iisreset, it stops working until I give admin rights again and then run it once. I'm not sure what's different between restarting IIS in the IIS control panel, or using IISRESET, but something causes it to stop working again using iisreset.
Thanks

Related

Mailwatch Quarantine Not Showing Contents

I have setup a mail gateway using MailScanner and have now setup MailWatch to be able to monitor the emails passing through.
It seems as though MailWatch's Quarantine is not showing me the contents of the quarantine. It does show me the recent emails as they pass through. But if I browse to the quarantine and select today's date it just says: No quarantined messages found
I am not sure why I am not seeing anything as I have done the setup exactly how the MailWatch.org website states I should.
Also, not sure if it is important, but I am running the following setup:
Debian 7
Postfix
Mailscanner * Latest
MailWatch * Latest
How can I find the cause?
From what I read it sounds like permissions. But I am not sure what I can/should change them to as as I don't want to break mailscanner.
Any help would be appreciated :).
Answer Found
It seems that when the server reboots mailscanner tries to launch before mysq has completely started causing mailwatch sql logging to crash.
Simplest solution is to stop mailscanner, end the processes that may still be running and start mailscanner service back up again.
Resolves it immediately.
Change permissions for quarantine folder... Not sure about Debian but in Centos it is in /var/spool/MailScanner/quarantine. It should be owned by user postfix and group should be group that your web server is in (apache in Centos but, again, not sure about Debian). Access rights should be 770.

Failed to open Stream, no such file or directory

I recently started using the Laravel framework and i set up a little workspace for me to work in. I setup a Xubuntu client at home that runs a Apache server from which i program and host my Laravel instance from. Now recently I've run into a little bit of a problem. I was following a tutorial series and everything went fine, the next day however i run into this error http://puu.sh/nh5vQ/8ae11c52ab.png
Both from opening the /var/www/html/test/public directory in apache2 from my webbrowser or from running php artisan and actually hosting the laravel instance.
So the first thing that came to mind was permissions, but the permissions for the public folder are fine, It should be able to read or execute as any program. http://puu.sh/nh5Ho/06e061a056.png
Mostly other posts can reference to a bit of code where they specified the wrong filepath. What i find odd is that when i open my hosted instance of apache server in my webbrowser, where you can technically browse all the files in the hosted directory it is there in the list, but when i click it it pops up with that same error.
I checked if all the files that the server is trying to acces exist, and they do exist and i made no typo's.
I'm going to continue on looking and i shall post the solution as soon as i find one, though I'm hoping you guys have an idea since I've been looking for about 2 days to find a solution.
Thanks for your time
I Decided I'd have to start a new Laravel project to fix this without making a chaoticly configured project.

Laravel / Nginx serving wrong site

I have tried everything.
I recently tried to deploy a new Laravel application on my Ubuntu Digital Ocean droplet. I have done this many times in the past and have done nothing out of the ordinary with this project. I'm using https://gist.github.com/jamieshepherd/50419bb148a4f43e8266 this as a template nginx configuration, which I base all of my sites off. However, this time I deployed and went to my domain, I was served another client's site. The site had no images, styles, scripts etc. - but sure enough this was the wrong site. Weirdly, I could go to /images/example.jpg and get the correct file which would be in /public/images/example.jpg - but the actual routes were being served from a completely different folder.
There is absolutely no reference to the other client in my project anywhere, I feel like it has something to do with Laravel or PHP5-FPM setting some kind of root directory to the other folder.
I have gone to /public/index.php and just echo and died a message, and this works fine. When I revert the change and let the application run it again displays the other client's application. Here's a list of other things I've tried.
Temporarily renaming the other client's folder, as expected, NewSite throws a 404 error
Temporarily disabling the other client's nginx block, NewSite continues to serve the other client's site (remember, not css/images/scripts, weirdly)
Reinstalling PHP5-FPM
Printing the document_root, everything looks normal (/web/NewSite/public)
Trying to run the site off a different port
Pulled a working Laravel application from a completely different server, put it on this server, set the domain to point to this working application, serves the other client's site
Grep'd for any references to the client site in any of the project folders just to check I wasn't going insane, confirmed I'm not insane, though after all this I'm not sure anymore
Really I'm lost, I have no idea how to debug this any more.
Site trying to deploy: http://paragon.gg
Client site view that it's servring: https://swellhunter.co.uk
Client site NGINX conf: https://gist.github.com/jamieshepherd/4ff5430ddb13ed04f22c
Edit: Update: To make matters even more bizarre. I have temporarily removed swellhunter from sites-enabled, visited paragon.gg, still serves swellhunter's index. WHAT? There is absolutely no reference to the site at all now, I've even moved the paragongg folder to a completely different place to check. How on earth is it even finding the view with no reference to go on?
Seems like an issue with Laravel rather than with nginx or with your VPS.
Since you pointed out simple PHP file is pointing out rightly.
SSH to your droplet and run you laravel app using php artisan serve.
And access your droplet on port:3000
If the problem persists you can rule out server issues and can concentrate on debugging laravel app. Maybe be there is something wrong with you laravel app itself, some unwanted changes etc. Did you verify your laravel App?
Can you paste an LS -l of the directory? Have you checked to see what you have in the Laravel app/config/app.php for url ? I just took a look at paragon.gg and put https://paragon.gg it gave me a cert error but after I accepted it the site looked fine. Is that not the result you wanted?

Is it possible to start / stop apache service from PHP?

I have created a simple website that will help me in my many projects by creating a sub domain for each new website project that I take on.
I keep going back to the older websites I've created so I have decided to keep all of them as a sub domain on localhost.
My PHP code works fine to add the information to the relevant files.
But I need to restart Apache for the changes to take affect.
I know PHP runs from the Apache service. Is it possible therefor to stop and start or even restart the Apache service from PHP code?
Yes, with exec()
exec("apachectl restart");
You might want to allow programs to close themselves before just shutting down the server, so I'd recommend:
exec("apachectl graceful");
Make sure PHP doesn't run in safemode (<= PHP 5.3), as these functions won't be available then.
Please note, this is how I restart apache on my server, you might have to adjust the command.
Also think about the permissions. Not all users (and probably not the one running php scripts) have permission to stop the server.

IIS access to a remote server in same domain

I have a server A where some logs are saved, and another server B with a web server (IIS) on it.
I can access serverA from Windows Explorer with zero problems, but when I want to access it from serverB with some PHP code, it doesn't work.
I made a python script that accesses the file from serverA on serverB. It works if I run that script from CMD, but when I run that script from PHP code it doesn't work anymore.
I run IIS server as a domain account that has access on serverA
I try to run that as LocalService, NetworkService, System, LocalUser but no success.
That script is a simple open command, so problem it's not from python.
Since you provide no example code or describe what you are doing... There are a few things to consider.
Anything running in the context of a webpage in IIS is running in a different context than a logged in user.
The first part of that is simply what file system level permissions might be different for the IIS user account. The proper way you want to handle that is by assigning the necessary changes at the filesystem level for the IIS user. Do not change the IIS user if you do not understand the ramifications of doing that.
The next part is that certain operations cannot be done in the context of the IIS user account (regardless of account permissions), because there are certain things that only a logged in user with access to the console/desktop can do.
Certain operations called from IIS are purposely blocked (shell.execute) regardless of permissions, account used, etc. This occurs in versions of IIS in Windows Server 2008 and later and is done for security.
Resolved.
Uninstall IIS and use XAMPP.
No problem found till now, everything works okay.
So use XAMPP/WAMP!

Categories