Setup on Arch Linux
===================

1) Clone the AUR project:

   $ cd /srv/http/
   $ git clone git://projects.archlinux.org/aurweb.git

2) Setup a web server with PHP and MySQL. Configure the web server to redirect
   all URLs to /index.php/foo/bar/. The following block can be used with nginx:

    server {
        listen       80;
        server_name  aur.local aur;

        root   /srv/http/aurweb/web/html;
        index  index.php;

        location ~ ^/[^/]+\.php($|/) {
            fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(/[^/]+\.php)(/.*)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO        $fastcgi_path_info;
            include        fastcgi_params;
        }

        location ~ .* {
            rewrite ^/(.*)$ /index.php/$1 last;
        }
    }

3) Copy conf/config.proto to conf/config and adjust the configuration (pay
   attention to disable_http_login, enable_maintenance and aur_location).

4) Create a new MySQL database and a user and import the AUR SQL schema:

    $ mysql -uaur -p AUR </srv/http/aurweb/schema/aur-schema.sql

5) Create a new user:

    # useradd -U -d /srv/http/aurweb -c 'AUR user' aur

6) Initialize the Git repository:

    # mkdir /srv/http/aurweb/aur.git/
    # cd /srv/http/aurweb/aur.git/
    # git init --bare
    # git config --local transfer.hideRefs '^refs/'
    # git config --local transfer.hideRefs '!refs/'
    # ln -s ../../git-interface/git-update.py hooks/update
    # chown -R aur .

7) Install needed Python modules:

    # pacman -S python-mysql-connector python-pygit2

8) Install the git-auth wrapper script:

    # cd /srv/http/aurweb/git-interface/
    # make && make install

9) Configure sshd(8) for the AUR. Add the following lines at the end of your
   sshd_config(5) and restart the sshd. Note that OpenSSH 6.9 or newer is
   needed!

    Match User aur
        PasswordAuthentication no
        AuthorizedKeysCommand /usr/local/bin/aur-git-auth "%t" "%k"
        AuthorizedKeysCommandUser aur

10) If you want to enable smart HTTP support with nginx and fcgiwrap, you can
    use the following directives:

    location ~ "^/([a-z0-9][a-z0-9.+_-]*?)(\.git)?/(git-(receive|upload)-pack|HEAD|info/refs|objects/(info/(http-)?alternates|packs)|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx))$" {
        fastcgi_pass   unix:/run/fcgiwrap.sock;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
        fastcgi_param  PATH_INFO /aur.git/$3;
        fastcgi_param  GIT_HTTP_EXPORT_ALL "";
        fastcgi_param  GIT_NAMESPACE $1;
        fastcgi_param  GIT_PROJECT_ROOT /srv/http/aurweb/;
    }

   Sample systemd unit files for fcgiwrap can be found under conf/.