-2

I want to run a command "chmod -R 777 foldername" every time when apache restarts on my linux server.

How can I do that?

I have Linux CentOs 7.1 64 bit installed on my server with VestaCp.

3
  • Either you're the one person on earth with a case-insensitive shell, or you wrote this "CHMOD" command you're talking about. Incidentally, it's considered a Bad Idea(TM) to have multiple programs whose names differ only by case. Also, you can't possibly be running Apache 2.2 and 2.4. I'd guess with a fair degree of certainty you're using 2.4. Dec 18, 2015 at 20:15
  • Hahaha! Sorry! I meant chmod, I don't know why I wrote it in uppercase :/ Yes, I have 2.4 running. Dec 19, 2015 at 6:51
  • FWIW you almost certainly don't want to run chmod -R 777.
    – user9517
    Dec 19, 2015 at 6:55

2 Answers 2

0

You can edit /etc/init.d/apache2

and add your command in start & restart

start)
            [..]
            CHMOD -R 77 foldername &
            ;;

restart)
            [..]
            CHMOD -R 77 foldername &
            ;;

But don't forget that thoose informations will be reset if there is an Apache update

5
  • I went to /etc/init.d folder but found no apache2 or httpd file. On doing 'ls', these were the folders and files in /etc/init.d/ : functions netconsole network README vesta Dec 18, 2015 at 15:52
  • did you checked in /etc/rc*.d/ ?
    – Froggiz
    Dec 18, 2015 at 17:01
  • rc*.d has the following folders : K50netconsole S10network S85vesta Dec 18, 2015 at 18:26
  • CentOS 7 doesn't use init scripts
    – user9517
    Dec 19, 2015 at 9:16
  • So, then how can can I edit the apache start script on CentOS 7? Dec 19, 2015 at 17:52
0

Not sure about Redhat-style distros, but in Debian-likes there's /etc/default/apache2, a shell file included on every run of /etc/init.d/apache2.

Not the answer you're looking for? Browse other questions tagged .