how to set path so that they work on both localhost and remote server - laravel-5.8

I have an app that is working fine in localhost. On remote server I have uploaded it to a sub folder. Some of the relative paths are not working. My question is what is the best practice in defining relative paths, so that they work on local and remote server.

You need to set a relative path for links
Example :
{{ __('home') }}
OR By route name
{{ __('home') }}
This will work for any where you set project.

Related

Site can't be reached when running IIS in Docker

I followed the instructions on the official Dockerhub repo for IIS (https://hub.docker.com/_/microsoft-windows-servercore-iis), but running into "Site can't be reached" when trying to access via the IP of the container.
I get 403 forbidden when I try htp://localhost:8000.
I copied a test.html page into C:/inetpub/wwwroot and verified by logging into the container as well.
The results of appcmd list site is as follows:
SITE "Default Web Site" (id:1,bindings:http/*:80:,state:Started)
403 typically indicates that the web address we are trying to access is not the root directory of the website.
I doubt if there exist any files, which have been copied to the remote docker container.
Please make sure that the directory where the dockerfile is located contains the content folder and contains all site files.
WORKDIR /inetpub/wwwroot
COPY content/ .
Feel free to let me know if the problem persists.
You are right in your analysis. What i didn't realize is IIS perhaps serves index.html as default and my file was called helloworld.html which obviously wasn't going to be to served when i access localhost:8000; it works when i try localhost:8000/helloworld.html.

how do i solve the image upload issue of laravel while hosting it on shared hosting?

i am using hostinger to deploy my laravel project i uploaded all the files into the public_html folder and then did all the necessary changes needed for the application to work.The app seems to work pretty fine but when an user tries to upload a image the image gets stored in the storage/app/public/avatar folder and on public/storage/avatar folder as i have used symlink to link the two folders but yet the photos cannot be viewed by the users. this is how i recall my photo
div class="profile-avatar" style="width: 400px;height:500px; border-radius: 0%;background-image: url('#if(Auth::user()->avatar == "avatar.png") {{ url("/imgs/".Auth::user()->avatar) }} #else {{ url("/storage/avatar/".Auth::user()->avatar) }} #endif');"
please help me to solve this issue
As you have no ssh access to run some command in shell,
try this when uploading the image
1. Store image here: public_path() . 'img/filename.jpg'*
2. Save the 'img/filename.jpg' in database
3. Generate the image URL with url('img/filename.jpg')
// Output http://www.your-domain.com/img/filename.jpg
If you can manage shell access then try this:
Remove your current app/public/avatar directory, which is created inside of storage folder.
Also remove your storage folder inside public !
After that via ssh cli, cd to your laravel project folder and create a symbolic link via following command
ln -sr storage public/storage
Hopefully it will solve your issue. I had same issue and mine got fixed via second method ( I had ssh access to my server ).

NIFI AWS BATCHIQ PAAS

I have a template which uses a keystore. locally, i just point it to my folder and it works. On the cloud, it doesnt seem to be working. i placed the keystore (jks) object under home/ec2-user/FUTBIN.jks . i did chmod777 on home , home/ec2-user and home/ec2-user/FUTBIN.jks .
I also placed the keystore on AWS S3 which has the same symptoms. Uploading the sql JDBC driver on S3 works without any problem
Please find screenshot attached of nifi controller config and error
When you are running NiFi on a Linux file system, I believe you need a leading slash ('/') to indicate an absolute path from the root of the file system, like /home/ec2-user/FUTBIN.jks. Without the leading slash for the root, it is interpreted relative to the NiFi process directory.
Changing directory to /opt/ worked correctly.

Get actual project directory of Gitlab

I'll straight to my point. I have an machine which installed gitlab and nginx, and I have an fresh laravel project that already has commited, but I need to access the source code of "public" directory of laravel for my nginx. how to get source code of public directory, so I can put into line "root path" in files "sites-enabled" nginx, so nginx can access those files ?
The GitLab API doesn't expose the filesystem location directly so you need to stitch the url together.
To get the entry point of all your repositories check you GitLab configuration. (Normally /etc/gitlab/gitlab.rb). Find the key gitlab_git_http_server['repo_root'].
In there you will see folders which represent your namespaces in these folders are your project.

Add /public in local enviroment laravel

In my local server launched with artisan serve need to specify the path to save the files to / public + path to the directory to save. In my real server as points directly to public is not necessary. Anyone know how to fix this to not having to change routes every time I'm in the local environment?
I always use URL::to('asset path') for links, and base_path() for server folders, and it seems to work for me.
An example I just dug up from my own app:
$file->move(base_path()."/public/uploads/".$type.'/', $filename);

Resources