云计算学习路线教程大纲课件:HTTP Server: Apache知识点
admin
2023-03-30 03:21:29
0

云计算学习路线教程大纲课件:HTTP Server: Apache知识点:

建议使用2.4及以上的版本

========================================================

一、Apache基础

Apache: www.apache.org

软件包: httpd

服务端口: 80/tcp(http) 443/tcp(https,http+ssl)

配置文件: /etc/httpd/conf/httpd.conf

/etc/httpd/conf.d/*.conf

/etc/httpd/conf.d/welcome.conf //默认测试页面

二、安装Apache

[root@apache ~]# yum -y install httpd

[root@apache ~]# systemctl start httpd

[root@apache ~]# systemctl enable httpd

网站主目录建立测试页:

[root@apache ~]# vim /var/www/html/index.html

tianyun

[root@apache ~]# vim /var/www/html/2.php

phpinfo();

?>

192.168.31.154/index.html

[root@apache ~]# sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config

[root@apache ~]# setenforce 0

[root@apache ~]# firewall-cmd --permanent --add-service=http

[root@apache ~]# firewall-cmd --permanent --add-service=https

[root@apache ~]# firewall-cmd --reload

三、安装PHP

[root@apache ~]# yum -y install php //php作为Apache的模块

[root@apache ~]# ll /etc/httpd/modules/libphp5.so

-rwxr-xr-x. 1 root root 4588368 Jun 24 2015 /etc/httpd/modules/libphp5.so

[root@apache ~]# ll /etc/httpd/conf.d/php.conf

-rw-r--r--. 1 root root 691 Jun 24 2015 /etc/httpd/conf.d/php.conf

[root@apache ~]# systemctl restart httpd

192.168.31.154/2.php

四、安装Mariadb

[root@apache ~]# yum -y install mariadb-server mariadb

[root@apache ~]# systemctl start mariadb.service

[root@apache ~]# systemctl enable mariadb.service

[root@apache ~]# mysql_secure_installation //提升mariadb安全 [可选]

Set root password? [Y/n]

New password: 123

Re-enter new password: 123

[root@apache ~]# mysql -uroot -p123 //登录mariadb测试

MariaDB [(none)]> \q

[root@apache ~]# rm -rf /var/www/html/*

[root@apache ~]# vim /var/www/html/index.php

$link=mysql_connect('localhost','root','123');

if ($link)

echo "Successfuly";

else

echo "Faile";

mysql_close();

?>

测试结果: php无法连接mysql

五、并配置php连接Mariadb

[root@apache ~]# yum -y install php-mysql

[root@apache ~]# php -m //查看php有哪些扩展

[PHP Modules]

mysql

mysqli

[root@apache ~]# systemctl restart httpd

六、Apache基本配置

[root@tianyun ~]# vim /etc/httpd/conf/httpd.conf

ServerRoot "/etc/httpd" //安装目录

Listen 80 //监听端口

IncludeOptional conf.d/.conf //包含conf.d下的.conf文件

User apache //运行Apache的用户

Group apache //运行Apache的用户组

DirectoryIndex index.html index.php //设置默认主页

DocumentRoot //站点默认主目录

//Apache访问控制

AllowOverride None

Allow open access:

Require all granted

========================================================

配置进程和线程 针对apache2.2 仅针对面试

prefork MPM //进程模式

StartServers 10 //初始建立的进程数

MinSpareServers 10 //最小空闲的进程数

MaxSpareServers 15 //最大空闲的进程数

ServerLimit 2000 //最大启动的进程数 默认256

MaxClients 2000 //最大并发连接数 默认256

MaxRequestsPerChild 4000 //每个子进程在其生命周期内允许响应的最大请求数,0不限制

worker MPM //线程模式

StartServers 2 //初始建立的进程数

ThreadsPerChild 50 //每个进程建立的线程数

MinSpareThreads 100 //最小空闲的线程数

MaxSpareThreads 200 //最大空间的线程数

MaxClients 2000 //最大的并发访问量(线程)

MaxRequestsPerChild 0 //每个子进程在其生命周期内允许响应的最大请求数,0不限制

========================================================

忘记MySQL密码

MySQL 5.7.5 and earlier:

[root@mysql1 ~]# vim /etc/my.cnf

[mysqld]

skip-grant-tables

[root@mysql1 ~]# service mysqld restart

[root@mysql1 ~]# mysql

mysql> update mysql.user set password=password("456") where user="root" and host="localhost";

mysql> flush privileges;

mysql> \q

[root@mysql1 ~]# vim /etc/my.cnf

[mysqld]

#skip-grant-table

[root@mysql1 ~]# service mysqld restart

相关内容

热门资讯

特朗普下令不打了,美国的“余粮... 可以说戛然而止,快得让很多人都无法适应。前两周,每一天美国都要打击伊朗一通。就在7月24日白宫会议前...
穆杰塔巴最新表态:支持黎真主党 △伊朗最高领袖穆杰塔巴·哈梅内伊(资料图)当地时间7月26日晚,伊朗最高领袖穆杰塔巴·哈梅内伊对黎巴...
美军瘫痪一艘驶向伊朗的油轮,特... 美国总统特朗普虽下令暂停打击伊朗,但美军仍在执行对霍尔木兹海峡的封锁任务。针对美军瘫痪一艘驶向伊朗油...
“小牌大耍”的底气到底是哪里来... 澎湃首席评论员 李平这两天,“艺人李权哲乘高铁占座事件”在网上引发热议,该艺人参加的活动主办方曾发布...
越南籍船舶南海遇险沉没,中方已... 据凤凰卫视报道,一艘越南船舶7月24日夜间在越南庆和以东220海里附近遇险沉没,船上共62名越南籍人...
李权哲占座、蒙面、装死:娱乐圈... 你买了一张高铁一等座的票,找到自己的位置,18A。有人坐着。你拿出手机看了眼购票记录——没错,18A...
杭州景区咖啡店闯入1条幼蛇,仅... 夏天气温高、湿度大,蛇类活动进入高峰期,千万别被“小蛇无害”的刻板印象骗了!有些幼蛇看着迷你可爱,实...
AI开源公开信签署企业增至50... IT之家 7 月 26 日消息,英伟达、微软、IBM、Meta 等 25 家美国科技企业本周(7 月...
南阳快手短视频代运营企业的服务... 在短视频平台快速发展的背景下,企业通过快手等渠道进行内容运营已成为常见的市场动作。对于希望借助短视频...
普通人该如何跟上科技发展的步伐 这个被称作科技的词汇, 听起来既有宏大之感, 又颇为遥远, 好似仅仅归属于在实验室里专心致志钻研的科...