内乡微网站建设,wordpress默认后台登陆,网页顶部导航栏设计,东莞网页制作招聘网Linux/centos上如何配置管理Web服务器#xff1f; 1 Web简单了解2 关于Apache3 如何安装Apache服务器#xff1f;3.1 Apache服务安装3.2 httpd服务的基本操作 4 如何配置Apache服务器#xff1f;4.1 关于httpd.conf配置4.2 常用指令 5 简单实例 1 Web简单了解
Web服务器称为… Linux/centos上如何配置管理Web服务器 1 Web简单了解2 关于Apache3 如何安装Apache服务器3.1 Apache服务安装3.2 httpd服务的基本操作 4 如何配置Apache服务器4.1 关于httpd.conf配置4.2 常用指令 5 简单实例 1 Web简单了解
Web服务器称为WWW服务器主要是提供上网功能常见的Web服务器有Microsoft IIS、IBM WebSphere、Apache、Tomcat等本文主要以Apache服务器为例了解一些Linux/centos上如何配置管理Web服务器。
2 关于Apache
Apache是一种开源的Web服务器软件具有跨平台特性支持Unix、Linux、BSD等操作系统支持静态和动态内容对于模块化支持支持SSL和虚拟主机具有完整的日志功能支持用户认证机制等。
3 如何安装Apache服务器
3.1 Apache服务安装
先检查系统上是否已经安装了Apache服务如下
rpm -qa | grep httpd我的是已经安装了如下 如果没有安装可以使用以下命令安装
yum -y install httpd3.2 httpd服务的基本操作
查看httpd服务的运行状态
systemctl status httpd.service如下显示我的还没有启动 启动httpd服务
systemctl start httpd.service启动后如下显示
[rootlocalhost ~]# systemctl start httpd.service
[rootlocalhost ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)Active: active (running) since Wed 2023-11-08 17:53:21 CST; 2s agoDocs: man:httpd(8)man:apachectl(8)Main PID: 5953 (httpd)Status: Processing requests...Tasks: 9CGroup: /system.slice/httpd.service├─5953 /usr/sbin/httpd -DFOREGROUND├─5954 /usr/libexec/nss_pcache 6 off├─5956 /usr/sbin/httpd -DFOREGROUND├─5958 /usr/sbin/httpd -DFOREGROUND├─5959 /usr/sbin/httpd -DFOREGROUND├─5960 /usr/sbin/httpd -DFOREGROUND├─5961 /usr/sbin/httpd -DFOREGROUND└─5962 /usr/sbin/httpd -DFOREGROUNDNov 08 17:53:20 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
Nov 08 17:53:20 localhost.localdomain httpd[5953]: AH00558: httpd: Could not reliably determine the servers fully qualified domain na...message
Nov 08 17:53:21 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.停止httpd服务
systemctl stop httpd.service重启httpd服务
systemctl restart httpd.service设置开机自启动
systemctl enable httpd.service查看设置自启动是否成功
systemctl list-unit-files | grep httpd如下显示则为设置成功了
4 如何配置Apache服务器
4.1 关于httpd.conf配置
Apache服务的配置文件为httpd.conf文件在/etc/httpd/conf/下 httpd.conf文件内容说明
内容说明#ServerRoot全局环境设置#Main serve rconfiguration主服务器设置虚拟主机设置
4.2 常用指令
指令说明示例ServerName设置Apache服务器的主机名和端口号ServerName www.noamanelson.com 80ServerRoot设置Apache服务器的根目录包括conf、logs、modules等子目录ServerRoot /etc/httpdListen设置Apache服务器的监听端口默认监听80一般在监听非80时会设置Listen 8088DocumentRoot设置Apache提供的HTML文档根目录 默认为/var/www/htmlDocumentRoot /www/mywebDirectory指定Apache服务器根目录的访问权限和方式Directory /var/wwwAllowOverride None Require all granted /Directory DirectoryIndex设置Apache服务器网站的主文件通常为index.htmlDirectoryIndex index.htmlVirtualHost设置特定虚拟主机VirtualHost 192.168.1.7 DocumentRoot /www/myweb ServerName noamanelson.com /VirtualHostServerAdmin设置管理员邮箱ServerAdmin adminnoamanelson.comTimeOut设置接收和发送数据时的超时时间TimeOut 100ErrorLog指定Apache服务器使用的错误日志文件ErrorLog logs/error_logCustomLog指定Apache服务器使用的访问日志/Include其他配置文件/
5 简单实例
主要目标是配置个人Web站点建用户NoamaNelson修改权限并建立目录public_html:
useradd NoamaNelson
mkdir /home/NoamaNelson/public_html
chmod 711 /home/NoamaNelson/
chmod 755 /home/NoamaNelson/public_html/在public_html下建立网页文件index,html:
vim /home/NoamaNelson/public_html/index.htmlWelcome everyone
This is my Web~~~配置/etc/httpd/conf.d/userdir.conf文件
IfModule mod_userdir.c#UserDir disabledUserDir public_html
/IfModuleDirectory /home/*/public_htmlAllowOverride FileInfo AuthConfig Limit Indexes#Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExecOptions NoneRequire method GET POST OPTIONS
/DirectoryRequire method GET POST OPTIONS保存以上文件重启服务器关闭防火墙将Selinux设置为Permissive
systemctl start httpd
systemctl stop firewalld.service
setenforce 0
getenforce在浏览器中输入服务ip/ ~NoamaNelson/即可打开NoamaNelson的个人主页比如我的是如下
http://172.28.18.146/~NoamaNelson/