|
This article has been superseded by a new method I'm using to get Apache to execute web applications wherever I put them on my system.
Since I'm new to WordPress, I wanted to install a duplicate copy of my blog on my desktop machine to mess around with, somewhere I can change themes and generally try things out without annoying my millions of viewers.
As we're here to set up a place to install a local copy of WordPress, the additional components of the LAMP stack, MySQL and PHP, are going to be needed in addition to Apache. If you haven't installed everything already, then execute executing the following command in a terminal window to install the missing bits.
sudo apt-get install mysql-client mysql-server php5-mysql php5-mcrypt php5 libapache2-mod-php5 apache2
By default the document root for Apache will be in a folder called /var/www which is on the root partition. This means that any changes you make to your local websites have to be done as the super user, and that's a bad idea. Most of the guides I've seen for solving this issue simply move the Apache config files to point the document root at a folder under home, but since Apache uses the www-data user, you then need to grant "Others" access to your home folder, which I also think is a bad idea.
If you're reading this post having already moved your document root using another guide, granted "Others" access to it, and it's still giving you that annoying 403 error, it's likely that your home folder itself has permissions for "Others" set to "None". Higher level folders override the permission settings of sub-folders.
Before you continue, you should test your new web server by typing http://localhost in your browser's address bar and pressing enter. You don't want to continue until you can see that it's working. The first step for moving the document root is to create a www folder under home and put a test file in it for later.
mkdir ~/www echo 'Hello World!!' >> ~/www/index.html
Next, we need to remove the default document root and replace it with a symlink to the folder in home.
sudo rm -R /var/www sudo ln -s ~/www /var/www
Then, we need to tell Apache to run using your username so that it has access to the www folder in home, without needing to open home to all users. Once gedit opens, change all endurances of "www-data" to your login user name, then save it and close.
gksudo gedit /etc/apache2/envvars
Enable any modules you might need.
sudo a2enmod rewrite sudo a2enmod expires sudo a2enmod header
Finally restart Apache.
sudo apache2ctl restart
And that's it. You should now be able to open http://localhost and see the age-old programmer's greeting "Hello World!!". I've since written a second post showing you how to locally mirror your WordPress blog on your new web server.
|