Apache---Linux安装Apache(httpd)
httpd需要依赖APR 、APR-Util和PCRE,各软件下载地址:
Apache HTTP Server http://httpd.apache.org/download.cgi#apache24
** APR、APR-Util ** [http://apr.apache.org/download.cgi][http_apr.apache.org_download.cgi]
**PCRE ** [https://sourceforge.net/projects/pcre/files/pcre/][https_sourceforge.net_projects_pcre_files_pcre]
gcc(编译C语言软件)环境安装
查看gcc是否安装
gcc -v
安装gcc
yum install gcc-c++
expat(解析xml)环境安装
yum install expat-devel
apr安装
tar -zxvf apr-1.7.0.tar.gz
cd apr-1.7.0/
./configure --prefix=/usr/local/apr
make && make install
apr-util安装
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make && make install
pcre安装
tar -zxvf pcre-8.43.tar.gz
cd pcre-8.43/
./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config
make && make install
httpd安装
tar -zxvf httpd-2.4.41.tar.gz
cd httpd-2.4.41/
./configure --prefix=/usr/local/httpd --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make && make install
添加httpd环境变量
#编辑系统环境变量文件
vim /etc/profile
#在文件末尾添加httpd路径 保存并退出
export PATH=/usr/local/httpd/bin:$PATH
#重新加载系统配置文件,使之生效
source /etc/profile
添加httpd服务到systemctl
#进入 /usr/lib/systemd/system
cd /usr/lib/systemd/system
#编辑 httpd.service 文件
vim httpd.service
#httpd.service 文件加入以下内容 保存并退出
#######################################################
[Unit]
Description=apache - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
###### httpd 安装路径
ExecStart=/usr/local/httpd/bin/httpd -k start
###### httpd 安装路径
ExecReload=/usr/local/httpd/bin/httpd -k restart
##### httpd 安装路径
ExecStop=/usr/local/httpd/bin/httpd -k stop
[Install]
WantedBy=multi-user.target
#######################################################
#授予 httpd.service 文件权限
chmod 755 httpd.service
#重新加载服务配置文件
systemctl daemon-reload
启动/关闭httpd服务
systemctl start httpd
systemctl stop httpd
关闭Linux服务器防火墙,访问 host:80
还没有评论,来说两句吧...