centos中/etc/sysconfig/network-scripts/路径下没有ifcfg-eth0 怎么回事
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos中/etc/sysconfig/network-scripts/路径下没有ifcfg-eth0 怎么回事相关的知识,希望对你有一定的参考价值。
虚拟机下安装centos,/etc/sysconfig/network-scripts/路径下没有ifcfg-eth0 怎么回事,输入ifconfig可以看到eth0,可是那个路径里边为什么没有那个配置文件呢?我find / -name ifcfg-eth0都找不到,求解。。。
没有该文件可以手动创建
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
IPADDR=192.168.0.1
NETMASK=255.255.0.0
GATEWAY=192.168.0.254
ONBOOT=yes
保存退出:wq
重启服务service network restart
【虚拟机下安装centos方法】
第一步,启动虚拟机,并进行新建---虚拟机··
选择 从镜像安装,吧里有6.3镜像下载的链接的 然后, 下一步
选择客户机版本然后下一步
命名以及更改客户机占用空间的位置,建议是更改至空间较大的位置
设置分配空间的大小
如果对客户机硬件有需求的,可以进行定制硬件,如果没有,可以直接下一步
参考技术A ifcfg-lo 这是我的网卡,不见得是ifcfg-eth0 你可以用IP ADDR 看一下,就知道你的网卡是什么了 参考技术B create it:DEVICE
BOOTPROTO
IPADDR
NETMASK
ONBOOT 参考技术C 没有该文件可以手动创建vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
IPADDR=192.168.0.1
NETMASK=255.255.0.0
GATEWAY=192.168.0.254
ONBOOT=yes
保存退出:wq
重启服务service network restart本回答被提问者采纳 参考技术D
没有的话,你可以手动创建的,一般默认内容如下:
DEVICE=eth0BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=08:00:27:c8:2a:1c
CentOS 6.8 LAMP 安装配置
1.远程系统拒绝了连接:
需要关闭防火墙
/etc/rc.d/init.d/iptables stop
service iptables stop
chkconfig iptables off
setenforce 0
vi
/etc/sysconfig/selinux
SELINUX=disabled
#enforcing改为disabled
yum -y
install
gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel
bzip2
bzip2
-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers
make
libtool* git tree bison pcre-devel perl gd gd-devel
安装libiconv(支持编码转换为函数)
wget https://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
tar
xf libiconv-1.14.
tar
.gz
cd
libiconv-1.14/
.
/configure
--prefix=
/usr/local/libconv/
make
&&
make
install
tar xf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
cd libltdl/
./configure --enable-ltdl-install #加载动态库
make && make install
tar
xf mhash-0.9.9.9.
tar
.bz2
cd
mhash-0.9.9.9
.
/configure
make
&&
make
install
vim
/etc/ld
.so.conf
/usr/local/lib/
ldconfig
cd
/usr/local/src
tar
zxvf mcrypt-2.6.8.
tar
.gz
cd
mcrypt-2.6.8/
export
LD_LIBRARY_PATH=
/usr/local/lib
:$LD_LIBRARY_PATH
#暂时生效
.
/configure
make
&&
make
install
tar
xf cmake-3.4.1.
tar
.gz
cd
cmake-3.4.1
.
/bootstrap
make
&&
make
install
新增mysql用户
1
2
|
groupadd -r mysql useradd -r -g mysql mysql |
新建MySQL所需目录
1
2
|
mkdir -p /usr/local/mysql mkdir -p /data/mysqldb |
编译安装
1
2
3
4
|
wget http://pkgs.fedoraproject.org/repo/pkgs/community-mysql/mysql-5.6.23.tar.gz/md5/60344f26eae136a267a0277407926e79/mysql-5.6.23.tar.gz
tar xf mysql-5.6.23. tar .gz cd mysql-5.6.23 cmake -DCMAKE_INSTALL_PREFIX= /usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1-DMYSQL_DATADIR= /data/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1-DSYSCONFDIR= /etc -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 make && make install |
修改mysql目录权限
1
2
3
4
|
cd /usr/local/mysql chown -R mysql:mysql . cd /data/mysqldb chown -R mysql:mysql . |
初始化mysql数据库
1
2
|
cd /usr/local/mysql . /scripts/mysql_install_db --user=mysql --datadir= /data/mysqldb |
编译修改/etc/my.cnf (这里可能因为mysql 默认root用户也只有读和执行的权限,所以要chmod 644 my.conf)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
[mysql] # CLIENT # port = 3306 socket = /data/mysqldb/mysql .sock [mysqld] # GENERAL # user = mysql default-storage-engine = InnoDB socket = /data/mysqldb/mysql .sock pid- file = /data/mysqldb/mysql .pid # MyISAM # key-buffer-size = 32M myisam-recover = FORCE,BACKUP # SAFETY # max-allowed-packet = 16M max-connect-errors = 1000000 # DATA STORAGE # datadir = /data/mysqldb/ # BINARY LOGGING # log-bin = /data/mysqldb/mysql-bin expire-logs-days = 14 sync -binlog = 1 # REPLICATION # skip-slave-start = 1 relay-log = /data/mysqldb/relay-bin slave-net-timeout = 60 # CACHES AND LIMITS # tmp-table-size = 32M max-heap-table-size = 32M query-cache- type = 0 query-cache-size = 0 max-connections = 500 thread-cache-size = 50 open -files-limit = 65535 table-definition-cache = 4096 table- open -cache = 4096 # INNODB # innodb-flush-method = O_DIRECT innodb-log-files- in -group = 2 innodb-log- file -size = 64M innodb-flush-log-at-trx-commit = 1 innodb- file -per-table = 1 innodb-buffer-pool-size = 592M # LOGGING # log-error = /data/mysqldb/mysql-error .log log-queries-not-using-indexes = 1 slow-query-log = 1 slow-query-log- file = /data/mysqldb/mysql-slow .log |
同时,这个时候可能会出现报错:
在my.conf中加入
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
explicit_defaults_for_timestamp=true
复制MySQL启动文件及其命令加入PATH
1
2
3
4
5
|
cp support-files /mysql .server /etc/init .d /mysqld vim /etc/profile .d /mysql .sh PATH= /usr/local/mysql/bin : /usr/local/mysql/lib :$PATH export PATH source /etc/profile .d /mysql .sh |
启动MySQL并增加启动项
1
2
|
service mysqld start chkconfig mysqld on |
设置MySQL登录权限
1
2
3
4
|
drop user \'\' @localhost; drop user \'\' @ hostname ; update mysql.user set password=password( \'*******\' ); flush privileges; |
四、Nginx编译安装
新增nginx用户
1
2
|
groupadd -r nginx useradd -g nginx -r nginx |
创建所需要目录
1
|
mkdir -pv /var/tmp/nginx/client |
编译安装nginx
1
2
3
4
|
tar xf nginx-1.9.14. tar .gz cd nginx-1.9.14 . /configure --prefix= /usr/local/nginx --sbin-path= /usr/local/nginx/sbin/nginx --conf-path= /etc/nginx/nginx .conf --error-log-path= /var/log/nginx/error .log --http-log-path= /var/log/nginx/access .log --pid-path= /var/run/nginx/nginx .pid --lock-path= /var/lock/nginx .lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path= /var/tmp/nginx/client/ --http-proxy-temp-path= /var/tmp/nginx/proxy/ --http-fastcgi-temp-path= /var/tmp/nginx/fcgi/ --http-uwsgi-temp-path= /var/tmp/nginx/uwsgi --http-scgi-temp-path= /var/tmp/nginx/scgi --with-pcre make && make install |
编辑启动脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
vim /etc/rc .d /init .d /nginx #!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \\ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pid # Source function library. . /etc/rc .d /init .d /functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx= "/usr/local/nginx/sbin/nginx" prog=$( basename $nginx) NGINX_CONF_FILE= "/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile= /var/lock/subsys/nginx make_dirs() { # make required directories user=`nginx -V 2>&1 | grep "configure arguments:" | sed \'s/[^*]*--user=\\([^ ]*\\).*/\\1/g\' -` options=`$nginx -V 2>&1 | grep \'configure arguments:\' ` for opt in $options; do if [ ` echo $opt | grep \'.*-temp-path\' ` ]; then value=` echo $opt | cut -d "=" -f 2` if [ ! -d "$value" ]; then # echo "creating" $value mkdir -p $value && chown -R $user $value fi fi done } start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 make_dirs echo -n $ "Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval - eq 0 ] && touch $lockfile return $retval } stop() { echo -n $ "Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval - eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop sleep 1 start } reload() { configtest || return $? echo -n $ "Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status > /dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 |