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
You can gracefully restart the Apache v1.x or v2.x httpd daemon
You need to send USR1 signal to the Apache server:
You can run a configuration file syntax test as follows:
Type the following command as a root user:
OR
Reload HTTPD Configuration File Without Restarting Apache When Using Systemd:
I assume you are running PHP with FPM. Try restarting your FPM service with :
(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.
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.
Have you tried to remove the first symlink before creating the second one with unlink?
You can create .htacess file