LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 10: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, 01: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, 12: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, 12: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



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 02:23 PM
OpenVZ trfin_way Linux - Newbie 0 07-25-2007 03:27 AM
LXer: OpenVZ on Live CD LXer Syndicated Linux News 0 05-11-2007 01:46 AM
OpenVZ vs. Xen xowl Linux - Server 1 04-18-2007 08:27 PM
trying to install openVZ software atomico80 Linux - Software 0 07-03-2006 09:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:37 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
Open Source Consulting | Domain Registration