I’m trying to run a PHP Script that parses my Ubuntu Apache Logs for RSS Subscribers (https://gist.github.com/marcoarment/5968198) by executing:
php -f feed-subscribers.php < /var/log/apache2/access.log
The problem is that even if I run it as sudo, I get an access denied error. I’ve been able to execute bash and python scripts with sudo that worked fine accessing the apache logs.
Can anyone give some guidance on how to adjust my set up to work properly?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
That worked, thank you! <br> <br>Just curious why it would work when switching into the root user versus just executing as sudo in my own user account?
Prefixing it with sudo won’t work because you can’t access /var/log/apache2/access.log, sudo only affects the “php -f feed-subscribers.php” part. <br> <br>Try this: <br> <br>sudo cat /var/log/apache2/access.log | sudo php -f feed-subscribers.php
Just to test things out… execute: <br><pre>sudo su</pre> <br>and then try your script, again. If that still doesn’t work, go to the folder where you saved <strong>feed-subscribers.php</strong> and execute: <br><pre>ls -l feed-subscribers.php</pre> <br>and copy and paste (onto this thread) the output.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.