apache not reading updated symlink
Asked Answered
A

4

10

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?

Acidimeter answered 18/11, 2018 at 17:26 Comment(8)
I'm not specialist but there are several CLI available, for instance here, and here. You may prefer more or less direct call to API, for which you may find inspiration here.Sarinasarine
I've tried to switch the symlinks for a folder on OSX and Ubuntu, and after running ln -sfn I could just access the new folder without even having to restart Apache. Are you maybe running PHP-FPM or FCGI with Apache?Pattison
yes @DanD., PHP-FPM. I'll try to switch php modes to check the behavior. But I wan't to stay with PHP-FPM at the end.Acidimeter
@RicardoVigatti, have you also restarted the PHP FPM service after changing the symlink?Pattison
You rely need to re-title, and re-write you question. The most important bit of the question is not mentioned until the end, and no-one seems to have noticed it. “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.Blent
@Blent I guess tags are there for this reason.Acidimeter
Just don't expect anyone to notice them. If you want a good answer, then make it as easy as possible, for people to know what the question is. Tags are good for searching, but are not always read. Titles are read, the first paragraph is often read. The farther down one goes the less likely it is to be read (we may not like it, we may ourselves read every question to the end, but not everyone does).Blent
I really appreciate your tip. When I found the real issue I'll make sure to update the question so it can be more clear.Acidimeter
P
8

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:

sudo service php-fpm restart

or

sudo /etc/init.d/php-fpm restart

Or for other ways, you can check the answer from this post.

Pattison answered 26/11, 2018 at 11:13 Comment(1)
I had no opportunity to look into this issue again, but I guess this is the right solution. I'll come back to confirm when I'm done.Acidimeter
I
0

Check that apache is running

sudo service httpd status

Note that Apache recommends using apachectl -k as the command, and for systemd, the command is replaced by httpd -k

apachectl -k stop or httpd -k stop

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.

Example (note: I do not use the -d option):

doug@s15:/var/www/html$ ln -s /media/newhd/test_web bla2
doug@s15:/var/www/html$ ls -l
total 44
...
lrwxrwxrwx 1 doug doug   21 May 11 22:14 bla2 -> /media/newhd/test_web
...

Excerpt from '/etc/apache2/acpahe2.conf'

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

<Directory /media/newhd/test_web/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Make sure all permissions, including parents, are in order.

Injection answered 26/11, 2018 at 9:48 Comment(2)
hi thanks for the response, i will check this during this weekAcidimeter
I didn't tried that. Anyway, I believe it doesn't work. Perhaps this is a problem that shuold be handled from the ISPConfig layer.Acidimeter
H
0

Did you run it with sudo? It won’t take the command unless run with administrator privileges.

Hereld answered 26/11, 2018 at 14:25 Comment(0)
B
0

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:

How to update (resync) website from command line, using ISPConfig

My web site does not update until I go to ISPConfig's control panel and hit Resync. I want to be able to perform this from the command line.

Anyone know how to do it?

Blent answered 27/11, 2018 at 19:9 Comment(1)
Thanks for your suggestion.. At the time I've made this question, was not clear to me what could be leading to the issue. Well, now I know it can be related to PHP-FPM. I'm checking at this very momentAcidimeter

© 2022 - 2024 — McMap. All rights reserved.