After setting up all the instruction that Linode provided for a new web server (which were very good, by the way), downloading a new copy of WordPress files, and moving the MySQL database and images, I kept getting 404 Error Not Found.
The front page worked fine. The WordPress administration worked fine. And, when I would go set the Permalinks to being query for the Primary Key of the post, I would see the post.
This pointed to a problem with Apache and its rewrite function.
Apache recognizes special files that are used to configure the site (or an individual directory) called .htaccess files. Sometimes the problem with these files is that access permissions are not correct. Sometimes the system needs to have an extra line inserted at the top:
Options FollowSymLinks
or
Options +SumLinksIfOwnerMatch
WordPress requires the ability to write to the .htaccess file when the Permalink structure is changed. So, per multiple versions of instructions, I changed it to chmod 777 -- this grants full read-write privileges to anyone.
I wiped the file clean, and then hit the Permalink button. Wordpress wrote what it needed to just fine, but it was the same thing that had already been there. Not the problem. So, I set the chmod back without the writing privileges.
Someone suggested insert a line to cause a 500 Internal Server error -- to add the words "This is garbage" to the middle of the code. If the file was being recognized at all, there would be an error. If the file was not being recognized, nothing would happen. Nothing happened
.
So, I went back to the Apache config files of Linode.
I was installing a Ubuntu LAMP configuration, and there is a couple of things involved.
There is a main configuration file:
/etc/apache2/apache2.conf
There are also a couple of other files involved in configuration:
/etc/apache2/sites-enabled/
/etc/apache2/sites-available/MYSITENAME.conf
/etc/apache2/sites-available/000-default.conf
I had a problem with 000-default.conf earlier. It was the, duh, the default configuration, and when I would go to the IP address, I would get the 000-default.conf directory (which was /var/www). I had already disabled this default setup, so that wasn't the problem.
Someone suggested that I needed to fix the rewrite directive in the MYSITENAME.conf file.
But there wasn't anything in there that referred to rewrite or AllowOverride.
So, I turned to the apache2.conf
There I found the AllowOverride directives, but none of them had anything to do with MYSITENAME.
The first entry looked like this:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
I changed it to AllowOverride All, and it worked.
So, to restrict the level of access, I changed it back to None, and I added this code to the bottom of the virtual host configurations:
<Directory /PATH/TO/MYSITENAME/>
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
"/PATH/TO/MYSITENAME/" obviously should be changed to whatever the path is to your public website directory.
It works great now.
No comments :
Post a Comment