✓ Solved

How do I access apache2 conf files when apache2 is not in /etc?

I am trying to set up a redirect from one domain to my root domain. I read how to do this using apache config files, and I have always been able to do this in the past. However, when I go in the /etc directory there is no apache2 directory. Apache2 is installed, running, and serving the website, but I have no idea where the config files are. Has anybody else ran into this issue? I used the Ubuntu 20.04 lamp stack guide when I initially configured the web server. I could instead use a .htacces file to do the redirect, but I can't find that either since it is a hidden file. The site uses wordpress. If anyone could tell me where the .htaccess file should be that would probably suffice for now.

7 Replies

✓ Best Answer

This will probably help you out:

sudo apachectl -t -D DUMP_INCLUDES

This shows all included configuration files in a tree (with line numbers about where they are included). It gives the full path for each.

-- sw

A couple of points, here.

  1. Hidden files aren't really "hidden," ls just omits them by default. ls -a will show them, find can find them, etc.

  2. If you're lacking an /etc/apache2 directory, the installation of apache2 has failed, or something happened after install. I can't tell you how it failed, but I can tell you that something is wrong. I would start over from square one.

If you're lacking an /etc/apache2 directory, the installation of apache2 has failed, or something happened after install. I can't tell you how it failed, but I can tell you that something is wrong. I would start over from square one.

Not necessarily. There's no requirement that apache2 config files live in /etc/apache2…only convention. If you install apache2 from source or the automated installer the OP used decided they needed to go elsewhere, that's probably where they are.

-- sw

stevewi thank you for your help. I tried the command that you suggested and it said that the files are all where I thought they were, in /etc/apache2. This seems strange since I cannot find this directory.

I found the .htaccess for the site. Can I redirect a domain http://example1.com to http://example2.com in the .htaccess file without editing apache2 config files?

So I decided to just try opening the config file with vim using the full path name and it worked even the I cannot access the parent directory. Do you think I should still start from scratch?

What are the permissions/ownership on /etc/apache2?

cd /etc
sudo ls -la | grep apache2

-- sw

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct