Iβve been asked several times how to run OXID eShop in a subdirectory like . Actually, there are several methods to achieve this goal including the adaption of your apache vhost or via .htaccess forwarding. In this blog post I will describe how to use unix symlinks to resolve the situation as it is a very smart solution that can even be used to roll out and back between several versions of your project without any downtime.
We strongly advise to use a local development environment for running your OXID eShop project. Most likely, at some point, you want to transfer it to your production machine and will have a file structure like that on your server:
/var/www/. #doc root, depending on the system you use
βββ composer.json
βββ composer.lock
βββ source
βββ vendor
Theoretically, if your domain points to the web root (e.g. /var/www/), the shop can be run at the URL β which is definitely ugly: I mean, what should βsourceβ mean to the visitor of your shop? Very often, web hosting providers have the possibility to let the domain point to the subdirectory so you can easily let your OXID eShop project run on .
Hint: please donβt try to rename the source/ folder. Youβll definitely fail
Hereβs a very smart solution if you have no clue how to adapt your apache vhost: simply connect to your server via SSH, move to the root directory (see above) and set a unix symlink using this command:
ln -s source/ shop
ln is the command to set a link, -s is an option to define it as a symbolic instead of a hard link. source/ is your target directory and shop is the link name.
Now you have to adapt the values for sShopURL, sShopDir and sCompileDir in the file source/config.inc.php: simply point them to shop/ instead of source/.
Donβt forget to alter the rewrite base value in source/.htaccess as well.
Last step: clean up your source/tmp/ directory before you fire up your browser at and check if all alterations were successfully proceeded.
Downtimeless deployment with subdirectories
With the same method it is possible to switch back and forth between different project versions β practically without any downtime, with project folder names that could be ugly as sin, and your clients will not even notice them. Iβll show you:
/var/www/. #doc root, depending on the system you use
βββ my_oxid_eshop_project_v1.0
β βββ composer.json
β βββ composer.lock
β βββ source
β βββ vendor
βββ my_oxid_eshop_project_v1.1
β βββ composer.json
β βββ composer.lock
β βββ source
β βββ vendor
βββ my_oxid_eshop_project_v1.2
β βββ composer.json
β βββ composer.lock
β βββ source
β βββ vendor
βββ my_oxid_eshop_project_v1.3
β βββ composer.json
β βββ composer.lock
β βββ source
β βββ vendor
βββ my_oxid_eshop_project_v2.0
β βββ composer.json
β βββ composer.lock
β βββ source
β βββ vendor
βββ my_oxid_eshop_project_v2.1
βββ composer.json
βββ composer.lock
βββ source
βββ vendor
Letβs say you did in fact develop on your local machine and uploaded these project states to your production server. All these versions might be connected to the same database. You just check the new state in your browser if it works for you. If so, switch to it inside the doc root using the symlink function again:
ln -sfn my_oxid_eshop_project_v2.1/source/ shop
Hey, thereβs a customer complaining about a bug you accidentally added with your new version β just swiftly roll back:
ln -sfn my_oxid_eshop_project_v2.0/source/ shop
I think you got the idea, didnβt you? If you have any questions, please donβt hesitate to post them in the linked forum thread below
Many thanks to Joscha Krug for sharing this knowledge and the inspiration for this blog post!