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. 《C语言程序设计》编程总结汇总

    <C语言程序设计>编程总结汇总 院系: 专业年级: 班级名称: 学号: 姓名: 指导教师: 完成时间: 自我评价: 计算机科学与技术专业教研室 2018 年秋季学期 第四周编程总结 题目4 ...

  2. ESP8266EX资料

    https://github.com/esp8266/Arduino http://espressif.com/zh-hans/support/explore/faq 电路资料图如下: 介绍功能: 参 ...

  3. QMD ST表 倍增

    #include<iostream> #include<cmath> using namespace std; ; int a[maxn]; ]; ]; int quick(i ...

  4. centos 7 下 nginx 1.10.3 编译安装的方法

    安装所需环境 Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境. 一. gcc 安装安装 nginx 需要先 ...

  5. Linq分组查询统计

    这里介绍Linq使用Group By和Count得到每个CategoryID中产品的数量,Linq使用Group By和Count得到每个CategoryID中断货产品的数量等方面. 学经常会遇到Li ...

  6. DataTable与DataSet之间的转换Class

    using System;using System.Collections.Generic;using System.Data;using System.Linq; namespace Convert ...

  7. laravel的filter()方法的使用 (方法使用给定的回调函数过滤集合的内容,只留下那些通过给定真实测试的内容)

    filter 方法使用给定的回调函数过滤集合的内容,只留下那些通过给定真实测试的内容: $collection = collect([1, 2, 3, 4]); $filtered = $collec ...

  8. ubuntu安装nginx及其默认目录结构

    一. 安装包安装 1.1 安装Nginx $sudo apt-get install nginx Ubuntu安装之后的文件结构大致为: 所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经 ...

  9. C# 自定义类动态追加属性

    利用Dynamic,需要.net4.0以上的支持 var dg = rel.ResultDocuments.FirstOrDefault()["dg"].AsBsonArray.G ...

  10. json 中关于json数组跟json对象的区别

    原文地址:http://blog.csdn.net/lafengwnagzi/article/details/52789171 JSON 是存储和交换文本信息的语法 JSON 文本格式在语法上与创建 ...