PHP exec to restart mysqld


 
Thread Tools Search this Thread
Top Forums Programming PHP exec to restart mysqld
# 1  
Old 05-16-2012
PHP exec to restart mysqld

I want to do something very very bad. I want to create a button that restarts mysqld. Why is irrelevant for my issue.

Here is my php script ...
Code:
<?php
if(isset($_POST['restart'])){
       	exec("sudo /etc/init.d/mysqld restart");        
}
?>
<form method="POST">
<input type="submit" name="restart" value="restart">
</form>

On any old server this usually can work. But on my locked down amazon ec2 server it doesn't. I tried putting this in the sudoers file but the button still doesn't restart mysqld.

Code:
Cmnd_Alias RESTART_APACHE = /etc/init.d/httpd restart
apache ALL =NOPASSWD: RESTART_APACHE

Cmnd_Alias RESTART_MYSQL = /etc/init.d/mysqld restart
apache ALL =NOPASSWD: RESTART_MYSQL

I'm stumped, at wits end, maybe someone here knows the solution ?
# 2  
Old 05-17-2012
Check the apache error log for messages.
Is it working on the command line?
# 3  
Old 05-17-2012
I don't really see anything in the log file...
It does work on command line.
# 4  
Old 05-17-2012
check auth log for error. are you sure it'd exec as apache user (maybe 'nobody')?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Mysql missing mysqld.sock (Linux)

I am trying to start a server for a class I am in but... mysql won't start with this error ( ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) ) ---------- Post updated at 03:51 PM ---------- Previous update was at 03:50 PM ---------- ... (2 Replies)
Discussion started by: Slayer939
2 Replies

2. Shell Programming and Scripting

Script Variables Inquiry, Values Okay in Standalone Exec, No-Show in Cron Exec

I have the following bash script lines in a file named test.sh. #!/bin/bash # # Write Date to cron.log # echo "Begin SSI Load $(date +%d%b%y_%T)" # # Get the latest rates file for processing. # d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1) filename=$d export filename... (3 Replies)
Discussion started by: ginowms
3 Replies

3. Red Hat

MySQL (mysqld) fails to start!

Hello, I have recently installed MySql and I encourage an error. I am using Fedora 15 and when I am trying to start mysqld service i am getting the following error message: Starting mysqld (via systemctl): Job failed. See system logs and 'systemctl status' for details. If I try to start it... (4 Replies)
Discussion started by: dot_pro
4 Replies

4. UNIX for Dummies Questions & Answers

mysqld overloading cpu of VPS

Hi bros I have a VPS 512mb (Burst 2GB) with Kloxo installed and hosting few sites on it with not much traffic I am facing high cpu load for the last few days and seems mysqld is overloading the cpu Any suggestion will be appreciated Regards Rizwan Top output is as under top -... (2 Replies)
Discussion started by: rizwan65
2 Replies

5. Red Hat

comm: mysqld Not tainted ... Kernel Panic , System totally unresponsive

Hi, I am experiencing frequent system hangs, hard kernel panics, etc almost thrice a day. The system would be totally unresponsive and the only way is to reboot is hard power recycling (plug out the power cable and plug in back after 30 secs). I enabled kdump, but unfortunately the kdump files... (3 Replies)
Discussion started by: massoo
3 Replies

6. Shell Programming and Scripting

php shell_exec, exec command timeout

HI, Does anybody know if its possible to execute a command through exec, shell exec, system and if the program doesn't terminate in N seconds returns control to PHP ? reg, research3 ---------- Post updated 10-16-09 at 12:20 AM ---------- Previous update was 10-15-09 at 11:03 PM... (1 Reply)
Discussion started by: research3
1 Replies

7. Web Development

Can't restart apache. PHP is broken.

I need to restart my apache, but apachectl configtest tells me that Syntax error on line 208 of /etc/httpd/conf/httpd.conf: Cannot load /usr/local/apache/libexec/libphp4.so into server: /usr/local/apache/libexec/libphp4.so: undefined symbol: ap_signal I've tried rebuilding php, I'm not... (2 Replies)
Discussion started by: tatebn
2 Replies

8. Shell Programming and Scripting

Exec bash shell via PHP Site !

Hi everybody ! I writed php code so exec bash shell via php (SMS Send via bash shell) but i have problem as follow : 1. When i exec from linux mode : ./sms.sh --- output is "Messages ... OK". Then all message has been sent. 2. When i exec from PHP site --- return value is "Message ... OK" on... (1 Reply)
Discussion started by: lamthenhan
1 Replies

9. BSD

mysqld

Hello I installed mysql41 this is the end of the installation but when I try to launch the mysqld daemon it write this: note: LodelServoo is a CMS which need mysql I verify that the dir mysql existed under /var/db, but it doesn't so naively I created it and launch again the mysqld... (4 Replies)
Discussion started by: SoulCoder
4 Replies

10. UNIX for Dummies Questions & Answers

how can I restart X server ?

WITHOUT shutdown X ??? thanks , Ivan (6 Replies)
Discussion started by: oneivan
6 Replies
Login or Register to Ask a Question

Featured Tech Videos