##设定https虚拟主机并设定网页重写
cd /etc/httpd/conf.d ##cd到httpd的配置目录下写子配置
[root@apache conf.d]# ls
a_cgi.conf cgi.conf mxw.conf README welcome.conf
a_default.conf login.conf news.conf ssl.conf
autoindex.conf manual.conf php.conf userdir.conf
vim login.conf
<VirtualHost *:443> ##https的端口
ServerName login.westos.com
DocumentRoot /var/www/virutal/login.westos.com/html
CustomLog logs/login.log combined
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/www.awestos.com.crt ##申请过的证书
SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key ##密钥
</VirtualHost>
<Directory /var/www/virutal/login.westos.com/html> ##授权为发布目录
Require all granted
</Directory>
<VirtualHost *:80> ##http的默认端口
ServerName login.westos.com
RewriteEngine on ##打开重写引擎
RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]
</VirtualHost>
systemctl restart httpd ##重启服务
^(/.*)$ ##客户在浏览器地址栏中输入的所有字符
https:// ##强制客户加密访问
%{HTTP_HOST} ##客户请求访问的主机
$1 $1 标示 ^(/.*)$ 的值 (即客户输入要访问主机的域名或IP)
[redirect=301] ##临时重写 302永久转换
mkdir /var/www/virutal/login.westos.com/html ##创建目录
vim /var/www/virutal/login.westos.com/html/index.html ##编辑login的主页内容
测试 :
在网页输入域名 Add Exception… ##给这个域名添加https服务
重新刷新网页 https出现 并显示你编辑的login的主页
##mysql的安装与语法
yum search mariadb
yum install mariadb-server.x86_64 -y
systemctl start mariadb
vim /etc/my.cnf
yum install mysql mysql-server
mysqladmin -uroot -predhat password westos (-u 跟用户 -p 跟数据库密码 修改密码为westos) 修改本地mysql root密码
mysqladmin -uroot -predhat -h 192.168.0.188 password westos 修改远程192.168.0.188 mysql服务器 root密码
mysql_secure_installation 第一次安装mysql以后通过这条命令可以对mysql进行设置
[root@izwz9gql1520750fswaastz ~]# mysql_secure_installation -uroot ##初次设置mysql密码
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
mysql -uroot -predhat 从本机登录mysql数据库
show databases; 显示数据库
use mysql; 进入数据库
show tables; 显示数据库中的表
desc user; 查看user表的数据结构
flush privileges; 刷新数据库信息
select host,user,password from user; 查询user表中的host,user,password字段
create database westos; 创建westos数据库
use westos;
create table linux( 创建表,username,password字段
username varchar(15) not null,
password varchar(15) not null
);
select * from mysql.user; 查询mysql库下的user表中的所以
alter table linux rename messages;
alter table linux add age varchar(4); 添加age字段到linux表中
ALTER TABLE linux DROP age 删除age字段
ALTER TABLE linux ADD age VARCHAR(5) AFTER name 在name字段后添加字段age
show tables;
desc linux; ##查看表的字段
insert into linux values ('user1','passwd1'); 在linux表中插入值为username = user1,password = password1
update linux set password=password('passwd2') where username=user1; 更新linux表中user1 的密码为password2
delete from linux where username=user1; 删除linux表中user1的所以内容
##创建新用户别授权
mysql -uroot -p ##进入root数据库
create user lee@localhost(@% ##允许远程登陆) identified(adj.经鉴定的,被识别的) by 'lee' ##创建一个新的用户lee只能本地登陆密码为 lee
select user from mysal.user ##查看数据库用户
grant select on *.* to user1@localhost ##给这个用户全部数据库的查询权限
revoke select on *.* from user1@localhost ##取消这个用户的查询权限
grant select on *.* to user1@localhost identified by 'passwd1'; 授权user1 密码为passwd1 并且只能在本地 查询数据库的所以内容
grant all on mysql.* to user2@'%' identified by 'passwd2'; 授权user2 密码为passwd2 可以从远程任意主机登录mysql 并且可以对mysql数据库任意操作
##数据库的备份
mysqldump -uroot -p mxw(-p 跟密码直接进,不用再输入密码) mxw(数据库名) >/mnt/mxw.sql
mysqldump -u root -p mxw mxw --no-data ##只备份结构,不备份数据
--all-database ##备份全部数据库
--all-database --no-data ##备份数据库的结构 ,不备份插入的数据
测试:
备份好后删除数据库
恢复方式1
mysql -u root -p mxw -e "create database mxw" ##命令行直接建立数据库
mysqldump -uroot -p mxw mxw(数据库名) < /mnt/mxw.sql ##备份倒入数据库
恢复方式2:
vim /mnt/mxw.sql ##进入备份文件编辑
create database mxw; ##建数据库
use mxw; ##用数据库
mysqldump -uroot -p mxw mxw(数据库名) < /mnt/mxw.sql ##备份倒入数据库
mysqldump -uroot -predhat mysql > mysql.bak 备份mysql库到mysql.bak
mysql -uroot -predhat westos < mysql.bak 恢复mysql.bak 到westos库
##mysql root密码恢复
systemctl stop mariadb ##关闭mysql服务
mysqld_safe --skip-grant-tables & (&运行过程打入后台) ##跳过grant-tables授权表 不需要认证登录本地mysql数据库
ps aux | grep mysql ##查看mysql的所有进程
mysql ##直接进入mysql不需要密码
update mysql.user set password=password('mxw') where user='root'
ps aux | grep mysql ##查看进程
kill -9 7098
kill -9 7253 ##关闭所有关于mysql的进程
systemctl satrt mariadb ##打开mysql服务
mysqld_safe --skip-grant-tables & 跳过grant-tables授权表 不需要认证登录本地mysql数据库
update mysql.user set password=password('westos') where user='root'; 更新mysql.user 表中条件为root用户的密码为加密westos
##安装phpmyadmin数据库的图形管理
yum install php php-mysql -y ##下载
systemctl restart httpd
tar jxf phpmyadmin-*.tar.bz2 -C /var/www/html ##解压到默认发布目录下
mv phpmyadmin-*. mysqladmin ##把解压好的移动到mysqladmin下
cd mysqladmin ##cd到mysqladmin
cp config.sample.inc.php config.inc.php ##将解压好的配置文件复制一份为config.inc.php
vim config.inc.php ## 编辑config.inc.php
add
$cfg['blowfish_secret'] = 'test';
测试:
http://本机IP/mysqladmin