Apache安装搭建

Linux系统下安装Apache服务器

第一步命令安装apache:

yum install httpd httpd-devel –y

2.第二步执行命令:开启服务器

systemctl start httpd.service

执行下面命令,使服务器随Linux的启动而启动:

systemctl enable httpd.service

.做到这里还是不行的,因为Linux系统中的防火墙会没有给Apache开放端口,所以需要做以下操作:

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

firewall-cmd –reload

.此时就可以在浏览器地址栏输入服务器的ip地址访问了,可以看到这样的界面:

这样apache服务器就成功安装完成!5.安装完成以后apache默认的安装地址为 etc/httpd/conf/httpd.conf我们可以自定义apache的默认路径首先在一个目录下面创建一个文件夹如:在home文件下架创建一个html文件夹

切换路径到home文件夹下:

cd /home

mkdir html

然后在打开apache原来的配置文件:

vi /etc/httpd/conf/httpd.conf

打开配置文件后将里面的/var/www/html/ 修改为/home/dic

.做到这里还是出问题.访问ip时会出现这个问题

Apache安装搭建

问题出现原因是 Linux系统中SELinux关闭访问引起的SELinux一共有三种状态分别是Enforcing,Permissive和Disabled状态,

执行命令 setenforce 0

临时关闭SELinux,就可以执行,但是下次重启服务器时,SELinux还是会恢复原始状态,所以找到SELnux的配置文件设置为disable状态

vi /etc/selinux/config

·

重启linux系统就可以了!完结!!


第二种方式源码安装

Apache安装搭建

usr/local/apache2/bin/apachectl start 开启服务

常见报错

apache常见错误总结:1、./configure报错Configuring Apache Portable Runtime library ...

checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.解决办法:下载安装apr:http://apache.etoak.com//apr/apr-1.4.6.tar.gzapr-utils:http://apache.etoak.com//apr/apr-util-1.4.1.tar.gz或者yum -y install apr apr-util

checking for pcre-config... falseconfigure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/解决办法:[[email protected] httpd-2.4.1]# yum -y install pcre-devel2、启动报错:[[email protected] bin]# service apache startAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this messagehttpd (pid 912) already running其实在这里并不是报错,只是个提醒信息,解决办法比较多(1)、在/etc/hosts写下当前ip与主机名的对应关系(2)、在本机指能解析本机主机名的DNS(3)、修改主配置文件,找到ServerName这一行写入本机主机名


分享到:


相關文章: