I have a symlink at /var/www/domain.example/web/MY_SYMLINK pointing to /var/www/domain.example/web/SOME_FOLDER. This is defined as my document root for the website.
Then I run ln -sfn to change the symlink to something like /var/www/domain.example/web/NEW_FOLDER.
So far, so good. If I run ls -a it’s possible to see that the change was applied.
If I hit the server at http://domain.example, the website still pointing to the old folder. I know that apache needs to be restarted, so I run service apache2 restart but the change isn’t performed. I’ve tried with apache2 stop/start, reload or graceful. None of them works.
The symlink update is only applied if I go to ISPConfig’s control panel and hit Resync.
I wanna be able to perform this from the command line. Anyone know how to do it?
4
Answers
Check that apache is running
Note that Apache recommends using apachectl -k as the command, and for systemd, the command is replaced by httpd -k
This tells the process to kill all of its threads and then exit
A symlink should work fine. You may or may not need to add the directory to /etc/apache2/apache2.conf so that apache knows it is allowed to access the non-standard directory.
Excerpt from ‘/etc/apache2/acpahe2.conf’
Make sure all permissions, including parents, are in order.
I’m pretty sure that this is related with the fact that you have PHP running as FPM. I’ve worked with a similar setup and the deployment process was to copy the sources on the server and reseting the symlink that was the document root dir defined in the vhost file. And I had to include a PHP FPM restart at the end of the deployment process, otherwise the server kept serving the old sources.
For restarting the PHP FPM service, the most common ways to do it are:
or
Or for other ways, you can check the answer from this post.
Did you run it with
sudo
? It won’t take the command unless run with administrator privileges.A partial answer (where not to look)
From what you have said, I see nothing wrong with what you are doing in creating the symlink. You don’t have to restart Apache.
There is one bit berried down at the end of the question that no-one seems to have noticed. “The symlink update is only applied if I go to ISPConfig’s control panel and hit Resync.” This question is not about symlinks, it is not about Apache, it is about ISPConfig.
Where to go next
You would be better off asking a new question: