RayRider
asked on
How to Make Wordpress One of Apache2's Virtual Hosts?
Maybe I am trying to do something that isn't possible. Please allow me to explain what environment I have, what I have done that works, and finally, what I wish to do that I cannot get to work.
I have Ubuntu server 14.04 LTS. I have installed LAMP. I have the Apache2 server working with the default server and two new virtual servers that work just great with both the domain name, with and without the "www" at the front. MySQL is working. I have configured a "wordpress user and database". I have created a wordpress configuration PHP file (wp-config.php) that contains the correct MySQL database, user and password.
When I added the Wordpress installation, I wasn't sure what to do with the virtual server configuration in /etc/apache2/sites-availab le. I have copied the 000-default.conf file to a file named wordpress.conf. Below is a paste of that configuration;
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
servername raymondrider.com
Serveralias www.raymondrider.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/wordpress
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.lo g
CustomLog ${APACHE_LOG_DIR}/access.l og combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-b in.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
My domain of raymondrider.com was just modified to point to the static ip of the router. Of course, it takes a few hours to update. In the meantime I have added these two domains to my Windows 7 "hosts" file in order to get a host referrer name to be sent to the Apache2 server. I pinged these two hosts and they indeed are routed to the IP address of the Apache2/Wordpress server.
After much time and many changes which I tried, I am unable to see the wordpress site. I am not sure how to get http requests over to the Wordpress virtual host. As far as I can tell, the Wordpress looks just like another virtual host site, and is configured similar to the other two working sites. I am missing something in my understanding.
Shouldn't I be able to get to the Wordpress site via my browser URL: http://www.raymondrider.com/wp-admin?
I have Ubuntu server 14.04 LTS. I have installed LAMP. I have the Apache2 server working with the default server and two new virtual servers that work just great with both the domain name, with and without the "www" at the front. MySQL is working. I have configured a "wordpress user and database". I have created a wordpress configuration PHP file (wp-config.php) that contains the correct MySQL database, user and password.
When I added the Wordpress installation, I wasn't sure what to do with the virtual server configuration in /etc/apache2/sites-availab
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
servername raymondrider.com
Serveralias www.raymondrider.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/wordpress
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.lo
CustomLog ${APACHE_LOG_DIR}/access.l
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-b
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
My domain of raymondrider.com was just modified to point to the static ip of the router. Of course, it takes a few hours to update. In the meantime I have added these two domains to my Windows 7 "hosts" file in order to get a host referrer name to be sent to the Apache2 server. I pinged these two hosts and they indeed are routed to the IP address of the Apache2/Wordpress server.
After much time and many changes which I tried, I am unable to see the wordpress site. I am not sure how to get http requests over to the Wordpress virtual host. As far as I can tell, the Wordpress looks just like another virtual host site, and is configured similar to the other two working sites. I am missing something in my understanding.
Shouldn't I be able to get to the Wordpress site via my browser URL: http://www.raymondrider.com/wp-admin?
I don't understand and I'm pretty sure you don't either. Wordpress is an application that you install in an existing virtual host / web site. There is no reason and maybe even no ability to install it as it's own virtual host.
ASKER
Maybe I'm using the wrong terminology. I see plenty of YouTube demos where one is installing WordPress on Apache2. I am not wishing WordPress to be a multiple site in itself, only another mechanism to create another site alongside other Apache2 sites on the same server. Are you saying that WordPress must totally consume a server?
I already had Apatche2 running for some time, and had interest in learning CMS systems like WordPress and Joomla. Of course, the simplest solution if I only wanted a WordPress site would be get a cheap GoDaddy site for $15/mo.
Am I making sense? Or, still have no clue?
I already had Apatche2 running for some time, and had interest in learning CMS systems like WordPress and Joomla. Of course, the simplest solution if I only wanted a WordPress site would be get a cheap GoDaddy site for $15/mo.
Am I making sense? Or, still have no clue?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dave:
Allow me to show my file structure. Maybe you can point out where I am wrong:
Here is my /etc/apache/sites-availabl e:
root@greece:/etc/apache2/s ites-avail able# ls -al
total 32
drwxr-xr-x 2 root root 4096 Nov 23 12:14 ./
drwxr-xr-x 8 root root 4096 Nov 15 20:12 ../
-rw-r--r-- 1 root root 1332 Jan 7 2014 000-default.conf
-rw-r--r-- 1 root root 1383 Nov 19 17:04 cissymccaa.com.conf
-rw-r--r-- 1 root root 6437 Jan 7 2014 default-ssl.conf
-rw-r--r-- 1 root root 1377 Nov 19 17:05 ridertek.com.conf
-rw-r--r-- 1 root root 1383 Nov 23 12:14 wordpress.conf
Verifying the symbolic links are there:
root@greece:/etc/apache2/s ites-enabl ed# ls -al
total 8
drwxr-xr-x 2 root root 4096 Nov 22 20:59 .
drwxr-xr-x 8 root root 4096 Nov 15 20:12 ..
lrwxrwxrwx 1 root root 35 Nov 15 13:50 000-default.conf -> ../sites-available/000-def ault.conf
lrwxrwxrwx 1 root root 38 Nov 19 15:18 cissymccaa.com.conf -> ../sites-available/cissymc caa.com.co nf
lrwxrwxrwx 1 root root 36 Nov 18 22:33 ridertek.com.conf -> ../sites-available/riderte k.com.conf
lrwxrwxrwx 1 root root 33 Nov 22 20:59 wordpress.conf -> ../sites-available/wordpre ss.conf
Here is my default site out of the box configuration (000-default.conf):
root@greece:/etc/apache2/s ites-avail able# cat 000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.lo g
CustomLog ${APACHE_LOG_DIR}/access.l og combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-b in.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Here is my Wordpress site configuration:
root@greece:/etc/apache2/s ites-avail able# cat wordpress.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
servername raymondrider.com
Serveralias www.raymondrider.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/wordpress
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.lo g
CustomLog ${APACHE_LOG_DIR}/access.l og combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-b in.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Here is the structure of /var/www:
root@greece:/var/www# ls -al
total 16
drwxr-xr-x 4 root root 4096 Nov 22 20:08 .
drwxr-xr-x 14 root root 4096 Nov 15 14:22 ..
drwxr-xr-x 4 www-data www-data 4096 Nov 18 10:21 html
drwxr-xr-x 5 www-data www-data 4096 Nov 22 20:23 wordpress
Here is the root html directory from 000-default.conf:
root@greece:/var/www# cd html
root@greece:/var/www/html# ls -al
total 32
drwxr-xr-x 4 www-data www-data 4096 Nov 18 10:21 .
drwxr-xr-x 4 root root 4096 Nov 22 20:08 ..
drwxr-xr-x 10 www-data www-data 4096 Nov 19 21:17 cissymccaa.com
-rw-r--r-- 1 www-data www-data 11510 Nov 15 13:50 index.html
drwxr-xr-x 8 www-data www-data 4096 Nov 18 22:14 ridertek.com
-rw-r--r-- 1 www-data www-data 21 Nov 17 19:35 test.php
Here are the contents of the wordpress directory:
root@greece:/var/www/html# cd ..
root@greece:/var/www# cd wordpress
root@greece:/var/www/wordp ress# ls -al
total 188
drwxr-xr-x 5 www-data www-data 4096 Nov 22 20:23 .
drwxr-xr-x 4 root root 4096 Nov 22 20:08 ..
-rw-r--r-- 1 www-data www-data 418 Sep 25 2013 index.php
-rw-r--r-- 1 www-data www-data 19930 Apr 9 2014 license.txt
-rw-r--r-- 1 www-data www-data 7194 Nov 20 16:32 readme.html
-rw-r--r-- 1 www-data www-data 4951 Aug 20 17:30 wp-activate.php
drwxr-xr-x 9 www-data www-data 4096 Nov 20 17:42 wp-admin
-rw-r--r-- 1 www-data www-data 271 Jan 8 2012 wp-blog-header.php
-rw-r--r-- 1 www-data www-data 4946 Jun 5 04:38 wp-comments-post.php
-rw-r--r-- 1 www-data www-data 2732 Nov 22 20:23 wp-config.php
-rw-r--r-- 1 www-data www-data 2746 Aug 26 19:59 wp-config-sample.php
drwxr-xr-x 4 www-data www-data 4096 Nov 20 17:42 wp-content
-rw-r--r-- 1 www-data www-data 2956 May 13 2014 wp-cron.php
drwxr-xr-x 12 www-data www-data 4096 Nov 20 17:42 wp-includes
-rw-r--r-- 1 www-data www-data 2380 Oct 24 2013 wp-links-opml.php
-rw-r--r-- 1 www-data www-data 2714 Jul 7 16:42 wp-load.php
-rw-r--r-- 1 www-data www-data 33229 Nov 20 12:23 wp-login.php
-rw-r--r-- 1 www-data www-data 8252 Jul 17 09:12 wp-mail.php
-rw-r--r-- 1 www-data www-data 11115 Jul 18 09:13 wp-settings.php
-rw-r--r-- 1 www-data www-data 26256 Jul 17 09:12 wp-signup.php
-rw-r--r-- 1 www-data www-data 4026 Oct 24 2013 wp-trackback.php
-rw-r--r-- 1 www-data www-data 3032 Feb 9 2014 xmlrpc.php
I can see the default Apache2 demo site when I point a browser to machine's IP address
Since /var/www/html is the directory for the default site and my virtual sites, maybe I should move wordpress under /var/www/html. Just a thought.
Allow me to show my file structure. Maybe you can point out where I am wrong:
Here is my /etc/apache/sites-availabl
root@greece:/etc/apache2/s
total 32
drwxr-xr-x 2 root root 4096 Nov 23 12:14 ./
drwxr-xr-x 8 root root 4096 Nov 15 20:12 ../
-rw-r--r-- 1 root root 1332 Jan 7 2014 000-default.conf
-rw-r--r-- 1 root root 1383 Nov 19 17:04 cissymccaa.com.conf
-rw-r--r-- 1 root root 6437 Jan 7 2014 default-ssl.conf
-rw-r--r-- 1 root root 1377 Nov 19 17:05 ridertek.com.conf
-rw-r--r-- 1 root root 1383 Nov 23 12:14 wordpress.conf
Verifying the symbolic links are there:
root@greece:/etc/apache2/s
total 8
drwxr-xr-x 2 root root 4096 Nov 22 20:59 .
drwxr-xr-x 8 root root 4096 Nov 15 20:12 ..
lrwxrwxrwx 1 root root 35 Nov 15 13:50 000-default.conf -> ../sites-available/000-def
lrwxrwxrwx 1 root root 38 Nov 19 15:18 cissymccaa.com.conf -> ../sites-available/cissymc
lrwxrwxrwx 1 root root 36 Nov 18 22:33 ridertek.com.conf -> ../sites-available/riderte
lrwxrwxrwx 1 root root 33 Nov 22 20:59 wordpress.conf -> ../sites-available/wordpre
Here is my default site out of the box configuration (000-default.conf):
root@greece:/etc/apache2/s
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.lo
CustomLog ${APACHE_LOG_DIR}/access.l
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-b
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Here is my Wordpress site configuration:
root@greece:/etc/apache2/s
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
servername raymondrider.com
Serveralias www.raymondrider.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/wordpress
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.lo
CustomLog ${APACHE_LOG_DIR}/access.l
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-b
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Here is the structure of /var/www:
root@greece:/var/www# ls -al
total 16
drwxr-xr-x 4 root root 4096 Nov 22 20:08 .
drwxr-xr-x 14 root root 4096 Nov 15 14:22 ..
drwxr-xr-x 4 www-data www-data 4096 Nov 18 10:21 html
drwxr-xr-x 5 www-data www-data 4096 Nov 22 20:23 wordpress
Here is the root html directory from 000-default.conf:
root@greece:/var/www# cd html
root@greece:/var/www/html#
total 32
drwxr-xr-x 4 www-data www-data 4096 Nov 18 10:21 .
drwxr-xr-x 4 root root 4096 Nov 22 20:08 ..
drwxr-xr-x 10 www-data www-data 4096 Nov 19 21:17 cissymccaa.com
-rw-r--r-- 1 www-data www-data 11510 Nov 15 13:50 index.html
drwxr-xr-x 8 www-data www-data 4096 Nov 18 22:14 ridertek.com
-rw-r--r-- 1 www-data www-data 21 Nov 17 19:35 test.php
Here are the contents of the wordpress directory:
root@greece:/var/www/html#
root@greece:/var/www# cd wordpress
root@greece:/var/www/wordp
total 188
drwxr-xr-x 5 www-data www-data 4096 Nov 22 20:23 .
drwxr-xr-x 4 root root 4096 Nov 22 20:08 ..
-rw-r--r-- 1 www-data www-data 418 Sep 25 2013 index.php
-rw-r--r-- 1 www-data www-data 19930 Apr 9 2014 license.txt
-rw-r--r-- 1 www-data www-data 7194 Nov 20 16:32 readme.html
-rw-r--r-- 1 www-data www-data 4951 Aug 20 17:30 wp-activate.php
drwxr-xr-x 9 www-data www-data 4096 Nov 20 17:42 wp-admin
-rw-r--r-- 1 www-data www-data 271 Jan 8 2012 wp-blog-header.php
-rw-r--r-- 1 www-data www-data 4946 Jun 5 04:38 wp-comments-post.php
-rw-r--r-- 1 www-data www-data 2732 Nov 22 20:23 wp-config.php
-rw-r--r-- 1 www-data www-data 2746 Aug 26 19:59 wp-config-sample.php
drwxr-xr-x 4 www-data www-data 4096 Nov 20 17:42 wp-content
-rw-r--r-- 1 www-data www-data 2956 May 13 2014 wp-cron.php
drwxr-xr-x 12 www-data www-data 4096 Nov 20 17:42 wp-includes
-rw-r--r-- 1 www-data www-data 2380 Oct 24 2013 wp-links-opml.php
-rw-r--r-- 1 www-data www-data 2714 Jul 7 16:42 wp-load.php
-rw-r--r-- 1 www-data www-data 33229 Nov 20 12:23 wp-login.php
-rw-r--r-- 1 www-data www-data 8252 Jul 17 09:12 wp-mail.php
-rw-r--r-- 1 www-data www-data 11115 Jul 18 09:13 wp-settings.php
-rw-r--r-- 1 www-data www-data 26256 Jul 17 09:12 wp-signup.php
-rw-r--r-- 1 www-data www-data 4026 Oct 24 2013 wp-trackback.php
-rw-r--r-- 1 www-data www-data 3032 Feb 9 2014 xmlrpc.php
I can see the default Apache2 demo site when I point a browser to machine's IP address
Since /var/www/html is the directory for the default site and my virtual sites, maybe I should move wordpress under /var/www/html. Just a thought.
ASKER
Oops! I see a problem that may be causing my Wordpress to fail. I have placed the Wordpress "documentroot" under /var/www/html instead of under /var/www. Let me change that to see what happens.
If you moved Wordpress to /var/www/html then it would take over the default site.
There are two ways for Apache to set up or use 'virtual hosts'. One is 'IP based' where each site has it's own IP address which is what I have used. The other is 'name based' virtual hosts. <VirtualHost *:80> implies that you are using 'name based' virtual hosts because there is no IP address assigned. More info here: http://httpd.apache.org/docs/2.2/vhosts/name-based.html Note that you may have to add the 'domain names' you have created to the etc/hosts file on that and other machines for them to be recognized.
There are two ways for Apache to set up or use 'virtual hosts'. One is 'IP based' where each site has it's own IP address which is what I have used. The other is 'name based' virtual hosts. <VirtualHost *:80> implies that you are using 'name based' virtual hosts because there is no IP address assigned. More info here: http://httpd.apache.org/docs/2.2/vhosts/name-based.html Note that you may have to add the 'domain names' you have created to the etc/hosts file on that and other machines for them to be recognized.
ASKER
Dave:
That little slip up has cost me lots of time, plus the bother to you and others. I see the site now as it brought up the Wordpress configuration and setup page. Hard headed people such as I deserve the pain, albeit the pleasure of success.
Thanks a million for the suggestions.
That little slip up has cost me lots of time, plus the bother to you and others. I see the site now as it brought up the Wordpress configuration and setup page. Hard headed people such as I deserve the pain, albeit the pleasure of success.
Thanks a million for the suggestions.
ASKER
Dave:
One last comment:
All my virtual sites are working with and without "www". The "as shipped" Apache2 demo default site works with IP address to localhost. And, the Wordpress site works with the new domain name pointed to the wordpress directory.
Thanks again@@
One last comment:
All my virtual sites are working with and without "www". The "as shipped" Apache2 demo default site works with IP address to localhost. And, the Wordpress site works with the new domain name pointed to the wordpress directory.
Thanks again@@
You're welcome, glad to help.