skip to Main Content

Basically i have followed steps from this link: https://docs.gitlab.com/ee/ci/examples/laravel_with_gitlab_and_envoy/

I am using apache server instead of NGINX and that is the only difference.

So there is one envoy file which will do below:

  • clone repository
  • run composer
  • update symlinks

code of envoy file is as same as: https://docs.gitlab.com/ee/ci/examples/laravel_with_gitlab_and_envoy/#full-script except git url change and root directories change.

So setup is like this: example.com (dummy url) is pointed to my app directory which is /var/www/html/deployer-home/current/public

here current is a symlink which will point to /var/www/html/deployer-home/releases/1 and if i will upload new release symlink will change to /var/www/html/deployer-home/releases/2

if i will so ls -l in server then symlink display the /var/www/html/deployer-home/releases/2 but example.com is still pointed to /var/www/html/deployer-home/releases/1

i Have tried to service apache2 restart but still it’s domain pointing is not getting updated. It will only update if i will perfrom reboot in server.

So how to fix this issue? I don’t want to restart the server for every release.

5

Answers


  1. You can gracefully restart the Apache v1.x or v2.x httpd daemon

    You need to send USR1 signal to the Apache server:

    This (USR1) signal causes the parent process to advise the children to
    exit after their current request (or to exit immediately if they’re
    not serving anything). The parent re-reads its configuration files and
    re-opens its log files. As each child dies off the parent replaces it
    with a child from the new generation of the configuration, which
    begins serving new requests immediately.

    You can run a configuration file syntax test as follows:

    apachectl configtest
    apachectl -t
    

    Type the following command as a root user:

    apachectl -k graceful
    

    OR

    apache2ctl -k graceful
    

    Reload HTTPD Configuration File Without Restarting Apache When Using Systemd:

    # CentOS/RHEL/Fedora Linux
    sudo systemctl reload httpd
    # Debian/Ubuntu Linux
    sudo systemctl reload apache2
    
    Login or Signup to reply.
  2. I assume you are running PHP with FPM. Try restarting your FPM service with :

    service php7.4-fpm restart
    

    (update with the correct version if needed)

    WHY ?

    Once upon a time PHP was running as an Apache module (mod-php) but is now run in a separate service. Restart Apache is not enough (nor even required) if you want to apply some PHP configuration changes or, as you are, want your PHP processes to be launched with new filesystem informations.

    Login or Signup to reply.
  3. I really think this practice of using symlinks sucks. The reason being that when you change the symlink, there could well be requests that are somewhere beyond starting but have not finished. How those requests will work is variable depending on what is going on, but generally they will be some kind of broken

    A much nicer way is to simply update your webserver config to point to a new document root and then do a graceful reload/restart of teh webserver. This will allow any requests currently running to complete normally and any new requests will be served from the new document root. This is effecitvely having your cake and eating it – allowing both document roots to be valid. In a very short time, all requests will be getting served out of the new document root and you are unlikely to have any weird bugs.

    Symlinks are great and I use them a lot, but using them to switch webroots instead of just updating webserver config is not a good use case.

    Note – the way I tend to do the webserver config is have a very small include file that only contains one line. This file can be easily manipulated by scripts/automation and then the webserver config reloaded.

    Login or Signup to reply.
  4. Have you tried to remove the first symlink before creating the second one with unlink?

    unlink /var/www/html/deployer-home/releases/1
    
    Login or Signup to reply.
  5. You can create .htacess file

    <IfModule mod_rewrite.c>
      RewriteEngine On
      Options +FollowSymLinks
      Options SymLinksIfOwnerMatch 
    </IfModule>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search