LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 06-16-2009, 11:20 AM   #1
yourweb
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Rep: Reputation: 0
OpenVZ problem


Hello everybody
I'm currently busy with developing a PHP system which needs ro run some commands such as vzctl. vzctl doesnt wants to run on a normal account and only on the root account. How can I run a root command with PHP and maybe C/C++ or perl??

OR is the best solution to put the command in a .sh file and set a cron job as root user on it? Or won't that work?

The OS is CentOS 5.3 64-bit.
 
Old 06-16-2009, 02:42 PM   #2
lukav
Member
 
Registered: Sep 2008
Distribution: Slackware & Ubuntu
Posts: 39

Rep: Reputation: 15
A possible solution is to add the user name that apache is running under to the sudoers file with the option to access those specific files and to not require a password. Keep in mind that this could open a security hole - so be carefull.

If you do this, just remember to add sudo to your commands.
 
Old 06-17-2009, 01:32 AM   #3
yourweb
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by lukav View Post
A possible solution is to add the user name that apache is running under to the sudoers file with the option to access those specific files and to not require a password. Keep in mind that this could open a security hole - so be carefull.

If you do this, just remember to add sudo to your commands.
I have already tried to do this, but it didn't work. Probably I did something wrong, can you show me how I can do this?
 
Old 06-17-2009, 01:31 PM   #4
lukav
Member
 
Registered: Sep 2008
Distribution: Slackware & Ubuntu
Posts: 39

Rep: Reputation: 15
In /etc/sudoers you will want a line similar to this:
Code:
www-data ALL=NOPASSWD: /usr/bin/vzctl
You will want to make sure that the specifics above are the same for you.

In your PHP code try executing vzctl using sudo
Code:
<?PHP
exec('sudo /usr/bin/vzctl');
?>
 
  


Reply

Tags
container, exec, openvz, php, root, vps


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenVZ Installation: Help Please I_AM Linux - Software 0 12-03-2008 03:23 PM
OpenVZ trfin_way Linux - Newbie 0 07-25-2007 04:27 AM
LXer: OpenVZ on Live CD LXer Syndicated Linux News 0 05-11-2007 02:46 AM
OpenVZ vs. Xen xowl Linux - Server 1 04-18-2007 09:27 PM
trying to install openVZ software atomico80 Linux - Software 0 07-03-2006 10:14 AM


All times are GMT -5. The time now is 09:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration