Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6209463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:59:21+00:00 2026-05-24T05:59:21+00:00

I am running Apache on my localhost. From a PHP script run as www-user

  • 0

I am running Apache on my localhost. From a PHP script run as www-user I would like to control Rhythmbox playback on my machine. So far I have a simple command in my PHP script:

exec('rhythmbox-client --pause');

This works great when I run it from the command-line as me, but if it runs as www-user I guess rhythmbox-client doesn’t know/can’t access my instance of Rhythmbox.

Is there an easy way for that PHP script to run as my user rather than www-user, or to tell rhythmbox-client which instance to control?

The overall application is that when my phone goes off-hook it calls my PHP script which pauses music, and resumes playback when the phone is on-hook. I love VoIP phones!

Solution:
Thanks to Carpetsmoker and Tarek I used sudo as the answer but there was a couple of problems. To overcome them I did the following:

Created a bash script to call rhythmbox-client. This bash script was executed using sudo in PHP as described in the answer below. Unfortunately rhythmbox-client didn’t know what environment to control, so the bash script looks like this:

#! /bin/bash
DBUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS /proc/*/environ 2> /dev/null| sed 's/DBUS/\nDBUS/g' | tail -n 1`
if [ "x$DBUS_ADDRESS" != "x" ]; then
        export $DBUS_ADDRESS
        /usr/bin/rhythmbox-client --pause
fi

Now that bash script can be executed by PHP and wwwuser, and my phone can pause/play my music!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:59:22+00:00Added an answer on May 24, 2026 at 5:59 am

    One solution is using sudo(8):

    exec('sudo -u myuser ls /');
    

    You will, obviously, need to setup sudo(8) to allow the user running your webserver to invoke it. Editing the sudoers file with visudo(8), you can use something like:

    wwwuser ALL=/usr/bin/rhythmbox-client
    

    To prevent Apache from being able to run other commands and only the rythymbox command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running IIS and Apache HTTP Server side-by-side on my localhost machine, and
so, I'm running Apache on my laptop. If I go to localhost, I get
I have my Apache http server running on localhost:80 and restlet server on localhost:8182,
I'm running wamp on Vista (Apache v2.2.11) and have projects setup such that http://localhost/projectx
On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts
Our current Apache installations are running Apache 2.0. Now we'd like to add some
For test purposes I have gearman running on localhost. So I run the gearman
I'm running Ubuntu. My Apache2 default file looks like this: <VirtualHost *:80> ServerAdmin webmaster@localhost
When running Apache Jackrabbit JCR as an embedded service in your app, is there
I have been running Apache HTTPD in 64bit mode by stripping out the 32bit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.