How to solve page not found error when using permalinks for wordpress

I got the page not found error when I use the pretty permalinks of wordpress.

Here is how I solved the problem after several round searches using search engines.

  1. make sure you have the write permission of /var/www/html/ folder
  2. sudo a2enmod rewrite
  3. edit the file /etc/apache2/apache2.conf (here we have an example of /var/www/html):

and change it to;

then,

Most people can solve the page not found error after step 3, but I got internal server error.

check the log:

cat /var/log/apache2/error.log,

I found: Invalid command ‘AuthGroupFile’, perhaps misspelled or defined by a module not included in the server configuration.

Then use: