创建.htaccess文件:
创建密码:
htpasswd -c .htpasswd username
根据提示输入密码。-c 用于创建.htpasswd文件,之后添加密码使用
htpasswd .htpasswd username
如果不成功,很有可能需要修改AllowOverride选项为All。AllowOverride可能在/etc/apache2/httpd.conf, /etc/apache2/apache2.conf或/etc/apache2/sites-available/default中找到。