lacee1986
6/17/2019 - 3:31 PM

Create nginx user

Create a new user for nginx and set the permissions.

Add nginx user in shell

sudo /usr/sbin/usermod -s /bin/bash nginx

Set password to user nginx

sudo passwd nginx

Stop all services

sudo service nginx stop
sudo service php-fpm stop

Add a home directory

sudo /usr/sbin/usermod -d /var/www/html nginx

Start all services

sudo service nginx start
sudo service php-fpm start

Enable SSH to nginx user

sudo mkdir /var/www/html/.ssh
sudo cp /home/ec2-user/.ssh/authorized_keys /var/www/html/.ssh/
sudo chown -R nginx:nginx /var/www/html/.ssh/

SSH configuration to allow password authentication

sudo vi /etc/ssh/sshd_config

The PasswordAuthenticat option will be marked as no, change to yes

PasswordAuthentication yes

Restart SSH service

sudo service sshd restart

Set permission

sudo chown -R nginx:nginx /var/www/html
sudo chmod -R 755 /var/www/html