When setting up a vanilla WordPress installation on a vanilla CentOS server with a vanilla Apache install, I kept getting 404 errors on pages and posts when Permalinks was set to anything other than the default.
I fixed it by editing Apache’s httpd.conf file to add the following in the website’s <VirtualHost> directive:
<Directory /www/vhosts/example.com/htdocs/> AllowOverride All </Directory>
The default set in the httpd.conf file is AllowOverride None, meaning the mod_rewrite wasn’t able to do its job.
If a section like that already exists, and that section contains AllowOverride None, simply change the “None” to “All.”
Be sure to search through the file to make sure there aren’t other configuration options entered in the file below the first one, which might be changing the setting back to “None.”
Once you’re done editing httpd.conf, restart Apache with:
sudo service httpd restart
That should do the trick!