Linux shell web,Linux入门--Xshell+Web Server之Apache

其实两者之间没什么前后关系,只不过是晚上一起完成的,就一起记录一下~

Xshell安装

a.网上自己下载一个安装包就欧了应该,然而我的是Xshell5(Free for Home/School),便携版本,连安装都不需要,直接打开就好了····

b.打开软件--新建会话:可以修改名字,必须输入主机名(ifconfig获得的ip)

c.点击 连接就可以进入啦,按要求输入用户名和密码(进入centos使用的),,,,

Apache

基本操作:

a. yum install httpd       ------安装apache (Apache在Linux系统中,叫“httpd”)

b. 1.    service httpd start          2.    systemctl start httpd.service     -------开启apache

c. 1.    service httpd stop          2.    systemctl stop httpd.service     -------关闭apache

d. 1.    service httpd  restart          2.    systemctl restart httpd.service     -------重启apache

这时候可以尝试一下输入自己本机ip。就可以出现apache的页面啦~

配置虚拟主机(ip或者网址显示本地html测试)

a.新建/data/www目录:(mkdir -p)

b.新建index.html,随便输入一些文字(vi index.html   当然方法很多)

c.  vim /etc/httpd/conf/httpd.conf

d.搜索到virtual,在下面添加配置:(具体文字:virtual host being define,可以用set number 看行号。大概在78)

ServerName www.imooc.test

DocumentRoot /data/www

Options Indexes FolllowSymLinks

AllowOverride None

Require all granted

e.window host修改:自行百度host文件哈,输入 ip = 网址

e.重启apache

现在可以输入ip或者网址,对应的就不是apache的网站了,而是自己本地的html

注意事项

1.如果安装好Apache但是无法显示页面,那很有可能是有防火墙哦~所以下面就是解决方案:

防火墙设置:

a.yum install firewalld    ------------    安装firewalld

b. 1.    service firewalld start          2.    systemctl start firewalld.service     -------开启firewalld

c. 1.    service firewalld status       2.    systemctl status firewalld.service     -------获取firewalld状态

d. 1.    service firewalld stop          2.    systemctl stop firewalld.service     -------关闭firewalld   (如果firewalld开启才需要关闭哦)

2.如果配置了虚拟主机的html,却只显示Apache主页,不显示自己的页面,那么就再输入一个   setenforce 0,这样可以关闭防火墙(具体不清楚原理,还需要学习),这样就可以显示自己的html啦~~~

PS:具体一些命令到时候会整理一份出来,然后这个真的是很基础的一个笔记,之后深入下去会有其他的内容加进来~很多不知道原理,希望可以慢慢摸索吧~~~~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值