1

I want to set up multiple local Wordpress sites for test purposes. I tried the following instructions:

I tried to make sure that all permissions are right, but all I get when I try to open the URL returned by the setup-mysql script is a 403 error.

1 Answer 1

0

It seems that using the /srv/www directory caused problems for some reason. The following procedure eventually did the trick (on Ubuntu 14.04):

Install packages

sudo apt-get install wordpress mysql-server

(mysql-server is not automatically installed as a dependency of wordpress, so it has to be installed explicitly.)

Set up virtual host

Say I want to access one local wordpress site via http://xyz/. I create the file
/etc/apache2/sites-available/xyz.conf
with the following content:

<VirtualHost *:80>
        ServerName xyz
        UseCanonicalName Off
        VirtualDocumentRoot /usr/share/wordpress
        Options All

        # wp-content in /var/www/wp-content/$0
        RewriteEngine On
        RewriteRule ^/wp-content/(.*)$ /var/www/wp-content/%{HTTP_HOST}/$1
</VirtualHost>

(This is almost identical with what the Debian Wiki suggests, but with an added ServerName and /srv/www replaced by /var/www.)

Now I add an entry in /etc/hosts

127.0.1.2   xyz

(the last 2 could be replaced with a different number).

Now I enable the virtual host and some required modules:

sudo a2enmod rewrite
sudo a2enmod vhost_alias
sudo a2ensite xyz
sudo service apache2 restart

Set up Wordpress

The wordpress package comes with a script to set up a Wordpress instance and a dedicated database. However, it does so at /srv/www, which did not work for me. So I unpacked the script...

gzip -dc < /usr/share/doc/wordpress/examples/setup-mysql.gz > setup-mysql

and replaced /srv/www with /var/www:

sed -i 's/\/srv\/www/\/var\/www/g' setup-mysql

Now, I can run the modified script to set up the Wordpress instance:

sudo bash setup-mysql -n xyz_db xyz

where the first xyz_db will become the database name and xyz the URL and directory name. The latter should match the URL that was set up above, the database could be named anything else, but it's sensible to give it a name that makes clear it's associated with the URL.

Now the URL can be opened in the browser to start working with the Wordpress instance.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .