- Edited
Hello everyone,
Today, I setup a new server using Debian and WordOps for my new website, everything is working smooth and I really like the Debian server, I think it's better than Ubuntu.
Here is how I set password to protect wp-admin folder. I searched on the forum and there isn't a tutorial so I write this.
sudo apt-get install apache2-utils
- Install the utilities to do the taskssudo mkdir /home/password
- Create the directory where password file storage.sudo htpasswd -c /home/password/.htpasswd theusername
(theusername is your username option, set any name you want). - Create the username and password.Enter your password
sudo nano /var/www/yoursite.com/conf/nginx/protectadmin.conf
- Create the config file for your domain.Copy the config content below into the file and save it.
location /wp-admin {
location ~ /wp-admin/admin-ajax.php$ {
include fastcgi_params;
fastcgi_pass php74;
}
location ~* /wp-admin/.*.php$ {
include fastcgi_params;
fastcgi_pass php74;satisfy any;
allow 127.0.0.1;
deny all;
auth_basic "Authorization Required";
auth_basic_user_file /home/password/.htpasswd;
}
}
If you're using php 7.3, you should change php74 to php73 from the config file above.
- sudo wo stack restart --nginx
That's all. Please correct me if you found any mistake.
Best regards,