Apache的介绍 Apache全称:Apache HttpD Server ;是Apache基金会的一个开源网页服务器,可以在大多数计算机操作系统中运行。Apache提供的服务器又称为:补丁服务器
#需要安装的包yum install httpd -yyum install httpd-devel -yyum install elinks -y示例:[root@localhost ~]# ls /mnt/Packages/httpd*/mnt/Packages/httpd-2.4.6-95.el7.Centos.x86_64.rpm #apache的主程序包/mnt/Packages/httpd-devel-2.4.6-95.el7.centos.x86_64.rpm #apache的开发程序包/mnt/Packages/httpd-manual-2.4.6-95.el7.centos.noarch.rpm #apache的手册文档/mnt/Packages/httpd-tools-2.4.6-95.el7.centos.x86_64.rpm #apache的工具包[root@localhost ~]# [root@localhost ~]# elinks
备案:搭建个人网站最先做的就是域名备案;因为备案需要二十几天的时间才能备案完成,时间较长
配置:需要根据最大的在线人数、注册数、最大的并发量来搭建网站
UV:最大并发量;就是进入访问网站的那一瞬间就是一个并发,没对网站内容进行任何操作
PV:用户在网站中的每次点击都会生成一个PV
域名:阿里、花生壳
安装机制:端口放行
峰值:基于峰值可计算出带宽
每秒钟:峰值➗(24✖3600)
经验值:在算出每秒钟的基础上再✖10;意思就是在每秒钟的数值的基础上估算的上下浮动
带宽:每秒钟✖经验值✖页面大小
PS:带宽不足时可以向运营商申请带宽,申请带宽是按照原本的带宽值✖8(经验值)
[root@sunlit4 ~]# ll /etc/httpd/conf/httpd.conf #apache配置文件路径[root@sunlit4 ~]# ll /var/www/html #页面显示内容默认目录
1xx 信息类
2xx 访问成功
3xx 重定向错误
4xx 页面无法访问
5xx 服务器错误
yum install httpd mariadb mariadb-server php php-mysql -y #安装LAMP所需的软件包#在httpd配置文件目录下创建index.php文件[root@sunlit4 ~]# cd /var/www/html/[root@sunlit4 html]# cat index.php#使用以下的php函数探测mysql的运行情况<?phpphpinfo()?>[root@sunlit4 html]# [root@sunlit4 html]# systemctl restart httpd
AddType application/x-compress .ZAddType application/x-gzip .gz .tgzAddType application/x-httpd-php.php #表示遇到php就立即解析<IfModule dir_module> DirectoryIndex index.php index.html #表示先解析php,如果没有php再解析html</IfModule>
搭建一台内部的web服务器,采用的内部IP地址和80端口,访问格式IP+端口,首页采用index.html文件。管理员E-mail地址为 sunlit4@sunlit.cn ,网页的编码类型采用UTF-8,所有网站资源都存放在/var/www/html目录下,并将Apache的配置文件根目录设置为/etc/httpd目录。
设置Apache的根目录为/etc/httpd(默认)
设置httpd 监听端口80
设置管理员E-mail地址为 sunlit@sunlit.com
#配置文件中需要修改的字段ServerAdmin sunlit@sunlit.com #修改管理员的E-mail地址
PS:想不显示Apache默认界面可在/etc/httpd/conf.d/welcome.conf文件中的LocationMatch注释掉
在注释掉后/var/www/html目录下的文件可在Apache页面上分享
# # Options -Indexes# ErrorDocument 403 /.noindex.html#
[root@sunlit4 html]# mkdir /usr/local/data[root@sunlit4 html]# echo "this is data test" >> /usr/local/data/index.html[root@sunlit4 html]# pwd/var/www/html[root@sunlit4 html]#
Alias /data/ "/usr/local/data/" #指定访问目录路径<Directory "/usr/local/data/">Options Indexes FollowSymLinks #不访问索引 AllowOverride None # 显示空白页 Require all granted # 接收所有的请求</Directory>
![[Pasted image 20221126194322.png]]
[root@sunlit5 ~]# mkdir /usr/local/data[root@sunlit5 data]# echo "this is data test" >> index.html
<Directory "/usr/local/data/">Options Indexes FollowSymLinksauthtype basic #认证类型 authname "my web site" #认证提示 authuserfile /etc/httpd/conf/passwd.secret #密码文件require valid-user #允许的请求用户</Directory>[root@sunlit5 ~]# grep "/usr/local" /etc/httpd/conf/httpd.confAlias /data/ "/usr/local/data/"<Directory "/usr/local/data/">[root@sunlit5 ~]#
[root@sunlit5 ~]# htpasswd -cm /etc/httpd/conf/passwd.secret sunlitNew passWord: Re-type new password: Adding password for user sunlit[root@sunlit5 ~]# cat /etc/httpd/conf/passwd.secret sunlit:$apr1$jCCa1cRa$zQu1Vg5nKlOX.Zu8umexn0[root@sunlit5 ~]# htpasswd -m /etc/httpd/conf/passwd.secret sunlit2 #第二次创建用户不用加"-c"参数New password: Re-type new password: Adding password for user sunlit2[root@sunlit5 ~]# cat /etc/httpd/conf/passwd.secret #密码由md5加密sunlit:$apr1$jCCa1cRa$zQu1Vg5nKlOX.Zu8umexn0sunlit2:$apr1$31git5JX$Hx3NUD8CKnonBo8u9iCPe.[root@sunlit5 ~]#
PS:配置完成后需要对apache进行重启
[root@sunlit5 ~]# ifconfig ens32:0 192.168.21.6 #设置临时IP[root@sunlit5 ~]# ifconfig | grep inet | awk 'NR==1{print $2}''NR==3{print $2}'192.168.21.5192.168.21.6[root@sunlit5 ~]# [root@sunlit5 html]# tail -9 /etc/httpd/conf/httpd.conf<VirtualHost 192.168.21.5:80>DocumentRoot /var/www/html/sunlit5</VirtualHost><VirtualHost 192.168.21.6:80>DocumentRoot /var/www/html/sunlit6</VirtualHost>[root@sunlit5 html]# [root@sunlit5 sunlit5]# echo '192.168.21.5我是sunlit5' > /var/www/html/sunlit5/index.html[root@sunlit5 sunlit5]# echo '192.168.21.5我是sunlit6' > /var/www/html/sunlit6/index.html
[root@sunlit5 ~]# tail /etc/httpd/conf/httpd.conf<VirtualHost *:80>DocumentRoot /var/www/html/sunlit5ServerName www.sunlit.net</VirtualHost><VirtualHost *:80>DocumentRoot /var/www/html/sunlit6ServerName www.sunlit.com</VirtualHost>[root@sunlit5 ~]# [root@sunlit5 ~]# tail -2 /etc/hosts192.168.21.5 www.sunlit.net192.168.21.5 www.sunlit.com[root@sunlit5 ~]#
[root@sunlit5 ~]# grep ^Listen /etc/httpd/conf/httpd.confListen 80Listen 81[root@sunlit5 ~]# [root@sunlit5 ~]# tail -9 /etc/httpd/conf/httpd.conf<VirtualHost 192.168.21.5:80>DocumentRoot /var/www/html/sunlit5</VirtualHost><VirtualHost 192.168.21.5:81>DocumentRoot /var/www/html/sunlit6</VirtualHost>[root@sunlit5 ~]#
来源地址:https://blog.csdn.net/u010722862/article/details/128060667
--结束END--
本文标题: Apache介绍及使用
本文链接: https://www.lsjlt.com/news/411059.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0