skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. Did you run it with sudo? It won’t take the command unless run with administrator privileges.

    Login or Signup to reply.
  4. 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?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search