Deploying your PHP application on our hosting accounts can be done hassle free with the use of symlinks (symbolic links) to the relevant folders. This can be as simple as pointing ~/httpdocs to your webroot folder or more complex setups for deployment applications.
To create a symlink you can use the following command.
ln -s /home/$USER/[File/Folder location] /home/$USER/[symlink location]
This will create a symbolic link at symlink location pointing to File/Folder location.
Here are some examples using Magento 2
Symlinking the httpdocs folder to the webroot folder of magento 2
# Magento root folder.
~/magento2
# symlink httpdocs to the Magento pub folder.
~/httpdocs -> ~/magento2/pub
Symlinks really shine when it comes to CI deployment.
This is an example of a Magento 2 setup ready for CI.
# Magento 2 root folder for the current release
~/releases/202608031523
# Shared folder for files not in Git
~/shared
# The symlinks for files not in the Git Repo.
~/releases/202608031523/pub/robots.txt -> ~/shared/pub/robots.txt
~/releases/202608031523/pub/media -> ~/shared/pub/media
~/releases/202608031523/var -> ~/shared/var
# Symlink to the current release for easy access
~/current -> ~/releases/202608031523
# Symlink to the webroot using the current symlink.
~/httpdocs -> ~/current/pub
# Symlink from the default magento2 installation folder to the current release.
~/magento2 -> ~/current
With this setup, the only symlink that needs to be changed after a new release is ~/current
and most deployment tools will take care of this for you.
After a release you may need to flush the various caches.
OPcache is enabled on the servers we manage. If you change a file, PHP will detect the change and re-read the code from disk. If you switch to a new release using a symlink, PHP will not detect any changes and keep using the old code. You can fix this by flushing the OPcache
We do not recommend cleaning Varnish after every deploy. This will cause your shop to become unnecessarily slow after a release. You can flush Varnish manually. Read here how to manage Varnish
You may need to clean application caches after a release, depending on the changes you make. If your application cache is in Redis, read here how to manage Redis
Was dit artikel nuttig?
Dat is fantastisch!
Hartelijk dank voor uw beoordeling
Sorry dat we u niet konden helpen
Hartelijk dank voor uw beoordeling
Feedback verzonden
We stellen uw moeite op prijs en zullen proberen het artikel te verbeteren