# Apache22 will not start after pkg upgrade



## ProServ (Nov 29, 2016)

Hi, ran pkg-upgrade(8) today. It installed apache24 even though /etc/make.conf has:

```
WITH_PKGNG=yes
DEFAULT_VERSIONS+=apache=2.2
```

We need apache22.

Ran `pkg remove apache24` and then reinstalled apache22 

http-error.log shows

```
[crit] (17)File exists: mod_rewrite: Parent could not create RewriteLock file /usr/local/etc/apache22/locks/systems.rewritelock
```
The directory /usr/local/etc/apache22/locks is mod 777 and there is no systems.rwritelock.

Tried `touch /usr/local/etc/apache22/locks/systems.rewritelock`
That doesn't help either.

Any help with this is greatly appreciated.


----------



## SirDice (Nov 29, 2016)

You can remove the WITH_PKGNG=yes, it was only used during the transition period, it doesn't do anything anymore. And on FreeBSD 10.x and higher you don't have a choice anyway. 

The settings in /etc/make.conf only work when building from ports. It does nothing for packages. The official packages always use the default options, you cannot change them (the default is Apache 2.4). If you need Apache 2.2 you will need to build from ports.


----------



## ProServ (Nov 29, 2016)

SirDice, thank you. Any idea on how to get apache22 to start and to be able to create the lockfile....


```
[crit] (17)File exists: mod_rewrite: Parent could not create RewriteLock file
```

As we both see the error says it exists. I beg to differ, it does not exist in /usr/local/etc/apache22/locks. The directory is empty.


----------



## SirDice (Nov 29, 2016)

Make sure you don't still have an Apache 2.4 running. Remove everything that depends on Apache 2.4. Remove /usr/local/etc/apache2[24]/, you most likely changed something you shouldn't have. Then reinstall Apache 2.2.


----------



## ProServ (Nov 29, 2016)

Hi, `rm -rf /usr/local/etc/apache24`
in /usr/ports/www/apache24, `make deinstall` : not installed, skipping
/usr/ports/www/apache22; `make deinstall; make config`

Checked it against an old file have locally and selected same options
make install

/etc/rc.conf has:

```
apache22_enable="YES"
apache22_http_accept_enable="YES"
apache22_flags="-DSSL"
```
`/usr/local/etc/rc.d/apache22 start`

Invalid command 'DBDriver', perhaps misspelled or defined by a module not included in the server configuration

In httpd.conf have:

```
# PostgreSQL authentication used for site
DBDriver pgsql
DBDParams "dbname=systems user=fbsdweb"
#DBDPersist on
# RewriteLock /var/tmp/freebsdsystems.rewritelock
RewriteLock /usr/local/etc/apache22/locks/freebsdsystems.rewritelock
```
Does that mean config is missing dbd? If so, it was not in the original make config file I have locally.

Thanks.


----------



## obsigna (Nov 29, 2016)

Please check whether devel/apr1 has been compiled with PostgreSQL database support. The default build does not. Apache relies on the SQL database functionality in apr1.


----------



## ProServ (Nov 29, 2016)

I did install devel/apr1 before but will run `make config` and reinstall again to be sure.

In the meantime, after recompiling/installing apache22 ....

```
root@w2:/usr/ports/www/apache22 # /usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
root@w2:/usr/ports/www/apache22 # ps auxw |grep http
root    75269  12.6 12.6 435588 96100  -  Ds   12:38PM   0:01.56 /usr/local/sbin/httpd -DSSL
root     1029   0.0  0.3  12372  2000  1  S+    9:34AM   0:00.78 tail -F /var/log/www/httpd-error.log
root    75273   0.0  0.3  18840  2344  2  S+   12:38PM   0:00.00 grep http
root     1538   0.0  0.3  12372  1996  3  S+   10:17AM   0:00.00 tail -f /var/log/www/httpd-error.log
root@w2:/usr/ports/www/apache22 # ps auxw | grep http
root     1029   0.0  0.3  12372  2000  1  S+    9:34AM   0:00.78 tail -F /var/log/www/httpd-error.log
root    75275   0.0  0.3  18840  2344  2  S+   12:38PM   0:00.00 grep http
```
Restart again:

```
[Tue Nov 29 12:41:14 2016] [crit] (17)File exists: mod_rewrite: Parent could not create RewriteLock file /usr/local/etc/apache22/locks/freebsdsystems.rewritelock
```


----------



## ProServ (Nov 29, 2016)

```
Registering installation for apr-1.5.2.1.5.4_2
Installing apr-1.5.2.1.5.4_2...
```
Just realized cannot add images here.
Made absolutely sure Postgres was X'd when running `make config` for devel/apr1

Tried to start/restart apache22:

```
[Tue Nov 29 12:44:32 2016] [warn] No JkShmFile defined in httpd.conf. Using default /usr/local/logs/jk-runtime-status
[Tue Nov 29 12:44:33 2016] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Nov 29 12:44:33 2016] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Nov 29 12:44:33 2016] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Nov 29 12:44:33 2016] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Nov 29 12:44:33 2016] [error] (2)No such file or directory: exec of '/home/quotes/bp/dm/util/optional-forced-logout.pl' failed
[Tue Nov 29 12:44:33 2016] [warn] No JkShmFile defined in httpd.conf. Using default /usr/local/logs/jk-runtime-status
[Tue Nov 29 12:44:33 2016] [notice] Digest: generating secret for digest authentication ...
[Tue Nov 29 12:44:33 2016] [notice] Digest: done
[Tue Nov 29 12:44:41 2016] [crit] (17)File exists: mod_rewrite: Parent could not create RewriteLock file /usr/local/etc/apache22/locks/freebsdsystems.rewritelock
Configuration Failed
```
And actually, the file /home/quotes/bp/dm/util/optional-forced-logout.pl does exist:

```
# ls -l /home/quotes/bp/dm/util/optional-forced-logout.pl
-rwxr-xr-x  1 quotes  quotes  195 Mar 14  2006 /home/quotes/bp/dm/util/optional-forced-logout.pl

ls -ld /usr/local/etc/apache22/locks/
drwxr-xr-x  2 root  wheel  512 Nov 29 12:44 /usr/local/etc/apache22/locks/
```
It's empty. Why is apache complaining file exists?

Thanks.


----------



## SirDice (Nov 29, 2016)

ProServ said:


> And actually, the file /home/quotes/bp/dm/util/optional-forced-logout.pl does exist:


What's the first line of that file?


----------



## ProServ (Nov 29, 2016)

```
uname -a
FreeBSD w2.servaris.com 10.2-RELEASE-p9 FreeBSD 10.2-RELEASE-p9 #0: Thu Jan 14 01:32:46 UTC 2016     [email]root@amd64-builder.daemonology.net[/email]:/usr/obj/usr/src/sys/GENERIC  amd64
```
In case the issue is caused because of old FreeBSD version, running upgrade now.

```
root@w2:/home # freebsd-update -r 10.3-RELEASE upgrade
```


----------



## ProServ (Nov 29, 2016)

```
#!/usr/bin/perl
```


----------



## ProServ (Nov 29, 2016)

In apache22/Includes/w2.conf it has:

```
DBDriver pgsql
        DBDParams "dbname=systems user=fbsdweb"
        DBDPersist on

        RewriteEngine On
        RewriteOptions Inherit
        RewriteMap      timestamps prg:/home/quotes/bp/dm/util/timestamps
        RewriteMap      optional-forced-logout prg:/home/quotes/bp/dm/util/optional-forced-logout.pl
```


----------



## SirDice (Nov 29, 2016)

ProServ said:


> ```
> #!/usr/bin/perl
> ```


There is no /usr/bin/perl any more, it moved to /usr/local/bin/perl. This results in a rather cryptic "no such file or directory" error message.


----------



## ProServ (Nov 29, 2016)

Changed first line to 

```
#!/usr/local/bin/perl
```
But apache still refuses to start with same error:

```
Tue Nov 29 13:06:32 2016] [warn] No JkShmFile defined in httpd.conf. Using default /usr/local/logs/jk-runtime-status
[Tue Nov 29 13:06:32 2016] [notice] Digest: generating secret for digest authentication ...
[Tue Nov 29 13:06:32 2016] [notice] Digest: done
[Tue Nov 29 13:08:03 2016] [crit] (17)File exists: mod_rewrite: Parent could not create RewriteLock file /usr/local/etc/apache22/locks/freebsdsystems.rewritelock
Configuration Failed
```


----------



## ProServ (Nov 29, 2016)

Upgraded system: 
	
	



```
FreeBSD 10.3-RELEASE-p11 (GENERIC) #0: Mon Oct 24 18:49:24 UTC 2016
```
Ran: 
	
	



```
portmaster -R apache22 ap22-mod_jk ap22-mod_geoip perl5-5.20 devel/apr1 mod_php56
```

===>>> The following actions were performed:
   Re-installation of apr-1.5.2.1.5.4_2
   Re-installation of perl5-5.20.3_15
   Re-installation of apache22-2.2.31_1
   Re-installation of ap22-mod_jk-1.2.41,1
   Upgrade of ap22-mod_geoip2-1.2.9_1 to ap22-mod_geoip2-1.2.10
   Re-installation of mod_php56-5.6.28

Start Apache22


```
[Tue Nov 29 14:07:30 2016] [crit] (17)File exists: mod_rewrite: Parent could not create RewriteLock file /var/tmp/freebsdsystems.rewritelock
```
Configuration Failed

What is causing it to not be able to create the rewritelock file??


----------



## ProServ (Nov 29, 2016)

Tried to start apache22 with rewritelock #'d
Still will not start.

Error log shows
[Tue Nov 29 14:17:35 2016] [warn] No JkShmFile defined in httpd.conf. Using default /usr/local/logs/jk-runtime-status
[Tue Nov 29 14:17:36 2016] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Nov 29 14:17:36 2016] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Nov 29 14:17:36 2016] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Tue Nov 29 14:17:36 2016] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Nov 29 14:17:36 2016] [warn] mod_rewrite: Running external rewrite maps without defining a RewriteLock is DANGEROUS!
[Tue Nov 29 14:17:36 2016] [warn] No JkShmFile defined in httpd.conf. Using default /usr/local/logs/jk-runtime-status
[Tue Nov 29 14:17:36 2016] [notice] Digest: generating secret for digest authentication ...
[Tue Nov 29 14:17:36 2016] [notice] Digest: done


----------



## ProServ (Nov 29, 2016)

Tried running by hand #
	
	



```
/usr/local/sbin/httpd -DSSL
```

Doesn't start

Tried running without -DSSL
it starts. I can get to the web site.

Something with ssl ?


----------

