I have been trying and Googling all week to get wordpress up and running on an Apache2 virtual host. It serves the Apache default page when I type localhost in the browser but when I type in localhost/wordpress, no luck!

I have followed tutorials from all over the web to no avail... I have done '#a2ensite wordpress' and various other commands. One of the tutorials said to change all the permissions recursively in /var/www to www-data. Is this correct?

Any help would be appreciated. Thanks!

Here are some configs:

justin@justin-HP-Ubuntu:~$ apache2 -v Server version: Apache/2.4.7 (Ubuntu) Server built: Mar 10 2015 13:05:59

justin@justin-HP-Ubuntu:~$ cat /etc/apache2/sites-enabled/wordpress.conf

ServerAdmin webmaster@localhost
ServerName wordpress.com
DocumentRoot /var/www/wordpress
ServerAlias www.wordpress.com
ServerAlias wordpress
ServerAlias wordpress.com
ServerAlias cikelectricians.com.au
ServerAlias www.cikelectricians.com.au

Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

justin@justin-HP-Ubuntu:~$ ls -l /etc/apache2/sites-enabled total 0 lrwxrwxrwx 1 root root 35 May 20 20:39 000-default.conf -> ../sites-available/000-default.conf lrwxrwxrwx 1 root root 33 May 25 12:22 wordpress.conf -> ../sites-available/wordpress.conf

justin@justin-HP-Ubuntu:~$ ls -l /var/www total 4 drwxr-xr-x 2 www-data www-data 23 May 27 20:54 html drwxr-xr-x 5 www-data www-data 4096 Jun 2 18:25 wordpress

/var/www/wordpress/wp-config.php extract:

// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpress');

/** MySQL database username */ define('DB_USER', 'justin');

/** MySQL database password */ define('DB_PASSWORD', 'password');

/** MySQL hostname */ define('DB_HOST', 'localhost');

Regards, Justin

  • I've got to ask, what is the reason for such a complicated set up? Give me a minute and I'll write something up for you – heypaleblue Jun 3 '15 at 6:30

Alright Let's being First check your default configuration for apache to make sure that your apache server is looking for your website in /var/www

cd /etc/apache2/sites-enabled/
nano 000-default

inside this file checkc that the default virtual host's DocumentRoot points to /var/www. then create a virtual host declaration like the following.

<VirtualHost *:80>
DocumentRoot /var/www/wordpress1
ServerAlias www.yourdomainname.co.au

Save the file and reload Apache with

sudo service apache2 restart

once this is done:

cd /var/www
mkdir wordpress1
cd wordpress
wget https://wordpress.org/latest.tar.gz
tar -xf latest.tar.gz
mv wordpress/* /var/www/wordpress1
mv .htaccess /var/www/wordpress1
cp wordpress1/ wordpress/
chmod -R 775 /var/www/wordpress && chown root:www-data /www/data/wordpress

Now we're going to back into apaches config files to make the virtual host declaration match our folder structure:

cd /etc/apache2/sites-enabled/
nano 000-default

now change your wordpress delcaration to look like the following:

<VirtualHost *:80>
DocumentRoot /var/www/wordpress
ServerAlias www.yourdomainname.co.au

Save the file and reload Apache

 sudo service apache2 restart

No go into SQL and create a database for your wordpress installation

 mysql -u root -p

"Query okay blah rows affected"



Now also long as your virtual machine is configured properly to talk with your host machine you should be able to access it by typing in your loopback address Usually your do this by choosing a bridged adapter setting for the virutal machine.

you should also make sure that php5 and php5-mysql are installed as well. you can install these with:

 sudo apt-get install php5 php5-mysql

hope this helps.

  • Hi heypaleblue. Thanks for your reply and I would like to apologise for my late reply. I have been inundated by tasks. – Justin Wilson Jun 7 '15 at 0:03
  • It's all good, just let me know if it works. Usually if you install an os into a VM with the network adapter set to bridged you can type in and it will come up just like that – heypaleblue Jun 7 '15 at 0:10
  • I would also like to apologise in advance for the poor presentation of this comment as I do not know markdown....<br/>As per your instructions:<br/>It is very similar to the tutorials I have tried, but I followed the instructions verbatim (copy & paste)- but no luck!!! When I specify localhhost in firefox, it comes up with the default apache page, but when I specify or it says "Page Not Found"... I really am at a loss of what to do.. – Justin Wilson Jun 7 '15 at 8:25
  • I did try the way that you suggested, that is, as an IP based web server, editing the /etc/apache2/000-default.conf... but I couldn't get a start. I will have to try it on a VM, I would love to get this working so I can get away from GoDaddy and roll my own web server. I tell you, I have followed every tutorial multiple times. <br/> Thanks for your help @heypaleblue , any help is much appreciated. Cheers! – Justin Wilson Jun 7 '15 at 8:34
  • Well my thought that the VM should be running on, I cant stress this enough go back into /etc/apache2/sites-enabled/000-default and check the FIRST virtual host declaration. My grilfriend ran into a issue where apache was directing web traffic to /var/www/html and that could be your problem. but seeing as you can get to the apache page that leads me to believe your VM is working, we just need to troubleshoot apache. Can you please confirm that apache is configure to have a "Web roo" of /var/www that way when you specify localhost/wordpress it should find the folder. – heypaleblue Jun 7 '15 at 8:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.