Symlink when the directory already exists [closed] - centos

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
We have added an NFS share onto our web servers and need to set-up a symlink - however, we are not sure how to do this when the directory already exists.
Webserver directory : /home/example/public_html/images
NFS target : /nfsshare
We want to have a symlink from /home/example/public_html/images -> /nfsshare
The NFS share has an up to date copy of everything in /home/example/public_html/images and we want it anytime someone goes to https://www.example.com/images/123.jpg or references /images/123.jpg in HTML that it shows the file /nfsshare/123.jpg for example
When we create the symlink
ln -s /nfsshare /home/example/public_html/images/
it appears to work fine but when we browse to /images it still shows the original content and the nfsshare folder is then inside the images folder
[root#host01 images]# ls
index.html nfsshare image.png
Is there any other way when you want to in effect point a folder to somewhere else rather than its current location?

The point of a symlink is to create a "virtual" folder (or file) that points to an existing folder (or file). But you can't create a folder or file when it already exists -- more precisely you can't create a "virtual" folder (symlink) when a physical directory already exists.
... and if I understand you correctly, you already have an existing /home/example/public_html/images directory. You can't have both; you'd need to remove (or rename) the existing web server directory.
As an aside, the symlink got created inside the folder because you specified an existing folder name as the target.
Update:
Assuming a sane set of permissions on the server, you probably need to do this as root or using sudo. You should probably also verify that the permissions on the NFS folder restrict your web app(s) to read-only access.

Related

How to move folders generated by application to an external disk on MacOS

This question may not be related to programming
An application will generate a large folder under /Users/Library/Containers/com.xxx.xxx during initialization. I want to move it to an external drive, but the app crashed after I ln -s back the folder and ran the app, which may be related to data verification or some plist files in it.
Is there any solution?

edited cgi file and then the website stopped [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
First of all, I am not an expert.
I have been working with a website.
I have looked at a cgi file:
eval {
# configuration
$ui_title="Something";
$ui_title_abbrev="Something";
$ui_dblue="#400080";
$ui_blue ="#6464FF";
$ui_lblue="#d0d9f4";
...
}
I have changed a value of a parameter $ui_title from "Something" to "Something_else".
Then the website stopped working.
I have changed the value from "Something_else" to "Something."
But the website still do not go back to the previous status.
Please advise the next step.
If you really want to get to the bottom of the error, look at the error log file of the web server. It will state the exact reason for the error. If you don't understand the error then searching for it on Google will give you more details and probably the exact solution to the problem. Things never just stops working for no reason.
The answers below assume that your web site is hosted on a Linux based web host:
In my experience the most common error in this kind of scenario is that the file permission of the file changed when you edited it or updated it. Perl files or cgi files need the permission setting of 755 (set to executable) to work. In other words the file needs to be set to be executable. If you are using FTP to update/transfer the file there will normally be an option in the FTP program to set the file permission setting to 755 on the server. (with your ftp program) If you are in a Linux terminal window you can use chmod to set the permission setting of the file. Also double check that the directory holding this file has the permission setting of 755
This is rare but happens: If you are using FTP to transfer the file to the server then it might be that it did not transfer properly. (Broken connections, sluggish internet, etc.) Try to re-transfer the file. You can also compare the file sizes of the one you have offline and the file on the server to make sure that they are the same.
This answer assume that you are using windows (opened the file in Windows to edit) and have a Linux based server. If you used a text editor to open the file and your web host or web server is Linux based make sure that you saved the file in the Unix file format. There are many good or more advanced text editors out there that will enable you to read and save files in the unix file format. Get a good text editor like Textpad (free to try) to open the file and save it in the Unix file format.
If you're new to Perl/CGI scripts then the best advice would probably be to make a backup of the file before you make changes to it. The 3 solutions above are probably some of the most common problems if there is nothing wrong with the code.

Including multiple folders (with images, scripts, etc) within a Matlab standalone GUI.exe

I have a software that has multiple GUIs. To organize things better (or at least that was my thought), I have created several folders within the root directory as it can be seen in this image.
Within the folders i have both files with different formats and also some Matlab scripts.
When creating the Matlab executable using the Application compiler, and after selecting the main file, Matlab does not directly detected that these same folders are important for the code to run. Therefore I decided to add the folders manually.
Once the setup is created and installed, by running the application within the Matlab environment, I was able to debug one possible issue why the software is not running.
As you can see in the first image, the "play.png" is within the Images folder.
My question is pretty straight forward: how to force the Matlab Compiler to learn that all these folders are to be included in the setup? Not only to be included but their paths'
Two things could be going on:
You are not including the files in the package.
Make sure that you include them using the -a option of mcc:
mcc -m hello.m -a ./testdir/*
You can also use the GUI, of course, see here.
You are looking for the included files in the wrong place. Use ctfroot as the root of all paths in your code:
img_file_name = fullfile(ctfroot,'Images','brain.jpg'));
Check the unpacked CTF file (it is automatically unpacked when executed) to see the directory structure in it. ctfroot points to the root of the unpacked CTF file.
PS: This blog post might give you some more pointers.

Changes in conf/server.xml does not seem to have any effect during runtime

Here's what I know:
When uploading files given by users, we should put them in a folder
outside the deployment folder. Let me call it D:\uploads.
We should (somehow) add that folder (D:\uploads) as a web app context.
Here's what I did:
I upload my files to the folder D:\uploads.
I tried adding the web app context as it's mentionned here by adding the following row to TOMCAT_DIR/conf/server.xml:
<Context docBase="D:\uploads" path="/uploads"/>
But that doesn't have any effect. When consulting http://localhost:8080/uploads/file.png or http://localhost:8080/uploads I get a HTTP Status 404 error.
So what I want to know:
What did I do wrong ? How can I add my upload folder to Tomcat?
Is there any better approach when it comes to uploading files ?
Because I'm wondering what should I change if I want to deploy my
application to another server where there's no D:\uploads.
Change the docBase attribute. Use D:/uploads (with slash) instead of D:\uploads (with backslash).
When dealing with files in Java, you can safely use / (slash, not backslash) on all platforms.
Regarding the differences you mentioned in the comments when starting the Tomcat from the IDE and from bin/startup.bat: It's very likely when you start the Tomcat from the IDE, it is not using the same context.xml your Tomcat is using. Just review the Tomcat settings in the IDE.
How to store uploaded files is a common topic at Stack Overflow. Just look around and you'll get surprised in how this topic is popular.
If you aren't happy enough in storing your files in D:/uploads or you'll have other servers accessing the files, you could consider storing them in some location in your network. Depending on your requirements, you can have one dedicated server to store your files or just share the folder which contains the files in your current server. The right decision will always depend on your requirements.

Should /config/passport.js appear in my root /config folder in Sails.js?

Sorry for the n00b question. I'm trying to configure sails-auth with a sails.js project.
I get the feeling the file should appear in MyProject/config/passport.js, but I can only see it in MyProject/node_modules/sails-auth/config/passport.js. Should I move it to MyProject/config? Or leave it there (with a symlink maybe)? Or maybe something didn't work right with my installation...