安装Apachi

1.打开Xshell把五个压缩包粘贴进/opt目录下

安装Apachi_第1张图片

2.打开/opt目录查看

安装Apachi_第2张图片

 3.解压缩文件

1.tar zxvf apr-1.6.2.tar.gz 

2.tar zxvf apr-util-1.6.0.tar.gz 

3.tar jxvf httpd-2.4.29.tar.bz2 

4.查看

安装Apachi_第3张图片

5. 把其余两个压缩包剪切复制到httpd-2.4.29/srclib/apr目录下

[root@localhost opt]# mv apr-1.6.2 httpd-2.4.29/srclib/apr
[root@localhost opt]# mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util

6.进入路径下查看

安装Apachi_第4张图片

7.安装环境

[root@localhost srclib]# yum -y install gcc gcc-gcc++ make pcre-devel expat-devel perl

 8.在阿帕奇主程序下安装模块

[root@localhost httpd-2.4.29]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi

9.编译和安装

[root@localhost httpd-2.4.29]# make && make install

10.把/usr/local/httpd/bin/的apachectl拷贝到init.d/目录下并修改名字为httpd

[root@localhost httpd-2.4.29]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

11.编译添加命令

1.打开文件
[root@localhost httpd-2.4.29]# vi /etc/init.d/httpd 
2.在开头添加
#!/bin/sh
# chkconfig: 35 85 21  //35级自动运行 第85个启动 第21个关闭
# description: Apache is a World Wide Wed server

12.打开文件修改配置

1.打开文件
[root@localhost httpd-2.4.29]# vi /usr/local/httpd/conf/httpd.conf 
2.把#去掉
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName www.example.com:80    //去掉#号

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other

13.删除/usr/local/httpd/htdocs/目录下的文件

[root@localhost httpd-2.4.29]# cd /usr/local/httpd/htdocs/
[root@localhost htdocs]# ll
总用量 4
-rw-r--r-- 1 root root 45 6月  11 2007 index.html
[root@localhost htdocs]# cat index.html 

It works!

[root@localhost htdocs]# rm index.html rm:是否删除普通文件 "index.html"?y [root@localhost htdocs]#

14,在/usr/local/httpd/htdocs下导入html类型的文件

安装Apachi_第5张图片

15. 做链接(文件名太长了)

[root@localhost htdocs]# ln -s /usr/local/httpd/conf/httpd.conf /etc  //链接
[root@localhost htdocs]# vi /etc/httpd.conf       //查看命令
[root@localhost htdocs]# ln -s /usr/local/httpd/bin/* /usr/local/bin/  //链接
[root@localhost htdocs]# 

16.关闭两个防火墙

[root@localhost htdocs]# systemctl stop firewlald
Failed to stop firewlald.service: Unit firewlald.service not loaded.
[root@localhost htdocs]# setenforce 0
setenforce: SELinux is disabled
[root@localhost htdocs]# 

17.检查语法

[root@localhost htdocs]# httpd  -t    //httpd
Syntax OK
[root@localhost htdocs]# apachectl -t   //阿帕奇
Syntax OK

18.开启阿帕奇,查看效果

 安装Apachi_第6张图片

 

你可能感兴趣的:(linux,服务器,运维)