Best way to make fake path in linux? - bash

Working part: I have folder with images for my website, but for local purpose, it is not necessary to show real images. I wrote php script, which serves fake image only with text of whole demanded path, script is located on root of image folder and activated for everything by .htaccess.
The other part - making thumbnails by php script is working directly in filesystem, so Apache does not affect these - and I have problem with non existing folders, files, etc. Is there some nice way to make similar fake path directly in filesystem?
I'm using docker image for this problem, so I'm able to do everything inside this image.
I'm avoiding to make changes directly in the scripts, because of temporary situation of server changing (change the path to serve over apache etc is not possible).
Thank you for your advice :).

You could create a linux softlink directory:
ln -s file1 link1

Related

Apache treatment of symbolic links under Windows

Does +FollowSymLinks work with Windows shortcuts? It seems it is completely ignored by Apache under Windows 10.
The importance of this is that, some web frameworks, like Laravel, use this directive to access storage folder (or any other folder outside the public directory) throughout symbolic links. Then, these features are simply ignored in Apache under Windows.
Could anyone, more experienced than I, conform or explain me that? Could you also tell me if there is any workaround?
Thanks for any help!
Shortcuts aren't symbolic links, that's not the same. In order to put a filesystem reference to a file or directory on Windows, you need to use mklink command in either CMD or PS console.
As for Laravel, it ships with no outside dependencies, meaning everything Laravel needs to work aside from PHP itself should be located in the served directory, minding the path in configs. As far as I know, Laravel doesn't use any kind of symbolic links as it is platform-independent, meaning that as long as you have PHP properly configured and compiled with needed extensions, it will work anywhere. It even ships with a default .htaccess used for routing inside /public directory, at least in Laravel 8.
The way Laravel files reference each other is rather simple, check relative paths. Mind they are also implemented as a part of filesystem in any Windows or *nix systems and behave similarly if not identically.
I propose to store the project as is in the config-defined directory and work on your code from there.

In Docker is it good practice to have a shared lib folder for entry point scripts?

As the amount of docker images and corresponding docker_entrypoint.sh files increases, I end up with repeated bash code across all entry point scripts. Since I hate repeated code my first thought was to create a shared lib folder with bash routines that are used by multiple entry point scripts.
However I'm not sure if this is a good practice mainly because we are leaving Docker's build context and we may get errors such as Forbidden path outside the build context (e.g. see here). I realize that we may work around this type of problems by doing something like creating symbolic links to connect the build context to the lib folder, but I'm not sure if I like this type of approach.
Therefore my question is whether it is a good idea to have shared libs for Docker entry points at all and: i) if not, is there a better approach to avoid repeated code; ii) if so, what is the best way to avoid problems such as the above-mentioned ones.
Thank you all for your attention
I would put your common code in a company base image, and call that common code from each of your child image's entrypoint.sh scripts. You will need a company base image for each of your extended upstream images, which isn't a problem if everyone uses the same upstream base image, but becomes a challenge if you have lots of different languages to support.
Another option, if you have lots of upstream images to support, you could get away with extending multi-stage builds to copy files from one "entrypoint" image you manage to each of your other images:
Dockerfile for entrypoint code could look like:
FROM scratch
COPY entrypoint_bin /usr/local/bin
Then you can add something like this to each of your other images:
FROM entrypoint:latest as entrypoint
FROM node_or_jdk_or_something_else:1.0
COPY --from=entrypoint /usr/local/bin /usr/local/bin
...

Trying to Set a Shortcut to a Directory

Im trying to run several different scripts on my Mac for data stored in different paths. So I put all said scripts into a folder. In order for a script to work, I have to be cd'd to a specific folder required for said script. I use the scripts to get different types of output (ex: Image volumes, MRI info, etc..).
I was wondering if there was a way to store all my scripts in one directory and assign a shortcut to it. That way, I can cd to my folder, and only type something like $ScriptsFolder/Script_1 to have it. Ive seen this done in the FSL software package, where typing $FSLDIR/data/standard would give you the items in that folder.
UPDATE:
Im using Script=/Users/ray/Documents/Script which works until I close down my terminal to start a new one. Any way to make the setup permanent?
EDITED
Found this helpful in the end.
http://www.techradar.com/how-to/computing/apple/terminal-101-creating-aliases-for-commands-1305638
I used it to create a shortcut to my scripts which are all placed in a folder for easy referencing.

Mac OS X - How to store web projects in a location other than /Library

Google turns up nothing but very basic set up of web servers on the Mac. I've got that.
I build web projects locally on a Mac using PHP/MySQL. I store the sites in /Library/WebServer/Documents then access them via browsers with http://localhost.
This works fine.
What I would like to do is to be able to place symlinks or aliases of projects into the /WebServer/Documents folder and access sites on other (local) drives. I don't want to have to store everything in the Library folder. However, it seems that symlinks don't work. The only way a project functions is if all it's files are located in the /Library folder - no symlinks.
I realize I can change the root path for the web server in the http.conf file but I don't want to actually change the server path, I merely want to use symlinks if possible. I also realize I could use something like MAMP, but things run fine with my traditional set up (and I prefer to avoid MAMP since it's not always real-world). Main motivation here is that I don't want to store files on the boot volume, where there Library folder is located.
Can I use symlinks for directories with Mac OS10.6.8/Apache? if so how, please?
Thanks!
Solved via this article at Apple:
http://support.apple.com/kb/TA21182?viewlocale=en_US
One must specifically create a symbolic link. Which, it appears, is not the same as an Alias on the Mac OS.
But this isn't feature of MAMP application, this is about web server. Make it through MAMP and go see what is new in apache config files (httpd.conf, vhost.conf).
you have to use symlinks instead of an alias... sad there is no ui for that!
you have to go into the Terminal and type:
ln -s /ORIGINALPATH /LINKEDPATH
the first PATH is the base path of the original file and the second is for the base path for the symlink of the file/folder etc

Move the whole joomla site to a different directoy/subdomain

I am currently developing a joomla 1.5 based site in a temp subdomain (which points to a subfolder on ther sever where all joomla stuff is installed). Currently I am using plugins joomgallery an kunene 1.0.9 (legacy mode).
Once the development is done I would like to move the whole site into the root directory and delete the whole subdomain. How would this ideally be done? Can I just move the files or is there more to it? Any common pitfalls to watch out for? E.g. Are there absolute paths referenced somehwere?
In your configuration.php file, the base path might be defined, something like this:
var $live_site = 'http://temp.mysite.com/';
...though I think by default now, it automatically detects this value for you.
Check in the configuration of your custom components to see if they have got the paths "hardcoded" in there too.
Another thing you could do is set up a .htaccess file with some RewriteRules so that any call to http://temp.mysite.com gets redirected to http://www.mysite.com
There is a free Joomla! extension for this called Joomlapack. Just make a backup with Joomlapack, move the backup files that was created to the new site/folder and run the script that also was created in the backup. Done!
Joomlapack makes a complete backup on both the DB and site files so you can move your site anywhere if you wanted. Joomlapack can be found here: http://www.joomlapack.net/
Make sure to edit your configuration.php file as per these instructions.

Resources