Apache和Nginx对比,其实我跟青睐轻量级的Nginx一点,无奈公司的这台电脑的Nginx被人配置的有点乱,所以装了个Apache来搞个网页文件服务器。这里记录下搭建步骤以及访问权限的坑。
我是T型人小付,一位坚持终身学习的互联网从业者。喜欢我的博客欢迎在csdn上关注我,如果有问题欢迎在底下的评论区交流,谢谢。
安装Apache
Apache在centos的repo中叫做httpd,直接用yum安装即可
yum -y install httpd
之后查看一下版本
[root@testmachine test]# httpd -version
Server version: Apache/2.4.6 (CentOS)
Server built: Aug 8 2019 11:41:18
配置文件详解
配置文件在路径/etc/httpd
目录
[root@testmachine httpd]# pwd
/etc/httpd
[root@testmachine httpd]# ll
total 0
drwxr-xr-x 2 root root 37 Mar 4 21:47 conf
drwxr-xr-x 2 root root 117 Mar 4 21:47 conf.d
drwxr-xr-x 2 root root 165 Mar 4 21:47 conf.modules.d
lrwxrwxrwx 1 root root 19 Mar 4 21:47 logs -> ../../var/log/httpd
lrwxrwxrwx 1 root root 29 Mar 4 21:47 modules -> ../../usr/lib64/httpd/modules
lrwxrwxrwx 1 root root 10 Mar 4 21:47 run -> /run/httpd
[root@testmachine httpd]#
其中主要的配置文件是conf/httpd.conf
,而一些自定义的配置,例如针对不同url提供的不同目录的服务,就可以在conf.d
中来配置,下面会讲。
其中httpd.conf
中有几个比较关键的配置项在这里说一下
-
ServerRoot “/etc/httpd”
这里指定Apache的配置文件的位置,也就是上面提到的文件夹,不要修改 -
Listen 80
这里指定服务监听的IP和端口,不指定IP则默认是所有网卡。如果是多个站点,则这里要分多行