雲計算學習路線教程大綱課件:HTTP Server: Apache知識點

雲計算學習路線教程大綱課件:HTTP Server: Apache知識點:php

建議使用2.4及以上的版本html

========================================================mysql

1、Apache基礎linux

Apache: www.apache.org面試

軟件包: httpdsql

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

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

/etc/httpd/conf.d/*.conf安全

/etc/httpd/conf.d/welcome.conf //默認測試頁面併發

2、安裝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

<?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

3、安裝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

4、安裝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

<?php

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

if ($link)

echo "Successfuly";

else

echo "Faile";

mysql_close();

?>

測試結果: php沒法鏈接mysql

5、並配置php鏈接Mariadb

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

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

[PHP Modules]

mysql

mysqli

[root@apache ~]# systemctl restart httpd

6、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 //站點默認主目錄

<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:

[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

相關文章
相關標籤/搜索