2

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 
<VirtualHost *:80>



    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
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/wordpress>
    Options Indexes FollowSymLinks MultiViews
AllowOverride All
    Order allow,deny
    allow from all
</Directory>


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


</VirtualHost>

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');
  • 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
3

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
</VirtualHost>

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
</VirtualHost>

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
 CREATE DATABASE wordpress;

"Query okay blah rows affected"

 EXIT;

"Bye."

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 127.0.0.1/wordpress. 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.

| improve this answer | |
  • 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 127.0.0.1 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 127.0.0.1/wordpress or 172.16.2.18/wordpress 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 127.0.0.1, 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
0

This seems to be a continued issue due to version updates not being compatible with online tutorials which will now be superceeded in some areas.

I landed on page searching for a fix for my problem which was that I was unable to "point" my the server to my wordpress. Note that I was able to confirm server was working (displays apache welcome when entering url/ip) and able to both install and config my wordpress (updating welcome page themes etc) however when entering the IP/URL I still saw my apache welcome page. As both the server and wordpress were working in isolation, I established my server was not pointing to my desired wordpress page.

Note that I am using Apache as web server. The site (homepage) is served from a file in the server directory. So we need to amend configurations explained below.

From root user you can try this cd /etc/apache2/sites-enabled Now if you do ls, this should confirm what file you have within this directory. Hopefully a file such as 000-default.conf. Now we need to get into this file to amend the configure the "pointer". Now sudo nano 000-default.conf Upon pressing enter, it should pop up with a config file, code starting with etc. Notice in black writting it has 2 lines of code, server admin which we leave as "webmaster@localhost". But the 2nd line is the root of our fix. We need to amend this which tells the server the source of the content being requested when entering/landing the home page. (There has been an update to raspian jessie whereby there is now an added line of code causing issues with people following other online tutorials/videos using an older version). Change document root, which in my case was from /var/www/html to /var/www/html/index.html then Ctrl X, press y, and enter.

Reload website homepage and you should see the wordpress page!

Note that methods will vary and my explanation is on the basis all other config has been completed correctly i.e. database linked to wordpress etc.

My setup involved a Raspberry pi 3, Apache server, PHP V 7.1, mySQL Mariadb and of course Wordpress latest version as March 2020.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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