How to get gitolite / gitweb working together? - gitolite

I have gitweb and gitolite installed. I can configure a repo for gitweb access and it appears in the "projects.list" file but the repo is not listed by gitweb in the browser.
I've been searching and searching but can't find what I am missing to make this work.
My gitweb.conf contains
$git_temp = "/tmp";
# The directories where your projects are. Must not end with a slash.
$projectroot = "/srv/git/repositories";
$projects_list = "/srv/git/projects.list";
My .gitolite.rc contains
$PROJECTS_LIST = $ENV{HOME} . "/projects.list";
I've checked and the projects.list file goes get updates as per changes to the gitlite config once that is pushed back to the repo. So I think it's just gitweb not seeing the list and acting on it, but I can't figure out know why.
I just get the gitweb page with "404 - No projects found" where the project list should be.
UPDATE:
I found that in my case the problem was caused by incorrect Apache config. I had followed http://git#boron/testing.git. I had the following in my VirtualHost:
# Make sure we can execute gitweb okay
<Directory "/srv/http/gitweb">
Options ExecCGI
AllowOverride None
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
Order allow,deny
Allow from all
</Directory>
This executed gitweb.cgi directly, as the httpd user and without any environment settings. I replaced this block with an explicit call to my suexec wrapper:
# Call GitoWeb cgi via suexec wrapper for relevant URLs
ScriptAliasMatch "^/$" /srv/http/git-suexec/gitweb.cgi.suexec-wrapper
And that fixed my problem.

As the OP mentions in the comment, you need to make sure your VirtulaHost in the Apache config calls gitweb.cgi with the right parameters/environment variables:
Here is my httpd.conf for that service:
Notice how it will avoid ScriptAliasMatch and how it does set GIT_HTTP_BACKEND.
# GitWeb on 8443 # or any port you want
Listen 8443
<VirtualHost hostname>
ServerName hostname
ServerAlias short-hostname
SSLCertificateFile "/path/to/apache/crt"
SSLCertificateKeyFile "/path/to/apache/key"
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SetEnv GIT_HTTP_BACKEND /path/to/git/libexec/git-core/git-http-backend
DocumentRoot /path/to/gitweb
Alias /gitweb /path/to/gitweb
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /path/to/gitweb>
SSLOptions +StdEnvVars
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AuthName "LDAP authentication for GitWeb repositories"
AuthType Basic
AuthBasicProvider myldap companyldap
AuthzLDAPAuthoritative On
Require valid-user
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
RewriteEngine Off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[a-zA-Z0-9_\-]+\.git/?(\?.*)?$ /gitweb.cgi%{REQUEST_URI} [L,PT]
</Directory>
</VirtualHost>
Original answer:
Here is my gitweb.conf.pl:
my $gl_home = $ENV{HOME} = "#H#";
# the following variables are needed by gitolite; please edit before using
# this should normally not be anything else
$ENV{GL_RC} = "$gl_home/.gitolite.rc";
# this can have different values depending on how you installed.
# if you used RPM/DEB or "root" methods it **might** be this:
$ENV{GL_BINDIR} = "/usr/local/bin";
# if you used the "non-root" method it **might** be this:
$ENV{GL_BINDIR} = "$gl_home/gitolite/bin";
# If in doubt take a look at ~/.ssh/authorized_keys; at least one of the lines
# might contain something like:
# command="/home/git/.gitolite/src/gl-auth-command
# and you should use whatever directory the gl-auth-command is in (in this
# example /home/git/.gitolite.src)
# finally the user name
$ENV{GL_USER} = $cgi->remote_user || "gitweb";
# now get gitolite stuff in...
unshift #INC, $ENV{GL_BINDIR};
require gitolite_rc; gitolite_rc -> import;
require gitolite; gitolite -> import;
# set project root etc. absolute paths
$ENV{GL_REPO_BASE_ABS} = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$gl_home/$REPO_BASE" );
$projects_list = $projectroot = $ENV{GL_REPO_BASE_ABS};
$export_auth_hook = sub {
my $repo = shift;
# gitweb passes us the full repo path; so we strip the beginning
# and the end, to get the repo name as it is specified in gitolite conf
return unless $repo =~ s/^\Q$projectroot\E\/?(.+)\.git$/$1/;
# check for (at least) "R" permission
my ($perm, $creator) = &repo_rights($repo);
return ($perm =~ /R/);
};
Replace the #H# by your path where your .gitolite, .gitoliterc, repositories, project.list files are.
Note how I defined $ENV{GL_BINDIR}: I didn't comment the second definition, because in my case I did a non-root installation, hence the:
$ENV{GL_BINDIR} = "$gl_home/gitolite/bin";
Make sure to have a gitweb_config.perl with:
our $home_link_str = "ITSVC projects";
our $site_name = "ITSVC Gitweb";
use lib (".");
require "gitweb.conf.pl";
That is what will make the link between gitweb and the extra gitweb.conf.pl which will call gitolite.

Related

.htaccess not working on localhost (manjaro)

I've been spending all afternoon trying to solve this but couldn't by myself.
I've been trying in VSCode to implement an admin area by using .htaccess but the page will load without asking me anything.
I get no error whatsoever, neither do I in /var/log/httpd/error_log.
I modified AutoOverride in httpd.conf as such :
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride All
Require all denied
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/srv/http"
<Directory "/srv/http">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
and uncommented LoadModule rewrite_module modules/mod_rewrite.so
Here's my .htaccess file :
RewriteEngine On
RewriteBase /
AuthName "Page d'administration protégée"
AuthType Basic
AuthUserFile "/home/badakzz/php/openclassroom/htdocs/sql/blog/admin/.htpasswd"
Require valid-user
I honestly don't know where to search anymore, I'm very new to Linux few people use Manjaro so they don't seem to have "/srv/http" as DocumentRoot (which I tried to copy my VSCode project into but it didn't change anything).
Thanks in advance for helping me in my misery...!
I would recommend the following Solution:
Edit the: /etc/httpd/conf/extra/httpd-userdir.conf file
Change:
AllowOverride Option1 Option2 Option3
to:
AllowOverride All
Save and restart apache:
sudo systemctl restart httpd
Test it.

Execute CGI file without extension

I am new to CGI or Apache.
I am trying to install an application called as mooshak.
The installation is finishing fine. But when I open the local site, it simply downloads the file instead of executing it.
When I open http://localhost/~mooshak/cgi-bin/execute, it simply downloads the file as shown:
#!/bin/sh
# the next line restarts using tclsh \
PATH=$PATH:/usr/local/bin:/usr/contrib/bin ; exec tclsh "$0" "$#"
#-*-Mode: TCL; iso-accents-mode: t;-*-
set errorCode NONE
cd ../..
lappend auto_path packages
source .config
execute::command_line
My /etc/apache2/mods-enabled/userdir.conf file looks like this :
<IfModule mod_userdir.c>
<Directory /home/*/public_html/cgi-bin>
Options +ExecCGI -Includes -Indexes
SetHandler cgi-script
Order allow,deny
Allow from all
</Directory>
</IfModule>
What should I do ?
Try like this
<Directory /home/*/public_html>
Options -Includes -Indexes
Order allow,deny
Allow from all
</Directory>
<Directory /home/*/public_html/cgi-bin>
Options +ExecCGI -Includes -Indexes
SetHandler cgi-script
</Directory>
And give to script chmod +x
Try to use /urs/lib/cgi-bin for cgi-scripts. Every thing else will give you a haedache if you not know what to do.
The cgi-scripts need to be executable and readable for the user www-data
For Apache version >=2.2 you will need to add an entry in /etc/apache2/conf-available. My config looks like this ...
admin#suse:~$ cat /etc/apache2/conf-available/cgi-bin.conf
<IfModule mod_alias.c>
<IfModule mod_cgi.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>
<IfModule mod_cgid.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>
<IfDefine ENABLE_USR_LIB_CGI_BIN>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AllowOverride AuthConfig
AuthType Basic
AuthName "Suleiman's Heimat 2.0"
AuthBasicProvider file
AuthUserFile /etc/apache2/passwd
Require valid-user
</Directory>
</IfDefine>
</IfModule>
These are the default settings for Debian systems, and additional password protection.
Then you call a2enconf cgi-bin.
This has nothing to do with /etc/apache2/mods-enabled ! I cant find a reason to put cgi-code in there. Instead you will need to activate the common-gateway-interface via
a2enmod cgi
This will put a entry into /etc/apache2/mods-enabled.
Last but not least, you need to restart the server via /etc/init.d/apache2 restart
There you go.
Hope this will help.
Addition
You should run apache2ctl configtest to check your configuration, before restarting the server!
/var/log/apache2/ has also good info when something goes south.
You can also use the command systemctl status apache2.service to check the status of your service and journalctl -b -n 30 -u apache2.service to get the last 30 protocol entries.

How do I disable listing of directories in Apache?

Does Apache have an option to disable directory listing globally? (But it will still allow me to use index.php as my main page)
Note: I have many virtual hosts and subdomains and what not.
Yes, its possible. You should use the Options directive with the -Indexes param
For example, in Centos /etc/httpd/conf/httpd.conf update Directory / to:
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
<Directory />
Options FollowSymLinks -Indexes
AllowOverride None
</Directory>
This way all child configuration will enhirit this restriction.
Note that each child can override this if the directive AllowOverride is set to Indexes or All (This effect override params in .htaccess files)

easyphp and .htaccess

I need help with EasyPHP and .htaccess .
The .htaccess file isn't working, I think its because I didn't setup something with EasyPHP.
My EasyPHP version is 5.3.8.1
Maybe anyone knows how to fix this problem ?
.htaccess file :
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^get/([^/]+) /func/get.php?link=$1 [NC]
Default installation of Apache in EasyPHP don't have activated the option to use .htaccess files to modify server configuration in folders.
You have to tell Apache what configuration can be changed with .htaccess files, and in which folder. To enable all config changes on main web server, you should edit http.conf (in Apache/conf folder), and look for:
<Directory "${path}/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
and change
AllowOverride None
to
AllowOverride All
To better fine tune it, read documentation about AllowOverride in:
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
Also, check that http.conf has mod_rewrite activated, look for:
#LoadModule rewrite_module modules/mod_rewrite.so
And remove the leading "#"
LoadModule rewrite_module modules/mod_rewrite.so
When working on a local website I fixed this problem by adding the website path (with the .htaccess) as a virtual host. Easyphp has got a module for this: 'Virtual Hosts Manager'. This wil automatically take care of the httpd.conf.

How to use .htaccess in WAMP Server?

I searched in web for 2 days and I try to use htaccess in my local wamp but I can't! I know there is something wrong but I don't know where...
First: I activated "rewrite_module" in the apache menu, then I checked the phpinfo page and I saw that module added to its "Loaded Modules" part.
Second: I checked the httpd.conf and made some changes, it is the result (just important parts):
ServerRoot "c:/program Files/wamp/bin/apache/apache2.2.11"
Listen 80
ServerName localhost:80
DocumentRoot "c:/program Files/wamp/www/"
<Directory />
Options FollowSymLinks
# AllowOverride None
# Order deny,allow
# Deny from all
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
<Directory "c:/program Files/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
Next: I made an alias to my workspace. Here is contents of its .conf file:
Alias /basic_test/ "e:/Projects/basic_test/"
<Directory "e:/Projects/basic_test/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Next: I place a simple "index.php" and "test.php" in my workspace root and tested the alias by this addresses:
--> "localhost/basic_test/index.php"
--> "localhost/basic_test/test.php"
They worked perfectly...
Finally, I added a ".htaccess" file to the root of my workspace (beside index.php), and I wrote in it:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^index.php$ test.php
</IfModule>
But the problem occurred when I tried to test the ".htaccess" by this address:
--> "localhost/basic_test/index.php"
It shows an error page with this message:
Oops! This link appears to be broken.
Click on Wamp icon and open Apache/httpd.conf and search "#LoadModule rewrite_module modules/mod_rewrite.so". Remove # as below and save it
LoadModule rewrite_module modules/mod_rewrite.so
and restart all service.
RewriteEngine on
RewriteBase /basic_test/
RewriteRule ^index.php$ test.php
click: WAMP icon->Apache->Apache modules->chose rewrite_module
and do restart for all services.
Open the httpd.conf file and search for
"rewrite"
, then remove
"#"
at the starting of the line,so the line looks like.
LoadModule rewrite_module modules/mod_rewrite.so
then restart the wamp.
if it related to hosting site then ask to your hosting to enable url writing or if you want to enable it in local machine then check this youtube step by step tutorial related to enabling rewrite module in wamp apache
https://youtu.be/xIspOX9FuVU?t=1m43s
Wamp server icon -> Apache -> Apache Modules and check the rewrite module option
it should be checked
Note its very important that after enable rewrite module you should require to restart all services of wamp server

Resources