---
# System prepended metadata

title: nexus建置service

---

1.連接opt底下nexus至init.d

```
sudo ln -s /opt/nexus/nexus-3.69.0-02/bin/nexus /etc/init.d/nexus
```

1-1 配置完成使用指令

```
cd /etc/init.d
sudo chkconfig --add nexus
sudo chkconfig --levels 345 nexus on
sudo service nexus start
```

2.配置權限
```
sudo chown -Rv iqserver:sonatype /opt/sonatype/nexus/nexus-3.69.0-02
```
3.切換至system底下
```
cd /etc/systemd/system/
```
4.建置nexusRepository.service
```
sudo nano nexusRepository.service
```
內容如下
```
[Unit]
Description=nexus service
After=network.target
  
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/etc/init.d/nexus start
ExecStop=/etc/init.d/nexus stop 
User=nexus
Restart=on-abort
TimeoutSec=600

[Install]
WantedBy=multi-user.target
```

5.重新啟動 systemct
```
sudo systemctl daemon-reload
```

6.設置開機啟動 
```
sudo systemctl enable nexusRepository.service
```
7.啟動nexusRepository.service
```
sudo systemctl start nexusRepository.service
```


8.出現錯誤可以使用此持續監控
```
journalctl -u nexusRepository.service -f
```