Moving the Apache DocumentRoot PDF Print E-mail
Friday, 03 July 2009 05:07

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.

 
Securing WordPress and cPanel PDF Print E-mail
Thursday, 02 July 2009 07:49

Here's some of the things I'm doing to reduce the chances of website ownage

  • Password protect WordPress wp-admin folder

Use "Password Protect Directories" under Security in cPanel. Sure, it's inconvenient to have to enter yet another password, but it might just save your bacon one day.

  • Turn off indexing

The first thing I saw when I browsed to my shiny new website was a directory listing, and that's just asking for trouble. Use Index Manager in cPanel to turn off directory listings for your entire site by selecting the Document Root and setting it to "No Indexes".

  • Install WordPress updates

Crackers, like all members of the rodent family, can squeeze through the tiniest hole. One of the easiest ways to find flaws in a system is to subscribe to patch announcements, which provides a handy list of vulnerabilities. If you don't keep up to date, then it's just a matter of time until you will be taught a lesson.

  • Make regular site backups

There's plenty of reasons why you should be doing backups of your site content yourself, so don't end up as a cautionary tale like AVSIM.

 
<< Start < Prev 11 12 13 14 15 16 17 Next > End >>

Page 17 of 17