Disable webserver write access wordpress-Digital Ocean - wordpress

I have used the following commands in Putty to ENABLE rewrite, so I can update wordpress in my LAMP stack Wordpress install.
$sudo a2enmod rewrite
$sudo chown -R www-data /var/www
I would like to disable rewrite so no one can install plugins and update wordpress automatically from wordpress admin area. What command should I use to do so?

Related

How can I set EC2 ownership permissions that allow me to update WordPress and modify files via FTP?

I have an AWS EC2 (Ubuntu Server 18.04 LTS (HVM), SSD Volume Type) on Apache with a working WordPress site on it.
If I run sudo chown -R ubuntu:ubuntu /var/www/html, then I can edit files via SFTP and save them, but not update my plugins.
If I run sudo chown -R www-data:www-data /var/www/html, then I can update my plugins but not edit files via SFTP and save them.
How can I update my plugins and edit my files without having to run the corresponding command each time?
I have already run sudo chmod -R 755 /var/www/html.
The permissions seems correct to me. Did you install a ftp server in the ec2 instance?
As you don't mention that, I guess you will have to install one than use credentials in wordpress to connect. Here's one guide to install and configure ftp at ubuntu
http://gabrielmagana.com/2014/11/installing-ftp-server-vsftpd-on-an-amazon-ec2-ubuntu-14-04-host/
If I remember correctly, you can set the owner of the directory to www-data. Then add user Ubuntu to the www-data group.
sudo adduser www-data ubuntu

Nginx permissions with wordpress

I am trying to set up wordpress on digitalocean with nginx. I am running into permissions issues though. When I upload a file or try to install a plugin I get the cannot create in directory warning. So I came across the post Here that says I need to give nginx access to the folder. So I executed the following:
sudo chown -R www-data:www-data /path/to/folder
sudo chmod -R 755 /path/to/folder
This works except now I cannot add and delete files with filezilla. Obviously because the permissions to the folder are no longer with the me the user they are now with www-data.
So my question is what is the correct way to configure nginx to work with wordpress and still allow me to upload and delete files with ftp.
When using digital ocean droplets you will probably be using sftp access to your server.
Try the following commands in your terminal when logged in.
Add your currently logged in user to the www-data group:
sudo usermod -aG www-data $USER
Then change your vhost directory and all files and subdirectories to be owned by www-data group:
sudo chown -R www-data:www-data /var/www
Set the proper permissions so you can upload files via sftp, manage files via command-line, and upload plugins and media directly in WordPress:
sudo chmod -R 774 /var/www
Hope this helps
Saskia

How to give bitnami user edit permission on .htaccess for bitnami multisite ec2?

I have installed a Bitnami Multisite Wordpress AMI on my Amazon EC2 instance. to setup the Multiite Network I need to make changes in the .htaccess file.
I checked the permission on the file :
-rw-r--r-- 1 daemon daemon 235 Nov 29 12:15 .htaccess
I need the bitnami user to be able to edit the file. So first I did
getfacl .htaccess
# file: .htaccess
# owner: daemon
# group: daemon
user::rw-
group::r--
other::r--
I am logged in as bitnami user. So i used the command as below to give bitnami edit permissions.
sudo setfacl –m u:bitnami:rwx .htaccess
But I get the error as
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
Try `setfacl --help' for more information.
Need help to resolve the same.
Thanks
Bitnami Engineer here.
You can change the permissions of the .htaccess file by running this command
sudo chown bitnami:daemon .htaccess
sudo chmod g+w .htaccess
After running those commands, you can start to edit the file.
For security and performance reasons, we do not allow Apache to read the .htaccess files. For this reason, we moved the configuration in the .htaccess files to the main application configuration files and set the AllowOverride option to None by default.
You have two different options to start using .htaccess files:
- Edit the /opt/bitnami/apps/mediawiki/conf/htaccess.conf file and include the information of the .htaccess file inside a Directory block. You will find more information about this in this guide
https://docs.bitnami.com/aws/apps/wordpress-multisite/administration/use-htaccess/
Edit the /opt/bitnami/apps/wordpress/conf/httpd-app.conf file and change the AllowOverride option to All. After that, you will need to restart Apache
In both options, you will need to restart Apache after that:
sudo /opt/bitnami/ctlscript.sh restart apache

Wordpress on google cloud. I cant install a plugin or upload an image

I installed Wordpress to google cloud but when i want to install a plugin, it is asking for ftp credentials.
I added "define('FS_METHOD', 'direct');" to wp-config.php file.
I have to give right permission to folders.
What is the giving permission code line for gcloud ssh?
i solve the "insue" doing this
nano /var/www/html/wp-config.php
add the following line
define('FS_METHOD','direct');
then
sudo chown -R www-data.www-data /var/www/html
sudo chmod 755 /var/www/html
works for my on click to deploy intallation

Giving Wordpress permissions on LAMP - Ubuntu

I'm setting up lots of wordpress install on ubuntu. Digital Ocean suggest running these commands to grant Wordpress permissions in order to be able to update, download plugins etc:
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data linux_user_name
src: https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-wordpress-sites-on-a-single-ubuntu-vps
I've been running everything as the root user, and I'm concerned these commands are not the most secure way of doing this. Is there a better way, without having to run commands for every domain?
Many thanks.
Ideally you don't want to be doing everything as root as when Wordpress runs it won't be running as the root user on the Ubuntu box meaning that you'll probably run into problems when trying to install plugins and updates.
This is because the default Apache user will be www-data and is the user you should be using to setup folders and permissions in which to install and run Wordpress. If you are managing permissions for each domain, use www-data in the root folder i.e. public_html and the sub folders will be set to the www-data user. There are loads of good tutorials on digital ocean for just this, I'd try getting setup with www-data as you'll run into a lot less issues going forwards.

Resources