Friday, December 17, 2021

How to Setup install HTTP Git Server with Nginx on Debian 11

 Git is an open-source version control system used by thousands of developers around the world.
HTTP Git Server is an open-source project that uses an Nginx webserver to serve Git repositories over your Local Area Network (LAN). It is very simple and easy to set up. Anyone can manage it from the command-line interface.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
๐Ž๐ฎ๐ซ ๐’๐ž๐ซ๐ฏ๐ž๐ซ ๐’๐ฉ๐ž๐œ๐ข๐Ÿ๐ข๐œ๐š๐ญ๐ข๐จ๐ง:-
๐Ž๐ฌ : ๐ƒ๐ž๐›๐ข๐š๐ง ๐Ÿ๐Ÿ ๐›๐ฎ๐ฅ๐ฅ๐ฌ๐ž๐ฒ๐ž ๐Ÿ”๐Ÿ’ ๐๐ข๐ญ     || ๐‡๐จ๐ฌ๐ญ๐ง๐š๐ฆ๐ž:       || ๐ˆ๐ ๐€๐๐๐ซ๐ž๐ฌ๐ฌ ๐จ๐Ÿ ๐’๐ž๐ซ๐ฏ๐ž๐ซ:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                            lsb_release -cd  ; getconf LONG_BIT ; hostname ; hostname -I
apt install -y build-essential net-tools curl git software-properties-common nginx git fcgiwrap apache2-utils unzip
mkdir /var/www/html/myrepo  ; cd /var/www/html/myrepo ; mkdir user1.git
cd user1.git ; git --bare init
git update-server-info
chown -R www-data:www-data /var/www/html/myrepo ; chmod -R 755 /var/www/html/myrepo
htpasswd -c /var/www/html/myrepo/htpasswd user1

nano /etc/nginx/conf.d/git.conf
server {
        listen 80;

        root /var/www/html/myrepo;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name debian.example.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

location ~ (/.*) {
    client_max_body_size 0;
    auth_basic "Git Login";
    auth_basic_user_file "/var/www/html/myrepo/htpasswd";
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
    fastcgi_param GIT_HTTP_EXPORT_ALL "";
    fastcgi_param GIT_PROJECT_ROOT /var/www/html/myrepo;
    fastcgi_param REMOTE_USER $remote_user;
    fastcgi_param PATH_INFO $1;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
}

}
nginx -t
systemctl restart nginx ; systemctl status nginx
mkdir project ; cd project ; git init
git config --global user.email "user1@yourdomain.com"
git config --global user.name "user1"
git remote add origin http://user1@debian.example.com/user1.git
mkdir dev01
echo "Subscribe share like " > dev01/file1
git add .
git commit -a -m "Add files and directories"
git push origin master
git clone http://user1@debian.example.com//user1.git
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment