使用yum安装apache服务
[root@1-0001 ~]# ;yum install httpd -y
启动apache服务,并本地测试访问
[root@1-0001 ~]# systemctl start httpd
[root@1-0001 ~]# systemctl status httpd
[root@1-0001 ~]# curl localhost
修改配置
[root@1-0001 ~]# vi /etc/httpd/conf/httpd.conf
修改内容如下
#Listen 12.34.56.78:80
Listen 9100
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/opt/httpd"
#
# Relax access to content within /var/www.
#
<Directory "/opt/httpd">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/opt/httpd">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
创建目录并授权
[root@1-0001 ~]# mkdir -p /opt/httpd
[root@1-0001 ~]# chmod -R +777 /opt/httpd
去除默认页
[root@1-0001 ~]# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bak
重启服务并生效
[root@1-0001 ~]# systemctl restart httpd