Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Help setting up a local domain with working override |
|
Author |
|
jasontheadams
Joined: 09 Feb 2014 Posts: 9 Location: United States, Detroit
|
Posted: Tue 25 Feb '14 22:02 Post subject: Help setting up a local domain with working override |
|
|
I've been fighting this for many hours now, and I'm very frustrated. Apache just doesn't make sense to me; I'd greatly appreciate any advice. Please read through what I've written, as I've read through dozens of posts and manuals on the subject, and really need specific advice.
I'm trying to accomplish two goals: First, get "Pretty Links" to work on my local Wordpress instance; second, to set up a local domain for the site.
I have a fresh install of Apache 2.4.6 running, and I'll I've done is enable the rewrite and vhost_alias mods. Nevertheless, here's my apache2.conf: http://pastebin.com/Vag8N1QA
For the first goal, I understand I need to have AllowOverride set to All. This, I gather, allows .htaccess files within the subsequent directories to alter the apache config. To try one thing at a time, I'm accessing the site from localhost/var/www/dhae/Wordpress (foregoing the domain). I tried altering the 000-default.conf to oblige this: http://pastebin.com/PwMGF9F2 -- all I added was the <Directory> section. This didn't work, and neither did changing the AllowOverride to All in the apache2.conf.
I wondered if perhaps I needed something more specific to the directory, so I tried using my second goal to accomplish this. I wrote the dhae.conf: http://pastebin.com/trwWVFLW
I've also added the following line to my HOSTS file:
127.0.0.1 dhae.dev
This hasn't worked either. I've tried virtual host config stuff as much as I could find, and I'm just not having any luck. What I have even came from this site (http://www.apachelounge.com/viewtopic.php?p=24139). I'm really at a loss, and I need this to work (especially my first goal), so I can continue my normal work. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Wed 26 Feb '14 17:41 Post subject: |
|
|
With apache 2.4 there is no Order Allow,Deny Allow from stuff
there is now Require
Since I do not like .htaccess cause it sucks a bit performance I putted the htaccess rewriting into the server config.
The vhost config http://pastebin.com/3vvqGxd3
Since it seems you run a debian or debian based linux sytem, make sure that you put that config file into /etc/apache2/mods-available and create a symlink into /etc/apache2/mods-enabled |
|
Back to top |
|
jasontheadams
Joined: 09 Feb 2014 Posts: 9 Location: United States, Detroit
|
Posted: Wed 26 Feb '14 18:28 Post subject: |
|
|
Hi James! Thanks for the config!
Unfortunately, I have two issues with it: First, for now I think I should let Wordpress do it's thing and go the .htaccess route. As I get more comfortable with all this stuff, I'll look into optimizing.
Second, for some reason when I go to dhae.dev it just takes me to /var/www instead of /var/www/dhae/wordpress. It seems dhae is going to 127.0.0.1, but apache isn't routing the domain properly.
Much appreciated! |
|
Back to top |
|
Anaksunaman
Joined: 19 Dec 2013 Posts: 54
|
Posted: Thu 27 Feb '14 8:23 Post subject: Help setting up a local domain with working override |
|
|
Based on your previous post, it sounds like you likely still do not have a working virtual hosts config. From the apache2.conf you posted, it sure looks like you are running Ubuntu. If this is the case, here is the official documentation for setting up Apache, including virtual hosts:
https://help.ubuntu.com/community/ApacheMySQLPHP#Virtual_Hosts
This walks you step-by-step through setting up a virtual host. Since you may not need everything in the link above, a couple points:
* Make sure dhae.conf is placed in /sites-available.
* To disable the default site and enable your site you can use:
Code: | $ sudo a2dissite default && sudo a2ensite dhae
$ sudo /etc/init.d/apache2 restart |
If you do not wish to disable the default site (000-default.conf) just leave off the 'sudo a2dissite default &&' -- so the commands become:
Code: | $ sudo a2ensite dhae
$ sudo /etc/init.d/apache2 restart |
The command 'sudo a2ensite dhae' takes the name of the dhae.conf file and creates the appropriate symlinks from /sites-available to /sites-enabled, which is necessary for Apache to recognize the virtual host. |
|
Back to top |
|
Anaksunaman
Joined: 19 Dec 2013 Posts: 54
|
Posted: Thu 27 Feb '14 8:36 Post subject: Help setting up a local domain with working override |
|
|
Also, per comments about the changes from Apache 2.2. to 2.4, I would use this as the basis for dhae.conf:
Code: |
<VirtualHost *:80>
ServerName dhae.dev
ServerAlias www.dhae.dev
DocumentRoot /var/www/dhae/wordpress
<Directory /var/www/dhae/wordpress>
Options Indexes FollowSymLinks Includes
Require all granted
AllowOverride All
</Directory>
ErrorLog /var/log/apache2/dhae-error.log
</VirtualHost> |
Note that I have also left out 'NameVirtualHost *:80' at the top. This should not be required in Apache 2.4. If it causes any issues, however, feel free to re-add it.
Last edited by Anaksunaman on Fri 28 Feb '14 10:58; edited 2 times in total |
|
Back to top |
|
jasontheadams
Joined: 09 Feb 2014 Posts: 9 Location: United States, Detroit
|
Posted: Thu 27 Feb '14 16:45 Post subject: |
|
|
Hi Anaksunaman!
I'll give this a shot, but I had a quick question for clarity: You said you left out "NameVirtualHost", but it's still at the top of the code you posted. Did you mean to remove that?
Also, I notice in the directions is directs to put the site in ~/public_html, but I don't have such a folder; I've just been putting things in /var/www/. Is that an issue?
Thanks! |
|
Back to top |
|
jasontheadams
Joined: 09 Feb 2014 Posts: 9 Location: United States, Detroit
|
Posted: Thu 27 Feb '14 17:15 Post subject: |
|
|
I figured it out!
There was absolutely nothing wrong with my configuration.. it was how I was restarting Apache. Oops!
There's a serious difference between 'service apache2 restart' and 'sudo etc/init.d/apache2 restart'. Apparently only the latter actually prompts apache to re-cache the config files!
I saw that in the link you provided, Anaksunaman, tried it, and it's working like a charm, now.
Thanks! |
|
Back to top |
|
Anaksunaman
Joined: 19 Dec 2013 Posts: 54
|
Posted: Fri 28 Feb '14 10:57 Post subject: |
|
|
jasontheadams wrote: |
[...]I had a quick question for clarity: You said you left out "NameVirtualHost", but it's still at the top of the code you posted. Did you mean to remove that? |
Whoops! There was supposed to be a # to comment it out. Changed that, thanks!
FYI, the only reason I like to comment things out is that sometimes it is easier than retyping. In this case, though, Apache 2.4 doesn't require this statement any more, so unless you encounter some odd errors, feel free to completely remove the line.
Quote: | Also, I notice in the directions is directs to put the site in ~/public_html, but I don't have such a folder; I've just been putting things in /var/www/. Is that an issue? |
As long as this the root folder for your Apache server, it isn't a problem. /var/www/ and /public_html are both widely used conventions.
Quote: | I figured it out!
There was absolutely nothing wrong with my configuration.. it was how I was restarting Apache. Oops!
|
Yep, this makes a difference.
You're are very welcome. I'm just glad you got things working. |
|
Back to top |
|
|
|
|
|
|