云计算学习路线教程大纲课件:HTTP Server: Apache知识点
云计算学习路线教程大纲课件: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
# yum -y install httpd
# systemctl start httpd
# systemctl enable httpd
网站主目录建立测试页:
# vim /var/www/html/index.html
tianyun
# vim /var/www/html/2.php
<?php
phpinfo();
?>
192.168.31.154/index.html
# sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
# setenforce 0
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https
# firewall-cmd --reload
三、安装PHP
# yum -y install php //php作为Apache的模块
# ll /etc/httpd/modules/libphp5.so
-rwxr-xr-x. 1 root root 4588368 Jun 24 2015 /etc/httpd/modules/libphp5.so
# ll /etc/httpd/conf.d/php.conf
-rw-r--r--. 1 root root 691 Jun 24 2015 /etc/httpd/conf.d/php.conf
# systemctl restart httpd
192.168.31.154/2.php
四、安装Mariadb
# yum -y install mariadb-server mariadb
# systemctl start mariadb.service
# systemctl enable mariadb.service
# mysql_secure_installation //提升mariadb安全 [可选]
Set root password?
New password: 123
Re-enter new password: 123
# mysql -uroot -p123 //登录mariadb测试
MariaDB [(none)]> \q
# rm -rf /var/www/html/*
# vim /var/www/html/index.php
<?php
$link=mysql_connect('localhost','root','123');
if ($link)
echo "Successfuly";
else
echo "Faile";
mysql_close();
?>
测试结果: php无法连接mysql
五、并配置php连接Mariadb
# yum -y install php-mysql
# php -m //查看php有哪些扩展
mysql
mysqli
# systemctl restart httpd
六、Apache基本配置
# 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 //站点默认主目录
<Directory "/var/www"> //Apache访问控制
AllowOverride None
Allow open access:Require all granted
</Directory>
========================================================
配置进程和线程针对apache2.2 仅针对面试
prefork MPM //进程模式<IfModule prefork.c>
StartServers 10 //初始建立的进程数
MinSpareServers 10 //最小空闲的进程数
MaxSpareServers 15 //最大空闲的进程数
ServerLimit 2000 //最大启动的进程数默认256
MaxClients 2000 //最大并发连接数 默认256
MaxRequestsPerChild 4000 //每个子进程在其生命周期内允许响应的最大请求数,0不限制
</IfModule>
worker MPM //线程模式<IfModule worker.c>
StartServers 2 //初始建立的进程数
ThreadsPerChild 50 //每个进程建立的线程数
MinSpareThreads 100 //最小空闲的线程数
MaxSpareThreads 200 //最大空间的线程数
MaxClients 2000 //最大的并发访问量(线程)
MaxRequestsPerChild 0 //每个子进程在其生命周期内允许响应的最大请求数,0不限制
</IfModule>
========================================================
忘记MySQL密码
MySQL 5.7.5 and earlier:
# vim /etc/my.cnf
skip-grant-tables
# service mysqld restart
# mysql
mysql> update mysql.user set password=password("456") where user="root" and host="localhost";
mysql> flush privileges;
mysql> \q
# vim /etc/my.cnf
#skip-grant-table
# service mysqld restart
页:
[1]