Installing GitLab
GitLab - Installation(Traditional Way)
1. Install related dependencies
1 |
|
2. Start the ssh
service & set it to start on boot
1 |
|
3. Set postfix
to start automatically after booting, and start it, postfix
supports gitlab sending function
1 |
|
4. Open ssh and http services, then reload the firewall list
1 |
|
5. Download the gitlab package and install the online download installation package
Download
1 |
|
Install
1 |
|
6. Modify gitlab configuration
1 |
|
external_url 'http://192.168.66.100:82'
nginx['listen_port'] = 82
7. Reload configuration and startup gitlab
1 |
|
8. Add port to firewall
1 |
|
GitLab - Installation(with Docker)
1. Installing Docker:
- If you haven’t installed Docker yet, you first need to install it on your system. You can download the installation package for your operating system from the official Docker website.
- Installing Docker Related Url
2. Pulling a GitLab Mirror:
- Use Docker commands to pull GitLab images from Docker Hub. You can use the following commands:
1
docker pull gitlab/gitlab-ce:latest
3. Configure the Docker container and start GitLab:
- You need to configure some parameters of the GitLab container, such as port mapping, data volumes, and so on. Here’s a simple sample command to start the GitLab container:
1
2
3
4
5
6
7
8
9docker run --detach \
--hostname gitlab.example.com or your_ip \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest - This command starts a GitLab container and binds it to ports 80 (HTTP), 443 (HTTPS), and 22 (SSH) on the host. It also sets up some persistent storage volumes so that GitLab data is not lost when the container is restarted.
4. Accessing and Configuring GitLab:
- Once the container is started, you can access GitLab through your browser. the first time you access it, you may need to set an administrator password.
- Visit
http://<your host IP or domain name>
to access GitLab.
5. Follow-up maintenance:
- To update GitLab, you can pull the latest GitLab image and restart your container.
Be sure to adjust the configurations in the above commands, such as domain name, port mapping, and paths to data volumes, to your actual needs. If your environment has special network or security requirements, you will also need to adjust accordingly.
6. Other
0. Cat Password(Docker)
1 |
|
1. Rest root
password
If you need to reset the administrator password within a GitLab container, you can follow these steps:
Enter the Bash Session of the GitLab Container:
- First, identify the name or ID of your GitLab container. You can use
docker ps
to see a list of running containers. - Enter the GitLab container’s bash session by running:
1
docker exec -it [your-gitlab-container-name] bash
- First, identify the name or ID of your GitLab container. You can use
Run the GitLab Rake Command to Reset Password:
- Inside the bash session of the GitLab container, run the following command to access the GitLab Rails console:
1
gitlab-rails console -e production
- This will open a Ruby on Rails console. In this console, execute the following commands to change the
root
user’s password:1
2
3
4user = User.find_by(username: 'root')
user.password = 'yournewpassword'
user.password_confirmation = 'yournewpassword'
user.save! - Replace
'yournewpassword'
with the new password you wish to set.
- Inside the bash session of the GitLab container, run the following command to access the GitLab Rails console:
Exit the Console and Container:
- After completing the above steps, type
exit
to leave the Ruby on Rails console and typeexit
again to leave the container’s bash session.
- After completing the above steps, type
Login Using the New Password:
- After resetting the password, try logging into GitLab using the
root
username and the new password you just set.
- After resetting the password, try logging into GitLab using the
Make sure to use a strong password for security reasons. If you encounter any issues during these steps, refer to the official GitLab documentation, as commands may slightly vary with different versions of GitLab.
2. WSL2 network Problem
If you are running the GitLab Docker container in a Windows Subsystem for Linux 2 (WSL2) environment, you can access it in a few steps:
Determine the IP address of the WSL2:
- Opening a terminal in a WSL2 environment.
- Execute the command
ip addr
to find the IP address of your WSL2 instance. Normally this address is displayed under theeth0
interface, similar toinet 172.25.x.x/20
.
Configuring and Starting GitLab Containers:
- In WSL2, start the GitLab container using the Docker commands mentioned earlier. Use the IP address of WSL2 in the
--hostname
parameter.
- In WSL2, start the GitLab container using the Docker commands mentioned earlier. Use the IP address of WSL2 in the
Accessing GitLab from Windows:
- On your Windows host, open a browser.
- Enter the IP address of the WSL2 instance, e.g.
http://172.25.x.x
(replace it with the actual WSL2 IP address).
**Configure port forwarding (if required)**:
- If you do not have direct access to the WSL2 IP, you may need to configure port forwarding on Windows.
- To do this, use a similar command in PowerShell:
1
netsh interface portproxy add v4tov4 listenport=80 listenaddress=0.0.0.0 connectport=80 connectaddress=172.25.x.x
- This command forwards port 80 on the Windows host to the appropriate port on the WSL2.
Note:
- The WSL2’s network configuration may have changed since the reboot. If you find that you cannot access GitLab, you may need to recheck the WSL2’s IP address and update the port forwarding settings.
- Make sure that Windows Firewall or any security software does not block access to these ports.
- If you want to remove the above web proxy rules:As a result, you should be able to access your GitLab instance running on WSL2 from your Windows environment. If you encounter any network connectivity issues, check your network settings and firewall rules.
1
netsh interface portproxy delete v4tov4 listenport=80 listenaddress=0.0.0.0