新聞中心
云計算學(xué)習(xí)路線教程大綱課件:HTTP Server: Apache知識點:
成都創(chuàng)新互聯(lián)專注于企業(yè)全網(wǎng)整合營銷推廣、網(wǎng)站重做改版、汝州網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5響應(yīng)式網(wǎng)站、成都做商城網(wǎng)站、集團公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為汝州等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
建議使用2.4及以上的版本
========================================================
一、Apache基礎(chǔ)
Apache: www.apache.org
軟件包: httpd
服務(wù)端口: 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
網(wǎng)站主目錄建立測試頁:
[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();
?>
測試結(jié)果: 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 //監(jiān)聽端口
IncludeOptional conf.d/.conf //包含conf.d下的.conf文件
User apache //運行Apache的用戶
Group apache //運行Apache的用戶組
DirectoryIndex index.html index.php //設(shè)置默認主頁
DocumentRoot //站點默認主目錄
AllowOverride None
Allow open access:
Require all granted
========================================================
配置進程和線程 針對apache2.2 僅針對面試
prefork MPM //進程模式
StartServers 10 //初始建立的進程數(shù)
MinSpareServers 10 //最小空閑的進程數(shù)
MaxSpareServers 15 //最大空閑的進程數(shù)
ServerLimit 2000 //最大啟動的進程數(shù) 默認256
MaxClients 2000 //最大并發(fā)連接數(shù) 默認256
MaxRequestsPerChild 4000 //每個子進程在其生命周期內(nèi)允許響應(yīng)的最大請求數(shù),0不限制
worker MPM //線程模式
StartServers 2 //初始建立的進程數(shù)
ThreadsPerChild 50 //每個進程建立的線程數(shù)
MinSpareThreads 100 //最小空閑的線程數(shù)
MaxSpareThreads 200 //最大空間的線程數(shù)
MaxClients 2000 //最大的并發(fā)訪問量(線程)
MaxRequestsPerChild 0 //每個子進程在其生命周期內(nèi)允許響應(yīng)的最大請求數(shù),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
新聞標(biāo)題:云計算學(xué)習(xí)路線教程大綱課件:HTTPServer:Apache知識點
網(wǎng)頁地址:http://fisionsoft.com.cn/article/gddoid.html