# Change location problem



## Nicat (Oct 14, 2022)

Hi there. Did anyone move the location of apache24 files in freebsd? I did this, but the httpd.conf file 
works on default location. What should I do? Sorry for my bad english:/


----------



## Alain De Vos (Oct 14, 2022)

Configuration stayed,remained in "/usr/local/etc/apache24/"
The server is the file "/usr/local/sbin/httpd"
The configuration details from which location you serve your files.


----------



## im (Oct 14, 2022)

You can specify another path to the config file
Try to edit your /etc/rc.conf

```
apache24_enable="YES"
apache24_flags=" -f /path/to/httpd.conf "
```

If you want to have more information then read:
1) /usr/local/etc/rc.d/apache24 - this is a startup script of Apache
2) Apache's httpd manual page httpd()


----------



## Nicat (Oct 15, 2022)

I edited /etc/rc.conf:
apache24_flags=" -f /home/etc/apache24/to/httpd.conf "
and
then like this: 
apache24_flags=" -f /home/apache24/httpd.conf "
I restarted apache service, then new error occurred(but server worked):

service apache24 restart
/etc/rc.conf: apache24_flags: not found
/etc/rc.conf: apache24_flags: not found
Performing sanity check on apache24 configuration:
Syntax OK
Stopping apache24.
Waiting for PIDS: 1144.
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.



im said:


> You can specify another path to the config file
> Try to edit your /etc/rc.conf
> 
> ```
> ...


----------



## Nicat (Oct 15, 2022)

Alain De Vos said:


> Configuration stayed,remained in "/usr/local/etc/apache24/"
> The server is the file "/usr/local/sbin/httpd"
> The configuration details from which location you serve your files.


I created /home directory. And then /home/www  /home/etc  /home/libexec. I can change html code.But httpd.conf does not works in /home/etc/apache24 (works in /usr/local/etc/apache24/).
What should I do?
Shoul I copy /usr/local/sbin/httpd to /home/sbin ?


----------



## Alain De Vos (Oct 15, 2022)

Maybe you have configured too much. Normally never a copy of something is needed. Maybe try to remove some configuration.


----------



## im (Oct 16, 2022)

I tried to build a clean environment with apache24,
and tried to run apache with httpd.conf in non-default location.

I have moved httpd.conf,
have added to the rc.conf

```
apache24_enable="yes"
apache24_flags=" -f /home/etc/httpd.conf"
```
Also I have changed a line in a rc.d script /usr/local/etc/rc.d/apache24

```
required_files=/home/etc/httpd.conf
```

In my opinion, it works!

```
root@testjail:/home/backup # /usr/local/etc/rc.d/apache24 restart
Starting apache24.
AH00557: httpd: apr_sockaddr_info_get() failed for testjail.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
root@testjail:/home/backup # ps -auxww | grep httpd
root 21018  0.0  0.1 17284 6004  -  SsJ  13:27   0:00.03 /usr/local/sbin/httpd -f /home/etc/httpd.conf -DNOHTTPACCEPT
www  21019  0.0  0.1 17284 5892  -  SJ   13:27   0:00.01 /usr/local/sbin/httpd -f /home/etc/httpd.conf -DNOHTTPACCEPT
www  21020  0.0  0.1 17284 5892  -  SJ   13:27   0:00.00 /usr/local/sbin/httpd -f /home/etc/httpd.conf -DNOHTTPACCEPT
www  21021  0.0  0.1 17284 5892  -  SJ   13:27   0:00.01 /usr/local/sbin/httpd -f /home/etc/httpd.conf -DNOHTTPACCEPT
www  21022  0.0  0.1 17284 5892  -  SJ   13:27   0:00.00 /usr/local/sbin/httpd -f /home/etc/httpd.conf -DNOHTTPACCEPT
www  21023  0.0  0.1 17284 5892  -  SJ   13:27   0:00.00 /usr/local/sbin/httpd -f /home/etc/httpd.conf -DNOHTTPACCEPT
```

But if you like to run commands like `httpd -t` and `httpd -S` then add to the end of this command the line:
 "-f /home/etc/httpd.conf"


Spoiler: example



root@testjail:/home/backup # httpd -S
httpd: Could not open configuration file /usr/local/etc/apache24/httpd.conf: No such file or directory
root@testjail:/home/backup # httpd -S -f /home/etc/httpd.conf
AH00557: httpd: apr_sockaddr_info_get() failed for testjail.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
ServerRoot: "/usr/local"
Main DocumentRoot: "/usr/local/www/apache24/data"
Main ErrorLog: "/var/log/httpd-error.log"
Mutex default: dir="/var/run/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/var/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www" id=80
Group: name="www" id=80



P.S.
Can you describe a reason for running apache with non-standart location?
In my opinion you are going to have misconfigured and heavy-upgradable configuration.
I think, running an apache with a minimal set of system files and libraries as a "freebsd jail" may be a better solution for the most cases;


----------



## Nicat (Oct 21, 2022)

thanks, but it does not work for me. Now I can not change anything on httpd.conf(in both places: /usr/local/etc/apache24/httpd.conf and /home/etc/apache24/httpd.conf. For example: location of index.html).
I started apache service, then new error occurred(but server worked):


----------



## Nicat (Oct 21, 2022)

im said:


> I tried to build a clean environment with apache24,
> and tried to run apache with httpd.conf in non-default location.
> 
> I have moved httpd.conf,
> ...


what should i do to use "freebsd jail"?


----------



## Nicat (Oct 21, 2022)

im said:


> I tried to build a clean environment with apache24,
> and tried to run apache with httpd.conf in non-default location.
> 
> I have moved httpd.conf,
> ...


Is your server running normally? Can you tell me what it's doing from beginning to end?


----------



## SirDice (Oct 21, 2022)

Please don't post _pictures_ of _text_. That makes it impossible for us to quote or copy/paste from it. 

`apr_sockaddr_info_get() failed for host` is likely due to not having the correct hostname and IP in the /etc/hosts file or in DNS. 



Nicat said:


> what should i do to use "freebsd jail"?











						Chapter 16. Jails
					

Jails improve on the concept of the traditional chroot environment in several ways




					docs.freebsd.org
				




Go back to the beginning:


Nicat said:


> Did anyone move the location of apache24 files in freebsd? I did this, but the httpd.conf file
> works on default location. What should I do?


What are you trying to do here? Why are you putting httpd.conf somewhere else? Just leave it at its default location; /usr/local/etc/apache24/httpd.conf.

Prevent an XY problem and tell us exactly what you're trying to accomplish.


----------



## Alain De Vos (Oct 21, 2022)

Why change the location of httpd.conf is very unclear to me.
Note : You can run apache on a different port in a jail. The httpd.conf is relative to the location of the jail.


----------



## Nicat (Oct 22, 2022)

SirDice said:


> Please don't post _pictures_ of _text_. That makes it impossible for us to quote or copy/paste from it.
> 
> `apr_sockaddr_info_get() failed for host` is likely due to not having the correct hostname and IP in the /etc/hosts file or in DNS.
> 
> ...


I am sorry.This is an assignment. But I could not solve this. Thanks for "https://docs.freebsd.org/en/books/handbook/jails/[/URL]"


----------

