Linux 第五天

作者: 王利桢 | 来源:发表于2019-07-02 23:04 被阅读0次

命令别名 目录别名 重定向

命令别名 目录别名 重定向

Linux 第五天:

扩展:

命令别名:

进入:

vim /root/.bashr

加入两行代码:

alias sta='/usr/local/apache2/bin/apachectl start'

alias sto='/usr/local/apache2/bin/apachectl stop'

保存退出:

wq

使命令生效:

source /root/.bashrc

目录别名:

创建一个目录:

mkdir mkdir /usr/local/apache2/shop/

进入shop目录:

cd /usr/local/apache2/shop/

创建一个文件:

vim index.html

进入配置文件:

vim /usr/local/apache2/etc/httpd.conf

更改配置文件:(去掉前面的注释)

Include etc//extra/httpd-autoindex.conf

进入子配置文件:

vim /usr/local/apache2/etc/extra/httpd-autoindex.conf

更改子配置文件:

原文件:

Alias /icons/ "/usr/local/apache2//icons/"

<Directory "/usr/local/apache2//icons">

    Options Indexes MultiViews

    AllowOverride None

    Require all granted

</Directory>

更改为:

Alias /shop/ "/usr/local/apache2/shop/"

<Directory "/usr/local/apache2/shop">

    Options Indexes MultiViews

    AllowOverride None

    Require all granted

</Directory>

将shop下的index.html改为index.php:

mv index.html index.php

进入默认配置文件:

vim /usr/local/apache2/etc/httpd.conf

修改默认配置文件:

修改:

<IfModule dir_module>

    DirectoryIndex index.html index.php

</IfModule>

重启Apache:

sta

sto

虚拟主机分配一个域名 一个ip 一个服务器 两个目录:

域名A -- ip -- 服务器 -- /目录A

域名B -- ip -- 服务器 -- /目录B

实验:shop.com  xiangxiang.com

A:域名解析

C:\Windows\System32\drivers\etc\hosts

Linux在hosts中的域名配置修改 虚拟地址ip

192.168.241.131 www.ss38.com

192.168.241.131 www.oto38.com

A:网站目录规划

新建目录

mkdir -p /share/ss38/

新建文件

vim /share/ss38/index.html/

B:网站目录规划

新建目录

mkdir share/oto38/

新建文件

vim /share/oto38/index.html

修改主配置文件

vim /usr/local/apache2/etc/httpd.conf

去掉#号

#Include etc//extra/httpd-vhosts.conf

A:修改子配置文件

vim /usr/local/apache2/etc/extra/httpd-vhosts.conf

添加到里面:

<Directory "/share/ss38" >

        Options Indexes

        AllowOverride None

        Require all granted

</Directory>

<VirtualHost 192.168.241.131>

    ServerAdmin webmaster@ss38.com

    DocumentRoot "/share/ss38"

    ServerName www.ss38.com

    ErrorLog "logs/ss38.com-error_log"

    CustomLog "logs/ss38.com-access_log" common

</VirtualHost>

B:修改子配置文件

vim /usr/local/apache2/etc/extra/httpd-vhosts.conf

添加到里面:

<Directory "/share/oto38" >

        Options Indexes

        AllowOverride None

        Require all granted

</Directory>

<VirtualHost 192.168.241.131>

    ServerAdmin webmaster@oto38.com

    DocumentRoot "/share/oto38"

    ServerName www.oto38.com

    ErrorLog "logs/ss38.com-error_log"

    CustomLog "logs/ss38.com-access_log" common

</VirtualHost>

重定向:访问不同的域名跳转到相同的页面 多个域名对应一个ip

进入主配置文件:

vim /usr/local/apache2/etc/httpd.conf

修改(已修改好的):

<Directory "/share/ss38" >

        Options Indexes FollowSymLinks

        AllowOverride All

        Require all granted

</Directory>

进入ss38目录:

cd /share/ss38

添加一个文件:

vim .htaccess

在.htaccess文件中写入:

#开启重启功能

RewriteEngine on

RewriteCond %{HTTP_HOST} ss38.com

#输入地址全部跳转到oto38.com这个网站

RewriteRule .* http://www.oto38.com

保存退出:

wq

重启服务:

sta

sto

结果:

www.oto38.com 输出的是 www.oto38.com网站信息

www.ss38.com 输出的也是www.oto38.com网站信息

实现了多域名 访问同一个ip的功能

相关文章

  • Linux 第五天

    命令别名 目录别名 重定向 Linux 第五天: 扩展: 命令别名: 进入: vim /root/.bashr 加...

  • Linux运维初步---第三周

    写作:N27_loong 2017-7-27[TOC] 一 本周内容回顾 学习要点 第五天:1、Linux文件权限...

  • Linux学习第五天

    用户账户的管理 一、用户账户和组账户概述 用户和用户组管理,顾名思义就是添加用户和用户组、更改密码和设定权限等操作...

  • 学习Linux的第五天

    个人电脑的内存主要组件为动态随机存取内存(Dynamic Random Access Memory,DRAM);R...

  • Linux Shell命令及配置安装手册

    Linux 教程 Linux 教程、Linux 简介、Linux 安装、Linux 系统启动过程、Linux 系统...

  • Linux命令行使用教程

    Linux基本单词 Linux缩写 Linux目录 Linux操作 Linux技巧 Linux自学命令行办法

  • 面试题 2021-11-01~2021-11-12

    常用的Linux命令 Linux命令 - Linux安全网 - Linux操作系统_Linux 命令_Linux教...

  • 远程桌面 linux

    Windows远程Linux、Linux远程Windows或Linux远程Linux Windows远程Linux...

  • 悦读会第五天

    第五天啦! 第五天啦! 第五天啦! 快来欣赏一下同学们认认真真阅读的美照~ ...

  • Linux简单介绍

    Linux 相关Linux 下的一些特点Linux 小练习Linux 文件权限Linux 命令-chmodLinu...

网友评论

    本文标题:Linux 第五天

    本文链接:https://www.haomeiwen.com/subject/bhmxhctx.html