1、安装apache

yum install httpd #根据提示,输入Y安装即可成功安装

systemctl start httpd.service #启动apache

systemctl stop httpd.service #停止apache

systemctl restart httpd.service #重启apache

systemctl enable httpd.service #设置apache开机启动

2、启动http服务

httpd -version #检查是否安装

yum install httpd #安装http服务

service httpd start #启动http服务

service httpd status #检查http服务状态(会显示绿色的active(running)表示启动成功)

service httpd restart #重启http服务

3、配置文件

httpd相关配置文件:

主配置文件:/etc/httpd/conf/httd.conf ,这个是httpd最主要的配置文档

扩展配置文件:/etc/httpd/conf.d/*.conf ,这个是httpd的额外配置文档

文档根目录: /var/www/html ,这个是apache 首页的文档目录 ,即输入http://127.0.0.1  显示页面所在的目录

服务脚本:/etc/rc.d/init.d/httpd

错误目录:/var/www/error  ,服务器设定错误,请求的资源错误或浏览器访问出现错误等错误文件的存储目录

CGI目录: /var/www/cgi-bin/   ,预设为CGI运行脚本的存储目录

日志目录:/var/log/httpd  ,client端登录httpd时,记录的登录日志等信息存储目录

脚本配置文件: /etc/sysconfig/httpd

Listen端口:80/tcp  ,443/tcp

命令执行文件:/usr/sbin/apachectl ,/usr/sbin/httpd,/usr/bin/htpasswd

PID文件:/var/run/httpd/httpd.pid

4、开放80端口 打开防火墙

查看指定区域所有开启的端口号

firewall-cmd --zone=public --list-ports

在指定区域开启端口(如80端口号,命令方式)

firewall-cmd --zone=public --add-port=80/tcp --permanent

重新启动防火墙

firewall-cmd --reload

参考网址:https://blog.csdn.net/u014079773/article/details/79745819

5、测试网页

echo “This is my first web page.”>/var/www/html/index.html

打开http://127.0.0.1 查看是否正常启动

linux启动http服务的更多相关文章

  1. 如何查看和停止Linux启动的服务

    1. 查看Linux启动的服务chkconfig --list 查询出所有当前运行的服务chkconfig --list atd  查询atd服务的当前状态 2.停止所有服务并且在下次系统启动时不再启 ...

  2. Linux启动ssh服务

    Linux启动ssh服务 在Linux下启动ssh服务使用如下命令其一即可: # service sshd start # /etc/init.d/sshd start 开机启动 使用如下方法其就可以 ...

  3. linux启动httpd服务出现 Could not reliably determine the server`s fully qualified domain name.

    安装好apache启动httpd服务时,出现httpd: Could not reliably determine the server's fully qualified domain name,  ...

  4. Linux 启动SVN服务

    #使用默认端口3690启动svn服务svnserve -d -r /home/svndata # 如果出现#svnserve: Can't bind server socket: Address al ...

  5. linux 启动ftp服务,sftp服务

    启动ftp服务:yum install vsftpd 在/etc/rc.d/init.d/目录下:命令 service vsftp start启动ssh服务,sftp服务在/etc/init.d/目录 ...

  6. Linux启动一个服务后,服务的某个文件所在的目录下出现类似:systemd-private.xxxxxx的目录

    Linux的目录下面形如: [root@:vg_adn_tidbCkhsTest:172.31.17.203 /var/lib/mysql]#ll /tmp total drwxr root root ...

  7. linux启动oracle服务 和监听

    (1) su - oracle 切换成oracle 用户 (2)sqlplus / as sysdba (3)startup: (4)quit:退出sql模式 exit 退出oracle用户 (5)l ...

  8. 【转】Linux学习之路--启动VNC服务

    我的Linux是Fedora 13,安装方法如下: 1.打开终端,执行 # yum install -y tigervnc tigervnc-server 2.编辑/etc/sysconfi/vncs ...

  9. linux下tomcat服务的启动、关闭与错误跟踪

    linux下tomcat服务的启动.关闭与错误跟踪,远程连接到服务器以后,通常通过以下几种方式启动关闭tomcat服务: 1).启动tomcat服务 进入tomcat主目录下的bin目录,然后执行如下 ...

随机推荐

  1. JavaScript 实现打印操作

    一.打印当前页面指定元素中的内容 方式一:直接使用window.print(); (1)首先获得元素的html内容(这里建议如果有样式最好是用内联样式的方式) var newstr = documen ...

  2. 《DSP using MATLAB》Problem 7.3

  3. terraform 配置github module source

      terraform 支持多种module 的source 配置 以下是一个简单的使用github source的demo 测试项目 项目结构 ├── init.tpl ├── main.tf 代码 ...

  4. socket资源

    http://www.360doc.com/content/13/1231/16/14919052_341525862.shtml Linux下基于socket多线程并发通信的实现 https://w ...

  5. 第三章 C#程序结构[3.2 选择结构的应用(Windows窗体应用程序)(四)]

    [案例]设计一个顾客选购商品的系统.其中,顾客身份有两类,一类是VIP,另一类是普通会员:商品种类有3种.分别是上衣.裤子和鞋子.其中,VIP享受8折优惠和商店赠送的礼品,而普通会员都不享受.单击[确 ...

  6. flask-appbuilder +echarts 展示数据笔记

    pip install flask-appbuilder fabmanager create-app cd newapp fabmanager create-admin fabmanager run ...

  7. awk 进阶,百万行文件取交集

    今天我们说的不是简单的交集,而是如下示例: file1: as,er,gf,1212kl,iop,121378,jkl,uio,jki,1214vbnm,yuoi,678i,1215sadfasdf, ...

  8. PAT 甲级 1005 Spell It Right (20 分)

    1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all th ...

  9. Percona XtraDB Cluster Strict Mode(PXC 5.7)

    在Percona XtraDB Cluster集群架构中,为了避免多主节点导致的数据异常,或者说一些不被支持的特性引发的数据不一致的情形,PXC集群可以通过配置pxc_strict_mode这个变量来 ...

  10. C#将List<T>转化为DataTable

    using System; using System.Collections.Generic; using System.Data; using System.Reflection; using Sy ...