I connected to ec2 instance using filezilla and uploaded a folder. When I login from putty to access the folder, i see the folder in .ssh directory. However, when login as a root user (sudo -i), I don't see the folder in .ssh directory. Any idea why this is happening?
Related
My apache server needs to serve files located in a mounted directory in the root folder. However, when the process attempts to access a file in that directory I get...
PermissionError: [Errno 13] Permission denined 'path/to/file'
How can I give the apache server access to the files safely?
I am working on a CentOS machine.
First unmount the shared directory.
chmod 775 <path>
chgrp apache <path>
Remount.
Would be one relatively safe way.
(assumes your apache user primary group is apache).
I have just installed a new LAMP server inside Ubuntu server. This was done using tasksel, while login as root user. I want to move apache document root into /home directory. Please advice, should i create new user other than root or just go with root and place the document root under eg. /home/public_html ?
I'm using Ubuntu 14 server from DO, with LAMP stack installed, i followed the instruction here to install flask on ubuntu because my main purpose was to use Flask on my website.
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps
During the test, when user connects to "http:/myvpsip/createfile/" which creates a new file on the current folder /var/www/, I got error from Apache saying that the file cannot be created, "permission denied".
I tried again using PHP script that create a new file on the same directory /var/www/ but got the same problem. Both of the trials were done using root account. I tried to chmod the www folder to 755 or 777 and they are not working.
My question is, how do I set permission for apache2 that when users browse the website they will be able to create/edit file on the current directory?
Thank you
This is because when you installed your application, you did so as the root user. All your application files and directories are owned by root.
If you ls -l on /var/www and look inside the FlaskApp folder structure, you will likely see permissions set like this:
-rw-r--r-- 1 root root
When Apache runs, it runs on behalf of a main process owned by the user root and several child processes owned by the user www-data. So essentially, Apache is running as if logged in as user www-data.
When your application needs to do a file or folder operation (its running on behalf of Apache www-data user), the public/world permission bits are used since Apache child processes are not running as root user and not as root group.
Looking above, we see that only the read bit is set for the public/world permissions - no write. And that is where the problem lies.
One way to solve this is to make everything under /var/www/mywebsite owned by the user root and the group www-data. This sets things up so that only the root user can have full permissions and www-data (everyone else) can only read and execute (no write).
When you setup your website, you should set it up to be under its own separate folder. This way you can have multiple virtual domains (i.e. more websites) added later on. Assuming 'mywebsite' is where your domain is and you have already installed your application software (Flask) within it:
cd /var/www/mywebsite
chown -R root:www-data /var/www
You then as the system administrator, need to understand the application and go through the folders and files setting permissions. Apply permissions generally, then on a case by case basis.
For most directories (750)
- Only root can rwx directory
- www-data can only read and execute directory
- no public/world bits set as it makes no sense (*)
For directories that can be changed by web application (770)
- Root can rwx directory
- www-data can rwx directory
- no public/world bits set as it makes no sense (*)
- for uploading files, creating images, documents, etc by the users of the site
For most files (640)
- Never set the execute bit to avoid execution of misplaced shell or executable files
- PHP, Perl, etc. are just text files. They have nothing to do with exec permission
- No group write bit set
- Read must be set for owner and group else they cant see the web document
For special case where files need to be changed (660)
- Set group write bit if you want www-data users to create things
(*) Because all users who visit Apache are running on behalf of www-data
I accidentally deleted my "Public_html" folder from the web server. After accessing by fileZilla agent there is no public_html folder present. How can i upload the files to the web server and how can i create it again ?
You should access via ssh to the server in order to have access to the console command. From there if your server is linux:
mkdir ~/public_html
fs sa ~/public_html system:anyuser read
or else, if your server is IIS:
cd /home/[yourUser]/domains/domain
mkdir public_html
chown [yourUser]:[yourUser] public_html
chmod 755 public_html
replace [yourUser] with your user name.
Hope this helps.
In FileZilla, right-click in the remote pane and select Create Directory. Name it 'public_html'.
Secondly, drag your files from the local panel on the local pane to the remote pane to upload files to your public_html folder.
I have dedicated server and have root accesss via ssh putty - I have 1 account set up on the server but I'm trying to workout how i can access the public_html directory of this account from root#ds-44498 [~]# the public_html in the root is empty.
I'm trying to copy a file from the root to the account public_html folder
I have WHM - cpanel
Thanks
Have found answer: in /home/accountname/public_html/
thanks