Set custom boot for Ubuntu 15.04/CentOS 7.0

Source: Internet
Author: User

Set custom boot for Ubuntu 15.04/CentOS 7.0

Ubuntu 15.x/CentOS 7.x and later enable boot, add custom system services, and customize boot.

Ubuntu 15.04 is installed with the LANMPS package today. After it is installed, it cannot be set after it is started and cannot be started. You can see the new features of Ubuntu 15.04:

Systemd -- the Ubuntu 15.04 service manager has been switched to Systemd;

Unity 7.3 -- the Unity desktop version is upgraded to 7.3, which contains many minor optimizations;

Compiz 0.9.12 -- upgrade the window manager to 0.9.12;

Linux Kernel 3.19

Ubuntu System Service Script directory:

/Lib/systemd/system/

CentOS System Service Script directory:

/Usr/lib/systemd/

There are systems and users,

If you need to start a program that can run without logging on to the system, it exists in the system service, namely:

/Lib/systemd/system/

Otherwise, the program that can run only after the user logs on exists in the user

The service ends with. service.

The following uses nginx as an example.

1. Create a service file

Vim/lib/systemd/system/nginx. service

[Unit]
Description = nginx
Afterdomainnetwork.tar get
 
[Service]
Type = forking
ExecStart =/www/lanmps/init. d/nginx start
ExecReload =/www/lanmps/init. d/nginx restart
ExecStop =/www/lanmps/init. d/nginx stop
PrivateTmp = true
 
[Install]
Wantedbypolicmulti-user.tar get

[Unit]: Service Description

Description: describes the service.
After: Describes the service category.

[Service] Service running parameter settings

Type = forking is the form of background running
ExecStart is the specific running command of the service.
ExecReload is the restart command
ExecStop is the Stop command
PrivateTmp = True indicates that an independent temporary space is allocated to the service.
Note: the absolute path is required for the [Service] startup, restart, and stop commands.

[Install] service installation settings, which can be set to multiple users

2. Save the Directory
Save as 754 permissions in the directory:

/Lib/systemd/system

3. Set auto-start upon startup

Systemctl enable nginx. service

4. Other commands

New commands of old task commands
Enable a service to automatically start chkconfig -- level 3 httpd on systemctl enable httpd. service
So that a service does not automatically start chkconfig -- level 3 httpd off systemctl disable httpd. service
Check service status service httpd status systemctl status httpd. service (service details)
Systemctl is-active httpd. service (only show whether it is Active)
Show all started services chkconfig -- list systemctl list-units -- type = service
Start a service httpd start systemctl start httpd. service
Stop a service httpd stop systemctl stop httpd. service
Restart a service httpd restart systemctl restart httpd. service


Start the nginx Service

Systemctl start nginx. service

Systemctl enable nginx. service stop and start automatically

Systemctl disable nginx. service to view the current service status

Systemctl status nginx. service Restart service

Systemctl restart nginx. service view all started services

Systemctl list-units -- type = service

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.