# Installing Gitlab on Ubuntu ## Links - [Download and install GitLab | GitLab](https://about.gitlab.com/install/#ubuntu) - [How To Install and Configure Postfix on Ubuntu 16.04 | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-on-ubuntu-16-04) - [Configure Postfix to Send Mail Using Gmail and Google Apps on Debian or Ubuntu | Linode](https://www.linode.com/docs/email/email-services/configure-postfix-to-send-mail-using-gmail-and-google-apps-on-debian-or-ubuntu/) - [Configure Postfix to use Mailgun SMTP Relay on Ubuntu •](https://guides.wp-bullet.com/configure-postfix-use-mailgun-smtp-relay-ubuntu/) - [git - Can't open ssh/authorized_keys of user - Stack Overflow](https://stackoverflow.com/questions/14819084/cant-open-ssh-authorized-keys-of-user) - [Set Up Postfix With Mailgun For Reliable E-Mail Delivery - Brian | Jamroom](https://www.jamroom.net/brian/documentation/guides/1312/set-up-postfix-with-mailgun-for-reliable-e-mail-delivery) - [How to restart GitLab | GitLab](https://docs.gitlab.com/ee/administration/restart_gitlab.html) - [NGINX Docs | Creating NGINX Plus and NGINX Configuration Files](https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/) - [Beginner’s Guide](http://nginx.org/en/docs/beginners_guide.html) - [How To Install and Configure GitLab on Ubuntu 16.04 | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-gitlab-on-ubuntu-16-04) - [How to Give All Permissions in Ubuntu | Small Business - Chron.com](https://smallbusiness.chron.com/give-permissions-ubuntu-33174.html#:~:text=Type%20%E2%80%9Csudo%20chmod%20a%2Brwx,file%20and%20folder%20inside%20it.) ## Notes ## Code ## SSH-KEY ## Linux installs `sudo apt-get install openssh-server` `sudo apt-get install ssh openssh-client openssh-server` `sudo apt install net-tools` `ip address` -- for ip address `ifconfig` -- for ip address Switch to bridged networking mode, make that change in the Virtual Machine Control Panel (Edit > Virtual Machine Settings) reboot the VM `sudo apt install openbsd-inetd` `cat ~/.ssh/id_rsa.pub` `ssh-keygen -t rsa -b 4096 -C "Your email"` `cat ~/.ssh/id_rsa.pub` `sudo vim ~/.ssh/authorized_keys` gg, dG - to clear all in vim now copy the keys ### Windows (on bash): `clip < ~/.ssh/id_rsa.pub` ### Mac: `pbcopy < ~/.ssh/id_rsa.pub` ### GNU/Linux (requires xclip): `sudo apt install xclip` `xclip -sel clip < ~/.ssh/id_rsa.pub` ## Install Postfix sudo apt-get update sudo apt-get install postfix libsasl2-modules mailutils -y ``` # See /usr/share/postfix/main.cf.dist for a commented, more complete version # Debian specific: Specifying a file name will cause the first # line of that file to be used as the name. The Debian default # is /etc/mailname. #myorigin = /etc/mailname smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h readme_directory = no # TLS parameters smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for # information on enabling SSL in the smtp client. myhostname = wp-bullet.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = wp-bullet.com, mail.wp-bullet.com, localhost.localdomain, localhost relayhost = [smtp.mailgun.org]:587 #limit to loopback address mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + #limit to loopback address inet_interfaces = loopback-only local_recipient_maps = proxy:unix:passwd.byname $alias_maps #where we specify the forwarding address to e.g. google virtual_maps = regexp:/etc/postfix/virtual-regexp #allow inet interfaces for SMTP - also allow submission inet in master.conf smtpd_client_restrictions = permit_inet_interfaces smtp_sasl_auth_enable = yes #set to your mailgun credentials smtp_sasl_password_maps = static:[PostMasterUserName]:[Password] #this is required for authentication to prevent the FROMTO error smtp_sasl_security_options = noanonymous ``` sudo vim /etc/mailname ``` # addYourDomainName smtp.mailgun.org ``` Try restart process and then run below code. echo "This is testing SMTP Relay." | mail -s "Postfix Mailgun" test@wp-bullet.com ### Restart PostFix sudo postfix check sudo systemctl restart postfix sudo service postfix restart sudo netstat -lntp | grep master sudo postmap /etc/postfix/virtual-regexp sudo service postfix reload tail -n 100 /var/log/mail.log get test email checker from https://www.mail-tester.com Add the given email to authorized email in the mailgun echo "This is testing SMTP Relay. 3 " | mail -s "Postfix Mailgun 2" [Use that testing email] ## Install Gitlabs ``` sudo apt-get update sudo apt-get install -y curl openssh-server ca-certificates tzdata curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee ``` ### Restart Gitlabs sudo gitlab-ctl restart ``` # Prevent users from writing to the repositories while you move them. sudo gitlab-ctl stop # Note there is _no_ slash behind 'repositories', but there _is_ a # slash behind 'git-data'. sudo rsync -av /var/opt/gitlab/git-data/repositories /mnt/nas/git-data/ # Start the necessary processes and run reconfigure to fix permissions # if necessary sudo gitlab-ctl reconfigure # Double-check directory layout in /mnt/nas/git-data. Expected output: # repositories sudo ls /mnt/nas/git-data/ # Done! Start GitLab and verify that you can browse through the repositories in # the web interface. sudo gitlab-ctl start ``` ## Permission Grant ``` sudo chmod a+rwx /etc/gitlab ```