溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

九、LAMP的安裝與配置

發(fā)布時間:2020-09-24 06:39:35 來源:網(wǎng)絡(luò) 閱讀:398 作者:少年不在了 欄目:MySQL數(shù)據(jù)庫

9.1、PHP與httpd的結(jié)合工作方式

常見PHP開源軟件:

  論壇:phpwind、discuz 、phpbb

  博客系統(tǒng):wordpress

  門戶站點:drupal、xooms

  數(shù)據(jù)庫:phpMyAdmin、Workbench、MySQL Front、Navicat for MySQL、Toad

  CMS(Content Management System)內(nèi)容管理系統(tǒng):Drupal、joomla

PHP與httpd的結(jié)合方式:

  Module作為模塊,需要時加載:

  prefork: 一個請求用一個進程處理,穩(wěn)定性好、大并發(fā)場景下消耗資源較多;事先創(chuàng)建進程,按需維 持適當(dāng)?shù)倪M程,模塊塊設(shè)計,核心比較小,各種功能都模塊添加(包括php),支持運行配置,支持單獨編譯模塊,支持多種方式的虛擬主機配置。

  worker: 一個進程多個線程,一個線程響應(yīng)一個請求

  event: 一個線程響應(yīng)多個請求,事件驅(qū)動,主要目的在于實現(xiàn)單線程響應(yīng)多個請求

  Cgi(Common gateway interface):通用網(wǎng)關(guān)接口,為HTTP服務(wù)器與其他機器上的程序服務(wù)通信的一種交流工具。(CGI程序必須運行在網(wǎng)絡(luò)服務(wù)器,每次HTTP服務(wù)遇到動態(tài)程序時都需要成新啟動解析器)

九、LAMP的安裝與配置

  Fastcgi,可伸縮的,高速的在HTTP服務(wù)器和動態(tài)腳本語言間通信的接口,優(yōu)點是把動態(tài)語言和HTTP服務(wù)器相分離。其主要行為是將CGI解釋器進程保持在內(nèi)存中并因此獲得較高的性能。CGI解釋器的反復(fù)加載是CGI性能低下的主要原因,如果CGI解釋器保持在內(nèi)存中并接受FastCGI進程管理器調(diào)度,則可以提供良好的性能、伸縮性、Fail- Over特性等等。

  LAMP配置順序:httpd --> MySQL --> php --> XCache(緩存器/優(yōu)化器)

  rpm格式配置lamp

# yum -y install httpd php php-mysql mysql-server mysql php-mcrypt

9.2、編譯安裝LAMP

軟件版本:


apacge:httpd-2.4.25.tar.gz

  依賴包:apr-1.5.2.tar.gz  apr-util-1.5.4.tar.gz

mysql:mysql-5.5.55-linux2.6-x86_64.tar.gz

php:  php-5.6.30-src.zip

相關(guān)軟件下載:

#wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.25.tar.gz
#wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz
#wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
#wget http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
#wget http://cn2.php.net/distributions/php-5.6.30.tar.gz

1、安裝apache

[root@mylinux app]# tar xf apr-1.5.2.tar.gz
[root@mylinux app]# cd apr-1.5.2
[root@mylinux apr-1.5.2]## ./configure --prefix=/usr/local/apr
[root@mylinux apr-1.5.2]## make && make install

[root@mylinux app]# tar xf apr-util-1.5.4.tar.gz 
[root@mylinux app]# cd apr-util-1.5.4
[root@mylinux apr-util-1.5.4]./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@mylinux apr-util-1.5.4]make && make install

[root@mylinux home]#yum install pcre-devel -y

[root@mylinux app]# tar xf httpd-2.4.25.tar.gz 
[root@mylinux app]# cd httpd-2.4.25
[root@mylinux httpd-2.4.25]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event
[root@mylinux httpd-2.4.25]#make && make install
[root@mylinux httpd24]# vim /etc/httpd24/httpd.conf     #修改配置文件
   PidFile  "/var/run/httpd.pid"                        #添加該行
   ServerName 127.0.0.1:80                              #修改服務(wù)名稱 
   
#提供服務(wù)腳本
[root@mylinux httpd24]# cp /home/app/httpd-2.4.25/build/rpm/httpd.init /etc/rc.d/init.d/httpd
[root@mylinux init.d]# vim /etc/rc.d/init.d/httpd       #修改相關(guān)參數(shù)
 CONFFILE=/etc/httpd24/httpd.conf
 apachectl=/usr/local/apache/bin/apachectl
 httpd=${HTTPD-/usr/local/apache/bin/httpd}
 pidfile=${PIDFILE-/var/run/${prog}.pid}
 lockfile=${LOCKFILE-/var/lock/subsys/${prog}}
 RETVAL=0
 prog=httpd
 
[root@mylinux init.d]# chmod +x /etc/rc.d/init.d/httpd   #為此腳本賦予執(zhí)行權(quán)限
[root@mylinux init.d]# chkconfig --add httpd             #加入服務(wù)列表
[root@mylinux init.d]# service httpd start               #啟動測試
Starting httpd: [  OK  ]

九、LAMP的安裝與配置

2、通用二進制格式安裝MySQL

[root@mylinux app]# tar xf mysql-5.5.55-linux2.6-x86_64.tar.gz 
[root@mylinux app]# ln -sv /home/app/mysql-5.5.55-linux2.6-x86_64 /usr/local/mysql
`/usr/local/mysql' -> `/home/app/mysql-5.5.55-linux2.6-x86_64'
[root@mylinux app]# cd mysql
[root@mylinux mysql]# chown -R root:mysql .
[root@mylinux mysql]# scripts/mysql_install_db --user=mysql          #初始化
[root@mylinux mysql]# cp support-files/my-large.cnf /etc/my.cnf      #提供配置文件
[root@mylinux mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld #服務(wù)腳本
[root@mylinux mysql]# service mysqld start                           #啟動測試
Starting MySQL.. SUCCESS! 
[root@mylinux profile.d]# vim /etc/mysql.sh                          #添加環(huán)境變量
[root@mylinux profile.d]# source mysql.sh 
[root@mylinux profile.d]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.55-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye
[root@mylinux profile.d]#

3、安裝PHP

# yum -y groupinstall "Desktop Platform Development"    #解決依賴關(guān)系
# yum -y install bzip2-devel libmcrypt-devel
[root@mylinux app]# tar xf php-5.6.30.tar.gz
[root@mylinux app]# cd php-5.6.30
[root@mylinux php-5.6.30]#  ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts
[root@mylinux php-5.6.30]# make
[root@mylinux php-5.6.30]# make test
[root@mylinux php-5.6.30]# make install
[root@mylinux php-5.6.30]# cp php.ini-production  /etc/php.ini   #提供配置文件

4、修改apache相關(guān)配置

 # vim /etc/httpd/httpd.conf
   AddType application/x-httpd-php  .php           #添加兩行
   AddType application/x-httpd-php-source  .phps
   ...
   <IfModule dir_module>
    DirectoryIndex  index.php index.html           #修改該行
   </IfModule>

5、測試

[root@mylinux php-5.6.30]# service httpd restart
Stopping httpd: [  OK  ]
Starting httpd: [  OK  ]
[root@mylinux htdocs]# vim /usr/local/apache/htdocs/123.php 
<?php
 $link = mysql_connect('127.0.0.1');
 if ($link)
   echo "Success...";
 else
   echo "Failure...";
 mysql_close();
?>
[root@mylinux htdocs]# vim /usr/local/apache/htdocs/index..php
<?php
phpinfo()
?>

九、LAMP的安裝與配置

九、LAMP的安裝與配置

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI