17. December 2013

Debian – upgrade from Apache 2.2 to 2.4 – Starting web server: apache2 failed!

Debian maintainers changed default Apache from version 2.2 to 2.4. Not a big deal?

I was just upgrading one package and it had dependency on whole new Apache. I said yes to upgrade, because I had no bigger issues with Apache upgrade in past.

Wohoo. This upgrade was very funny, because Apache 2.4 was not able to start due to conflicting configurations. The coolest part was that Subversion stopped working, but that’s different story.

The problematic part was that Apache failed to start with nice message:

[FAIL] Starting web server: apache2 failed!
[warn] The apache2 instance did not start within 20 seconds. Please read the log files to discover problems ... (warning)

I checked the log file /var/log/apache2/error.log, but there was no hint what went wrong.

Apache was working even though startup script reported error. :-)

After a while I found that there were some important changes in /etc/apache2/apache2.conf. I compared this file with /etc/apache2/apache2.conf.dpkg.dist.

It was necessary to update following lines in apache2.conf:

Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
#LockFile /var/lock/apache2/accept.lock - disable this, old value

Then it was possible to start Apache without problem:

[ ok ] Restarting web server: apache2.

22. September 2013

Deploy Spring application by Maven to Tomcat7 via HTTPS – PKIX problem

Simple scenario: deploy spring application to remote server which has https management interface.

Easy task. When you have properly configured project with pom.xml then you can use tomcat7 plugin for Maven.

Part of pom.xml

<plugin>
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId>
 <version>2.0-SNAPSHOT</version>
 <configuration>
  <path>/test</path>
  <!-- username and password must be set in ~/.m2/settings.xml -->
  <server>mytomcat</server>
  <!-- URL where Maven can find Tomcat 7 Manager -->
  <url>https://test.sinusgear.com:443/manager/text</url>
 </configuration>
</plugin>

Just run:

mvn tomcat7:deploy

Upload fails with error message:

PKIX path building failed

Ups. Not that easy? :)
The problem is that Java does not trust certificate of remote server.

Here is how to fix PKIX issue in Windows.

Open url of remote server by Firefox and save certificate to file.

Run PowerShell as administrator.

Go to directory with JDK cacets and import certificate. Default password is “changeit“.

cd C:\Program Files\Java\jdk1.7.0_40\jre\lib\security
keytool -import -alias test.sinusgear.com -keystore cacerts -file C:\Users\georgik\Documents\test.sinusgear.com

Done. Now you can start mvn tomcat7:deploy again.

1. June 2013

GitLab: Could not read from remote repository

When you try to push to GitLab you may end up with following error message:

fatal: Could not read from remote repository.
Please make sure you have the correct access rights
 and the repository exists.

It’s not very clear what’s real cause. You may check the permission, but it might not solve the problem.

One quick solution could be just restart of GitLab service. It still might not help.

Let’s learn some mechanics of GitLab.

You send data via ssh to GitLab server. When authentication by key is succesfull then server will invoke gitlab-shell. This will shell send request to web interface of GitLab. Yes, web interface. Then it will allow you to access git repository.

Schema:

git -> ssh -> sshd -> gitlab-shell -> gitlab web

The problem described in the beginning of this article is between gitlab-shell and gitlab-web. Most likely shell is not able to access gitlab web. URL is broken or host configuration is incorrect or port is not reachable.

Just go to gitlab-shell project and open file config.yml. You’ll see something like this:

gitlab_url: "http://localhost:80/"

Test this URL directly on server e.g. by links:

links http://localhost:80/

You may need to change hostname or port or add base directory to URL. Fix the URL so the gitlab-shell is able to access web interface. Restart gitlab service and try to push again.

Further discussion about this and similar problems is available at github.

7. September 2011

Debian – apt-get install perl problem

I wanted to install new package on Debian. But what a funny message:

E: Could not perform immediate configuration on 'perl-modules'. 
Please see man 5 apt.conf under APT::Immediate-Configure for details. (2)

How to solve it?

Type:

apt-get install perl -o APT::Immediate-Configure=0

27. August 2011

Try to create aux.h file on Windows 7

Try it :-)

I was playing with one package from Linux. I grab source code of package using Cygwin. This source code contained one funny file: aux.h.

Windows version of Vim refused to open this file with error message: Permission denied.

Even Notepad refused to open this file.

Finally Visual Studio gave me interesting hint about this aux.h file name:

 

I tried to zip this file by 7Zip and extract it back. Result was that 7Zip decompressed file as _aux.h.

Interesting issue. :-)