Fix typo in apache restart and remove code duplication