当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Running A2ensite and Apache Reload with cron

问题描述:

What I'd like to do is call a2ensite and service apache2 reload from a shell_exec when a user registers their domain on my server. I've tried setting it up with cron jobs, to no avail

*/5 * * * * /etc/apache2/sites-available/a2ensite *

And then inside the a2ensite file I have

#!bin/bash

#Enables Sites every five minutes.

a2ensite *

And then for apache reload I have

*/30 * * * * service apache2 reload

I have these two edited with sudo crontab -e and had no errors when I put them in, but I just waited an hour after registering and my example.com.conf file is there now. Inside my root html I have my example.com folder, but sites enabled does not have it and I have no idea if apache reloaded. If anyone can just point me in the right direction as to what I'm doing wrong it would be greatly appreciated

I also tried during the user registration

shell_exec("sudo /etc/apache2/sites-available/a2ensite");

And ran visudo and added

www-data ALL=NOPASSWD: /etc/apache2/sites-available/a2ensite

分享给朋友:
您可能感兴趣的文章:
随机阅读: