Ubuntu Server版 之 apache系列 常用配置 以及 隐藏 版本号 IP、Port 搭建服务案例

查看版本

旧的 用 httpd -v

新的 用 apache2 -v

配置检测

旧的 httpd -t

新的 apachectl configtest

window用的apache 是 httpd -t

Linux 中 apachectl configtest

主配置文件

之前旧版apache 是httpd 现在都改成 apache2

/etc/apache2/apache2.conf window中 httpd.conf


修改默认的网站根目录

apache2为了安全起见,只允许/var/www、/usr/share下面的文件夹被访问,假如要指定其它目录为网站根目录,

需要修改配置文件

vim /etc/apache2/apache2.conf

配置虚拟主机

/etc/apache2/sites-enabled/000-default.conf。

Apache虚拟主机配置文件存储在/etc/apache2/sites-available目录, 标准命名是使用域名来命名配置文件

ln 软链接

Apache 默认不会读取/etc/apache2/sites-available文件夹下的配置文件,需要将它们链接到/etc/apache2/sites-enabled文件夹,使用a2ensite创立一个链接,激活虚拟主机配置:

sudo a2ensite 自定义的.conf 如上文 000-default.conf

检测apache配置

window用的apache 是 httpd -t

Linux 中 apachectl configtest


Linux中 服务的 开启 、关闭、重启

1、 service 服务名 stop

2、 service 服务名 start

3、 service 服务名 restart

或者

1、 systemctl stop 服务名 systemctl stop apache2

2、 systemctl restart 服务名 systemctl restart apache2 systemctl reload apache

3、 systemctl start 服务名 systemctl start apache2

4 systemctl status apache2

5 systemctl enable 服务名 开机自启

6、 systemctl disable 服务名 关闭开机自启

搭建Apache服务

1 创建 项目 目录 mkdir -p /CustZen/www

2 利用重定向 www目录 创建 zen.html 文件

3 配置Apache





Apache 默认不会读取/etc/apache2/sites-available文件夹下的配置文件,需要将它们链接到/etc/apache2/sites-enabled文件夹,使用a2ensite创立一个链接,激活虚拟主机配置:

1 用ln -s 软链接

2 a2ensite 这个 apache 自己的方法 不需要考虑目录 ,写死了 脚本中

默认页面 index.html index.php 等



security.conf

sudo vim /etc/apache2/conf-avalilable/security.conf



注意要重启Apache服务

systemctl reload apache2


修改默认页




注意 DirectoryIndex 这个 越靠前,优先级越高

相关推荐
焱焱枫24 分钟前
Linux疑难杂症诊断利器:深入解析 fuser 命令
linux·运维·服务器
深思慎考33 分钟前
Ubuntu 系统 RabbitMQ 安装指南与使用(含 C++ 客户端与 SSL 错误解决)
c++·ubuntu·rabbitmq·github·rabbitmqpp
博语小屋44 分钟前
Linux进程信号(壹)_产生信号
linux·运维·服务器
轻松Ai享生活1 小时前
【Linux】VFS 虚拟文件系统 详解
linux
LCG元1 小时前
Linux环境Python生态速建指南:包管理+虚拟隔离+深度调优
linux
大白的编程日记.1 小时前
【Linux学习笔记】线程同步与互斥之生产者消费者模型
linux·笔记·学习
Knight_AL1 小时前
Spring Boot 中使用自定义注解和 AOP 实现微服务日志记录(包含 URL、状态码和耗时信息)
linux·spring boot·微服务
养海绵宝宝的小蜗1 小时前
Linux 例行性工作任务(定时任务)知识点总结
linux·运维·服务器
乌萨奇也要立志学C++2 小时前
【Linux】基础IO(二)深入理解“一切皆文件” 与缓冲区机制:从原理到简易 libc 实现
linux·运维·服务器
Ronin3052 小时前
【Linux网络】封装Socket
linux·网络·socket·网络通信