Will Symlink do as im hoping - treat one folder same as another - directory

I want to symlink:
/var/www/ThisFolder
to this folder
/var/www/htdocs/Thisfolder
I.e Symlink the folder that is in a non web accessible directory to link to one that is.
I plan to do this via:
ln -s /var/www/ThisFolder /var/www/htdocs/Thisfolder
Will my server then treat the folder outside the root as if it were inside the root?

Permissions on symbolic links are kind of funny. If you don't have permissions to view your target folder (/var/www/htdocs/Thisfolder) you wont be able to access it through the symlink. The permissions you will see by doing an ls -l on your symlink will show its permissions for renaming/unlinking the symlink, not for the target.

Related

Symlink working but is showing the directory one level up for some reason

I have a directory that contains media that I am trying to setup a basic symbolic link to - the directory is a mounted storage on a digital ocean droplet in the following directory /mnt/storage/media/all
this contains directories as shown below:
0118
0119
0218 and so on.......
I am trying to make a symlink from my unix terminal as follows :
$ root#server1:/var/www/abcd/public ln -s /mnt/storage/media/all
So if I cd into the public directory above I would expect to see the directories 0118, 0119, 0218 and so on... however when I cd into this directory I see the directory all and within this directories are the 0118, 0119, 0218 subdirectories.
How do I change the symbolic link so I see the directories 0118, 0119, 0218 etc.. and not the all directory (which contains those same sub directories)
Try giving a second argument for the function. Let that argument be the desired destination for the link (but it shouldn't exist prior to this).
E.g. ln -s /mnt/storage/media/all /var/www/abcd/public
In case the folder public already exists, the symlink will be created inside it.

Setting permissions to WordPress to install plugins is preventing access through SSH

I have read several ways to solve the problem of permissions in WordPress to install themes and plugins from the WordPress administration.
As I understand the problem is that the owner of the folder where WordPress is installed must be the user who manages the web server (read postdata). In my case with Apache and AWS, www-data.
However, by changing the owner to www-data (even just changing the group to this user), I lose SSH access to the server. In this case I had to ask the administrator of the entire server to access from its user and restore the owner and permissions of the folder.
I am using Amazon Web Services with Ubuntu 16.0.4 LTS where I have access to a main user and the installation of WordPress is located at the root of the user, i.e. /home/myuser/
I am accessing via SSH with a .pem key and with myuser#publicdns
What can I do?
Thank you so much.
PD: WordPress in this guide says that the owner always has to be the ftp web server owner (i.e. myuser) and never the webserver, I agree.
I hate having to answer my own question but maybe I can help others solve problems easily and fast. This is what worked for me:
BEFORE DOING ALL OF THIS YOU SHOULD TAKE NOTE OF ALL PERMISSIONS, OWNERS AND GROUPS OF ALL THE FOLDERS & FILES WE ARE CHANGING HERE BECAUSE YOUR WEBSITE MAY FAIL AFTER CHANGING THESE SETTINGS. ALL HOSTS HAVE DIFFERENT CONFIGURATIONS.
As long as you don't exit the session, you may be able to return all the changes you have made with sudo privileges.
If your WordPress installation is in the root folder of the user, eg: /home/myuser/
Take note of permissions, owners and groups:
With ls command and the -a -l flags you can see all files using long listing format. Do this being in /home and /home/youruser/ paths.
cd /home
ls -al
cd /home/youruser
ls -al
Copy the output and save it in some text file.
Prevent losing SSH access:
The owner of the folder must be the user you are accessing with.
sudo chown youruser /home/youruser/
I also have set the group of the folder myuser.
sudo chgrp youruser /home/youruser/
Set the permissions of this folder with 751 (I think the important thing here is that the owner has full access)
sudo chmod 751 /home/youruser/
The permissions for the hidden folder .ssh must be 700 for top folder, 600 for files inside the folder and the owner & group must be youruser
sudo chmod 700 ~/.ssh/
sudo chmod 600 ~/.ssh/*
sudo chown -R youruser ~/.ssh/
sudo chgrp -R youruser ~/.ssh/
Solve Plugins & Theme installation problems:
I'm still unsure if this solution is right for site security. However, I think you can apply this fix and then return the changes. The website should run smoothly in both cases.
I have changed permissions for folders and files via sftp in Nautilus. If you are using .pem key remember to add the key using ssh-add path/to/your/key.pem
then connect to the server sftp://youruser#yourpublicdns
Make multiple click in folders wp-content, wp-admin, wp-includes and do Right click -> Properties (or Ctrl + I), change to permission tab and click in the "Apply permissions to Enclosed files" button on the bottom of the window, set:
Files
Owner: Read and Write
Group: Read only
Others: Read only
Folders
Owner: Create and delete files.
Access to files.
Access to files.
This will apply the changes to files and folders inside these three folders selected. Depending on the speed of your internet and how much files do you have, this may take some minutes to finish.
Make multiple click in remaining files and do Right click -> Properties (or Ctrl + I), change to permission tab and set
Owner: Read and Write
Group: Read and Write
Others: Only Read
AND LAST
Change the owner and the group of all the WordPress installation files, i.e. all the files inside /home/youruser
sudo chown -R www-data wp*
sudo chgrp -R www-data wp*
This make changes for all the files that start with the "wp" word recursively. To remaining files, I have made the changes manually. There are better ways like find command but that changed hidden folders too so I decided to do manually.
Apply the corresponding changes to files to the .htaccess as well.
NOTE: Test your website. Access to it, access to your WordPress admin, try installing plugins and themes, open another terminal (DON'T CLOSE the one you were writing the commands) and try to SSH into your webserver. If you have problems use the backup and revert the process.
Hope this helps.

Issue in drupal the directory sites/default/files is not writable

To solve these issues display in process of installing Drupal as:
Go to your "drupal" folder and make permission 777
Then open "sites" folder and make it 777
Choose "default" folder and make it 777
Open "files" and choose "setting.php" to change permission to 777
You are giving public right to execute read and write files in your directories. Clearly not a good idea.
Check this link for more infos on what to do in production environnement (it also explains basic chmod values wich you seem to not be understanding) : https://www.drupal.org/node/244924
Some normal permissions would be 0644 for files and 0755 for directories. Then i.e. settings.php since there is no need for it to be writable you should fully forbid writing.
If only 0777 "solves" your issue, maybe problem are not permission values but file owner. It happens that you upload files with one (FTP) account Apache is running website with some other, which is not allowed to write over first one. So changing file owner could solve the issue.

How to upload my Symfony project to shared hosting?

I have a Symfony 3 app that I need to deploy to a shared hosting server - hostgator. I have copied all of the contents from the web folder into the public_html folder. I also copied all the other folders on the root of my directory. However, I does not run.
Did you check the proper permissions in particular the var/ folder, this is described on this page.
Also, if they use apache, you will have to set the owner:group of the web folder properly.
In Linux that is done easily by this command (from the root folder):
$ chown -R apache:apache web/
Try that out (you might need sudo access to run chown).

Problem with file permissions in Drupal 7

So, I've copied the install tree of a site I'm developing to another machine. After updating settings.php to the proper db and base_path, and making sure that the file permissions for /sites/default/files/ are set to 755 (chmod -R 755 files), the file settings page (Configuration -> Media -> File System) insist that "The directory sites/default/files exists but is not writable and could not be made writable." I've experimented with 777 permissions to no avail. Any thoughts?
Change ownership of the files directory to apache, or whatever your web user is.
chown -R apache.apache files
If you don't have access to change ownership for some reason, then making all files recursively writable should work.
chmod -R a+w files

Resources