Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set CentOS server initialization

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "how to initialize the CentOS server", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to initialize the CentOS server" article.

Mount the hard disk

1. Disk partition

When fdisk-l # looks at the device, you can generally see that the device name is / dev/xvdb

Fdisk / dev/xvdb # partitions the disk

Enter n # to create a new partition

Enter p # to create the primary partition

Enter 1 # to create the first primary partition

Enter w # to save and execute the above command to create a partition

After the above command has been executed, look at it using fdisk-l, and you will see something like this

Partition of / dev/xvdb1

Indicates that the partition was successful.

2. Disk formatting

Mkfs.ext4 / dev/xvdb1 # formatting partitions (www.jb51.net)

Description: ext4 is the default partition format for centos6.x. Please use ext3 for centos5.x.

After the formatting is complete (the time required for formatting varies according to the size of the partition, please wait patiently), mount the partition

3. Mount the disk

For example: to mount / dev/xvdb1 to the / data directory

Mkdir-p / data # create directory

Mount / dev/xvdb1 / data # mount

Df-h # View the mount result

Vi / etc/fstab # sets auto-mount on boot. Enter the following code on the last line

/ dev/xvdb1 / data ext4 defaults 0 0

: wq! # Save exit

Mount-a # makes the partition settings take effect immediately

Modify the language environment

[root@oracledb ~] # sudo vim / etc/sysconfig/i18n

Change zh_ch to "en_us.utf-8"

Set up yum local source

Methods to be continued

Vsftpd installation configuration

Reference: centos configuration vsftp server

Yum install vsftpd

Set vsftpd to boot

Last login: tue aug 12 08:21:26 2014 from l-001812.lan

[root@oracledb ~] # chkconfig-- list | grep vsftpd

Vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@oracledb ~] # chkconfig vsftpd on

[root@oracledb ~] # chkconfig-- list | grep vsftpd

Vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@oracledb ~] #

Configure the firewall

Open the / etc/sysconfig/iptables file

1.vi / etc/sysconfig/iptables

Add the following code before the reject line

1.What input-m state-- state new-m tcp-p tcp-- dport 21-j accept

Save and close the file, restart the firewall

1.service iptables restart

Create a ftp connection with active connection mode and utf8 character set (optional)

Modify ftp access permissions

Use the command getsebool-a | grep ftp to view

[root@oracledb vsftpd] # getsebool-a | grep ftp

Allow_ftpd_anon_write-- > off

Allow_ftpd_full_access-- > off

Allow_ftpd_use_cifs-- > off

Allow_ftpd_use_nfs-- > off

Ftp_home_dir-- > off

Ftpd_connect_db-- > off

Ftpd_use_fusefs-- > off

Ftpd_use_passive_mode-- > off

Httpd_enable_ftp_server-- > off

Tftp_anon_write-- > off

Tftp_use_cifs-- > off

Tftp_use_nfs-- > off

Check to see if the above red is on

If not, use the

Setsebool allow_ftpd_full_access on

Setsebool ftp_home_dir on

[root@oracledb vsftpd] # getsebool-a | grep ftp

Allow_ftpd_anon_write-- > off

Allow_ftpd_full_access-- > on

Allow_ftpd_use_cifs-- > off

Allow_ftpd_use_nfs-- > off

Ftp_home_dir-- > on

Ftpd_connect_db-- > off

Ftpd_use_fusefs-- > off

Ftpd_use_passive_mode-- > off

Httpd_enable_ftp_server-- > off

Tftp_anon_write-- > off

Tftp_use_cifs-- > off

Tftp_use_nfs-- > off

Vi / etc/profile / / add # set java environment export java_home=/usr/local/javaexport classpath=./:$java_home/lib:$java_home/jre/libexport path=$path:$java_home/bin to the end of the file

Set static ip address

Centos sets the ip address in the desktop environment, but cannot log in through ssh after restart. You must log in to your account under the desktop and start eth0 before you can be connected by ping. Therefore, under the desktop settings can not be turned on to enable the network card, you must modify the configuration file.

If we want to change the host address to a static address or change the host name, several files that need to be modified include:

/ etc/sysconfig/network set hostname and network configuration

/ etc/sysconfig/network-scripts/ifcfg-eth0 is set for a specific network card

/ etc/resolv.conf sets dns

/ etc/hosts sets the specified domain name resolution address

Generally speaking, we only need to modify the configuration file ifcfg-eth0 of the network card. The method of modification is as follows

Vim / etc/sysconfig/network-scripts/ifcfg-eth0

Edit configuration file

[root@map ~] # vim / etc/sysconfig/network-scripts/ifcfg-eth0device=eth0 type=ethernetuuid=1e3f09ce-74aa-4d8b-9988-a6db9aef4d32onboot=yesnm_controlled=yesbootproto=statichwaddr=00:50:56:b8:37:90ipaddr=10.138.16.144netmask=255.255.255.0prefix=24gateway=10.138.16.254defroute=yesipv4_failure_fatal=yesipv6init=noname= "system eth0"

explain

Device=eth0 # describes the device alias corresponding to the network card. For example, in the ifcfg-eth0 file, it sets the way for the network card to obtain the ip address for eth0bootproto=static #. The possible options are static,dhcp or bootp, corresponding to the statically specified ip address, respectively, and the ip address obtained through the dhcp protocol. The ip address broadcast=192.168.0.255 # corresponding to the subnet broadcast address hwaddr=00:07:e9:05:e8:b4 # the physical address of the network card ipaddr=12.168.1.2 # ip address ipv6init=no / / obtained through the bootp protocol may or may not be added with or without the network mask corresponding to the netmask=255.255.255.0 # network card gateway=10.138.16.254 # gateway onboot=yes # whether this network interface is set when the system starts, when it is set to yes Activate this device when the system starts

Restart to make the configuration effective

Service network restart

The above is about the content of this article on "how to initialize the CentOS server". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report