这里主要举例nginx、redis、frp,其他类似。
nginx编译安装:
useradd -s /bin/false -M nginx
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_v2_module \
--with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
make && make install
##nginx 注册服务
cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPost=/bin/sleep 0.1
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start nginx
systemctl enable nginx
systemctl stop nginx
redis编译安装:
cd redis-xxx
make && make test && make install
###redis 注册服务
cat /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis server v5.0.8 daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /data/redis/conf/redis.conf --daemonize yes
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/usr/local/bin/redis-cli -p 6379 -a password shutdown
User=root
Group=root
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start redis
systemctl enable redis
systemctl stop redis
frp注册服务:
cat /usr/lib/systemd/system/frpc.service
[Unit]
Description=Frp Client Service
After=network.target
[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/opt/frp/frpc -c /opt/frp/frpc.ini
ExecReload=/opt/frp/frpc reload -c /opt/frp/frpc.ini
[Install]
WantedBy=multi-user.target
systemctl start frpc
systemctl enable frpc
|