安装配置CentOS7服务器的实操原始记录
- 聚客宝
- 2021-08-06 15:49:36
(1)制作安装U盘,使用(1)usbwrite软件,(2)linux的安装iso文件,(3)一个U盘,
用usbwrite软件制作出来centos安装盘。
(2)按照开始,直接选择英文版本,设置时区时,无法设置网络对时,感觉很奇怪,觉得网络没有配置好。反复折腾几遍。发现问题在于,应该首先把网络打开,由于是英文版本,对于英文不敏感导致的这种问题。配置第一屏,需要设置的项目应该有以下几项:
1)设置网络,把网络打开,可以查看IP地址等网路信息;
2)设置时区,选择所在时区,网路通畅则会自动打开网路对时;
3)选择安装磁盘,用过的硬盘,在选中以后,会提示处理原来的数据,选择delete all,删除原有的数据;
(3)安装setup网络配置命令
[root@localhost ~]# yum install setup
[root@localhost ~]# yum info setup
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Installed Packages
Name : setup
Arch : noarch
Version : 2.8.71
Release : 9.el7
Size : 681 k
Repo : installed
From repo : base
Summary : A set of system configuration and setup files
URL : https://pagure.io/setup/
License : Public Domain
Description : The setup package contains a set of important system configuration and
: setup files, such as passwd, group, and profile.
[root@localhost ~]# yum install -y setuptool
[root@localhost ~]# yum info setuptool
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Installed Packages
Name : setuptool
Arch : x86_64
Version : 1.19.11
Release : 8.el7
Size : 146 k
Repo : installed
From repo : base
Summary : A text mode system configuration tool
URL : http://git.fedorahosted.org/git/?p=setuptool.git
License : GPLv2+
Description : Setuptool is a user-friendly text mode menu utility which allows you
: to access all of the text mode configuration programs included in the
: operating system distribution.
(4)SElinux服务默认是启动的
[root@localhost ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
如何关闭SELinux服务
通过配置文件调整SELinux的参数,修改以后需要重新启动系统
[root@www ~]# vi /etc/selinux/config
SELINUX=disabled <==调整 enforcing|disabled|permissive
SELINUXTYPE=targeted <==目前仅有 targeted 与 strict
(5)iptables.service
默认没有安装
(6)firewalld.service默认安装启动状态
[root@localhost ~]# systemctl status iptables.service
Unit iptables.service could not be found.
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2018-09-02 12:17:10 CST; 3min 2s ago
Docs: man:firewalld(1)
Main PID: 759 (firewalld)
CGroup: /system.slice/firewalld.service
└─759 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Sep 02 12:17:10 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 02 12:17:10 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
关闭服务,关闭自启动
systemctl stop firewalld.service
systemctl disable firewalld.service
(7)安装补充软件
links
eog
vim
setup
setuptool
(8)查看硬盘
[root@localhost ~]# fdisk -l
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x2c903157
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1953525167 976761560 83 Linux
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sda: 120.0 GB, 120034123776 bytes, 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: D26EECB3-516F-441C-814B-16586FF27138
# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 2508799 1G Microsoft basic
3 2508800 234440703 110.6G Linux LVM
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xabeb4f4d
Device Boot Start End Blocks Id System
/dev/sdc1 2048 1953525167 976761560 83 Linux
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 8388 MB, 8388608000 bytes, 16384000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-home: 56.7 GB, 56665047040 bytes, 110673920 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
(9)硬盘格式化
[root@localhost /]# mkfs.xfs -f /dev/sdb
meta-data=/dev/sdb isize=512 agcount=4, agsize=61047662 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=244190646, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=119233, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost /]# mkfs.xfs -f /dev/sdc
meta-data=/dev/sdc isize=512 agcount=4, agsize=61047662 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=244190646, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=119233, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost /]# fdisk -l
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sda: 120.0 GB, 120034123776 bytes, 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: D26EECB3-516F-441C-814B-16586FF27138
# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 2508799 1G Microsoft basic
3 2508800 234440703 110.6G Linux LVM
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 8388 MB, 8388608000 bytes, 16384000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-home: 56.7 GB, 56665047040 bytes, 110673920 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
(10)配置web目录及ftp目录
结构
www/wroot/web80/
1)wroot为ftp80上传目录
2)web80为虚拟主机的根目录
3)创建ftp80本地用户,用户目录为wroot,归属ftp组
4)虚拟主机目录的用户为ftp80,用户组为ftp
操作步骤
1)创建本地用户ftp80
[root@localhost /]# passwd ftp80
Changing password for user ftp80.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost www]# touch /etc/vsftpd/chroot_list
#访问权限的配置,可以把同一个目录下的虚拟主机做统一配置部署;
<Directory "/www/wroot/web80">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
#虚拟主机列表
<VirtualHost *:80>
ServerName m.zbca.com
DocumentRoot "/www/wroot/web80/m.zbca.com"
</VirtualHost>
<VirtualHost *:80>
ServerName n.zbca.com
DocumentRoot "/www/wroot/web80/n.zbca.com"
</VirtualHost>
网站根目录的父目录,必须对网站有读取的权限才可以
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /www/wroot/web80/app.4800.cn/config.php:1) in /www/wroot/web80/app.4800.cn/app/model/admin/yloginModel.php on line 56
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /www/wroot/web80/app.4800.cn/config.php:1) in /www/wroot/web80/app.4800.cn/app/model/admin/yloginModel.php on line 56
Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in /www/wroot/web80/app.4800.cn/app/model/admin/yloginModel.php on line 59
Warning: Cannot modify header information - headers already sent by (output started at /www/wroot/web80/app.4800.cn/config.php:1) in /www/wroot/web80/app.4800.cn/app/view/admin/yloginView.php on line 21
congfig文件编码有问题,在启动session前有输出,重新把config.php文件复制到记事本上折腾了一遍,恢复正常;
回顾问题
(1)配置vhost.conf以后无法访问,配置前,可以直接打开apache欢迎页面
问题解决:网站的父目录wroot没有对组用户开发权限,导致对于ftp(apache设置的用户)没有访问该网站文件的权限
(2)上传网站后无法访问
1)数据库的连接函数错误,上次已经修改,这次仍然没有修改过来
mysqli_conection()参数没有端口号不行
2)Cannot send session cookie - headers already sent by
尝试打开session.auto_start=1 没有起作用
重新把congfig文件用记事本uft-8导了一遍