Can see listing, but not repositories using Apache
ArkieCoder opened this issue · 4 comments
I am probably configuring Apache wrong. :)
I'm using the default Debian install with Apache2. I have enabled FollowSymLinks and linked /var/www/html/p3x-gitlist to /var/www/html/p3x-gitlist/public, which is the public directory of where I unzipped the latest release of p3x-gitlist.
I have RewriteBase set to '/p3x-gitlist' in /var/www/p3x-gitlist/public/.htaccess.
I can see the listing page just fine, but when I navigate to any of the repositories, I get the message "No input file specified".
The links on the listing page are of the format:
http://host/p3x-gitlist/index.php/path/to/repo.git
Please help! Thanks!
the p3x-gitlist has already a has public folder, so there rewrite.
it seems you unzipped to /var/www/html/p3x-gitlist so it will look like
/var/www/html/p3x-gitlist/public/public
p3x-gitlist is a bit differenet, because it is more secure the PHP is under the public.
i unzipped like this:
root@server:/var/www/gitlist.patrikx3.com# ll
total 76K
dr-xr-x--- 7 www-data www-data 4.0K Jul 15 00:20 .
drwxr-xr-x 49 www-data www-data 4.0K Jul 16 14:13 ..
-r--r----- 1 www-data www-data 657 Jul 15 00:20 boot.php
drwxr-x--- 4 www-data www-data 4.0K Jul 15 00:22 cache
-r--r----- 1 www-data www-data 12K Jul 15 00:20 changelog.md
-r--r----- 1 www-data www-data 2.5K Jul 15 00:20 config.example.ini
-rw-r----- 1 www-data www-data 2.0K Jul 15 00:20 config.ini
drwxr-x--- 15 www-data www-data 4.0K Jul 15 00:21 git-bare
-r--r----- 1 www-data www-data 4.5K Jul 15 00:20 INSTALL.md
-r--r----- 1 www-data www-data 2.7K Jul 15 00:20 LICENSE
-r--r----- 1 www-data www-data 2.6K Jul 15 00:20 package.json
dr-xr-x--- 4 www-data www-data 4.0K Jul 15 00:20 public
-r--r----- 1 www-data www-data 6.7K Jul 15 00:20 README.md
dr-xr-x--- 5 www-data www-data 4.0K Jul 15 00:20 src
dr-xr-x--- 12 www-data www-data 4.0K Jul 15 00:20 vendor
root@server:/var/www/gitlist.patrikx3.com#
that is how you should do it.
i do not use Apache2, so i have no idea how to set Apache, but I have a little info, if I use a rewrite, it is a bit more complex:
AliasMatch ^/p3x-gitlist/(.*)\.css$ /var/www/html/p3x-gitlist/public/$1.css
AliasMatch ^/p3x-gitlist/(.*)\.png$ /var/www/html/p3x-gitlist/public/$1.png
AliasMatch ^/p3x-gitlist/(.*)\.js$ /var/www/html/p3x-gitlist/public/$1.js
AliasMatch ^/p3x-gitlist/(.*)\.svg$ /var/www/html/p3x-gitlist/public/$1.svg
AliasMatch ^/p3x-gitlist/(.*)\.ico$ /var/www/html/p3x-gitlist/public/$1.ico
AliasMatch ^/p3x-gitlist/(.*)\.woff$ /var/www/html/p3x-gitlist/public/$1.woff
AliasMatch ^/p3x-gitlist/(.*)\.woff2$ /var/www/html/p3x-gitlist/public/$1.woff2
AliasMatch ^/p3x-gitlist/(.*)\.ttf$ /var/www/html/p3x-gitlist/public/$1.ttf
AliasMatch ^/p3x-gitlist/(.*)\.eot$ /var/www/html/p3x-gitlist/public/$1.eot
# AliasMatch ^/p3x-gitlist/.* /var/www/html/p3x-gitlist/public/index.html
Alias /p3x-gitlist /var/www/html/p3x-gitlist/public
<Directory "/var/www/html/p3x-gitlist/public">
AllowOverride All
</Directory
Plus you have to configure PHP to use the index.php az the index, with the rewrite.
I just do not have, either use Nginx or you have to figure it out. Sorry.
I found a solution for this after some digging. Thanks for the insight above.
Since this project is a fork of GitList, and GitList supports Apache, there is already an .htaccess file included in p3x-gitlist which has all the necessary Apache configuration.
I removed the symbolic link as that was an inelegant solution, and used this snippet to alias to the directory:
Alias /p3x-gitlist /var/www/p3x-gitlist/public
<Directory "/var/www/p3x-gitlist/public">
DirectoryIndex index.php
AllowOverride All
</Directory>
That, plus setting cgi.fix_pathinfo=1 for FPM fixed my problem. I am including the Dockerfile I'm using for the complete solution.
FROM debian
WORKDIR /var/www
## * wget and git are required for getting packages we need
## * unzip is needed to expand zip files
## * apache2 is the web server
## * php-fpm and php-xml are needed for p3x-gitlist
RUN apt-get -yqq update
RUN apt-get -yqq install \
wget git \
unzip \
apache2 \
php-fpm \
php-xml
## add configuration to apache
COPY p3x-gitlist.conf /etc/apache2/conf-available
RUN a2enconf p3x-gitlist
RUN a2enconf php7.3-fpm
## enable the apache rewrite, actions, and proxy_fcgi modules
RUN a2enmod rewrite
RUN a2enmod actions
RUN a2enmod proxy_fcgi
## fix a security hole in the default config
RUN echo "cgi.fix_pathinfo=1" >> /etc/php/7.3/fpm/php.ini
## increase memory limit
RUN sed -ie 's/memory_limit = 128M/memory_limit = 1024M/g' /etc/php/7.3/fpm/php.ini
## disable limit_extensions
RUN echo "security.limit_extensions =" >> /etc/php/7.3/fpm/pool.d/www.conf
## set log paths
RUN sed -ie 's/\/var\/log\/apache2/\/logs/g' /etc/apache2/envvars
RUN sed -ie 's/\/var\/log/\/logs/g' /etc/php/7.3/fpm/php-fpm.conf
## create the directory for the socket
RUN mkdir /var/run/php
## retrieve and configure p3x-gitlist
RUN wget -q https://github.com/patrikx3/gitlist/releases/download/v2019.4.128/p3x-gitlist-v2019.4.128.zip
## weird unzip command needed due to weird archive structure
RUN unzip -qq -d p3x-gitlist p3x-gitlist-v2019.4.128.zip -x "*p3x-gitlist-v2019.4.128*" -x "*..*"
RUN chmod -R 755 p3x-gitlist
RUN mkdir -p p3x-gitlist/cache
RUN chmod -R 777 p3x-gitlist/cache
RUN cp p3x-gitlist/config.example.ini p3x-gitlist/config.ini
RUN sed -ie 's/#RewriteBase \/path\/to\/gitlist\//RewriteBase \/p3x-gitlist/g' p3x-gitlist/public/.htaccess
## set permissions on .htaccess
RUN chmod 644 p3x-gitlist/public/.htaccess
## optionally turn on app debugging
#RUN sed -ie 's/debug = false/debug = true/g' p3x-gitlist/config.ini
## run php and apache as a daemon - php will detach and apache will hold the terminal
CMD /usr/sbin/php-fpm7.3 --fpm-config /etc/php/7.3/fpm/php-fpm.conf && chmod 644 /logs/* && apachectl -DFOREGROUND
i am glad you solved it. :)