日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

模块式lamp fpm式lamp

發(fā)布時間:2025/5/22 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 模块式lamp fpm式lamp 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一組常用來搭建動態(tài)網(wǎng)站或者服務(wù)器的開源軟件,本身都是各自獨立的程序,但是因為常被放在一起使用,擁有了越來越高的兼容度,共同組成了一個強大的Web應(yīng)用程序平臺。隨著開源潮流的蓬勃發(fā)展,開放源代碼的LAMP已經(jīng)與J2EE和.Net商業(yè)軟件形成三足鼎立之勢,并且該軟件開發(fā)的項目在軟件方面的投資成本較低,因此受到整個IT界的關(guān)注。從網(wǎng)站的流量上來說,70%以上的訪問流量是LAMP來提供的,LAMP是最強大的網(wǎng)站解決方案.



LAMP指的Linux(操作系統(tǒng))、ApacheHTTP 服務(wù)器,MySQL(有時也指MariaDB,數(shù)據(jù)庫軟件) 和PHP(有時也是指Perl或Python) 的第一個字母,一般用來建立web應(yīng)用平臺。

雖然這些開放源代碼程序本身并不是專門設(shè)計成同另幾個程序一起工作的,但由于它們的免費和開源,這個組合開始流行(大多數(shù)Linux發(fā)行版本捆綁了這些軟件)。當(dāng)一起使用的時候,它們表現(xiàn)的像一個具有活力的解決方案包。其他的方案包有蘋果的WebObjects(最初是應(yīng)用服務(wù)器),Java/J2EE和微軟的.NET架構(gòu)。

LAMP包的腳本組件中包括了CGIweb接口,它在90年代初期變得流行。這個技術(shù)允許網(wǎng)頁瀏覽器的用戶在服務(wù)器上執(zhí)行一個程序,并且和接受靜態(tài)的內(nèi)容一樣接受動態(tài)的內(nèi)容。程序員使用腳本語言來創(chuàng)建這些程序因為它們能很容易有效的操作文本流,甚至當(dāng)這些文本流并非源自程序自身時也是。正是由于這個原因系統(tǒng)設(shè)計者經(jīng)常稱這些腳本語言為膠水語言。



網(wǎng)站架構(gòu)方案


LAMP(Linux- Apache-MySQL-PHP)網(wǎng)站架構(gòu)是目前國際流行的Web框架,該框架包括:Linux操作系統(tǒng),Apache網(wǎng)絡(luò)服務(wù)器,MySQL數(shù)據(jù) 庫,Perl、PHP或者Python編程語言,所有組成產(chǎn)品均是開源軟件,是國際上成熟的架構(gòu)框架,很多流行的商業(yè)應(yīng)用都是采取這個架構(gòu),和 Java/J2EE架構(gòu)相比,LAMP具有Web資源豐富、輕量、快速開發(fā)等特點,微軟的.NET架構(gòu)相比,LAMP具有通用、跨平臺、高性能、低價格的 優(yōu)勢,因此LAMP無論是性能、質(zhì)量還是價格都是企業(yè)搭建網(wǎng)站的首選平臺。

對于大流量、大并發(fā)量的網(wǎng)站系統(tǒng)架構(gòu)來說,除了硬件上使用高 性能的服務(wù)器、負載均衡、CDN等之外,在軟件架構(gòu)上需要重點關(guān)注下面幾個環(huán)節(jié):使用高性能的操作系統(tǒng)(OS)、高性能的網(wǎng)頁服務(wù)器(Web Server)、高性能的數(shù)據(jù)庫(Database)、高效率的編程語言等。下面我將從這幾點對其一一討論。

操作系統(tǒng)

Linux操作系統(tǒng)有很多個不同的發(fā)行版,如Red Hat Enterprise Linux、SUSE Linux Enterprise、Debian、Ubuntu、CentOS等,每一個發(fā)行版都有自己的特色,比如RHEL的穩(wěn)定,Ubuntu的易用,基于穩(wěn)定性 和性能的考慮,操作系統(tǒng)選擇CentOS(Community ENTerprise Operating System)是一個理想的方案。

CentOS(Community ENTerprise Operating System)是Linux發(fā)行版之一,是RHEL/Red Hat Enterprise Linux的精簡免費版,和RHEL為同樣的源代碼,不過,RHEL和SUSE LE等企業(yè)版,提供的升級服務(wù)均是收費升級,無法免費在線升級,因此要求免費的高度穩(wěn)定性的服務(wù)器可以用CentOS替代Red Hat Enterprise Linux使用。

Web服務(wù)器、緩存和PHP加速

Apache是LAMP架構(gòu)最核心的Web Server,開源、穩(wěn)定、模塊豐富是Apache的優(yōu)勢。但Apache的缺點是有些臃腫,內(nèi)存和CPU開銷大,性能上有損耗,不如一些輕量級的Web 服務(wù)器(例如nginx)高效,輕量級的Web服務(wù)器對于靜態(tài)文件的響應(yīng)能力來說遠高于Apache服務(wù)器。

Apache做為Web Server是負載PHP的最佳選擇,如果流量很大的話,可以采用nginx來負載非PHP的Web請求。nginx是一個高性能的HTTP和反向代理服 務(wù)器,Nginx以它的穩(wěn)定性、豐富的功能集、示例配置文件和低系統(tǒng)資源的消耗而聞名。Nginx不支持PHP和CGI等動態(tài)語言,但支持負載均衡和容 錯,可和Apache配合使用,是輕量級的HTTP服務(wù)器的首選。

Web服務(wù)器的緩存也有多種方案,Apache提供了自己的緩存模 塊,也可以使用外加的Squid模塊進行緩存,這兩種方式均可以有效的提高Apache的訪問響應(yīng)能力。Squid Cache是一個Web緩存服務(wù)器,支持高效的緩存,可以作為網(wǎng)頁服務(wù)器的前置cache服務(wù)器緩存相關(guān)請求來提高Web服務(wù)器的速度,把Squid放在 Apache的前端來緩存Web服務(wù)器生成的動態(tài)內(nèi)容,而Web應(yīng)用程序只需要適當(dāng)?shù)卦O(shè)置頁面實效時間即可。如訪問量巨大則可考慮使用memcache作 為分布式緩存。

PHP的加速使用eAccelerator加速器,eAccelerator是一個自由開放源碼PHP加速器,優(yōu)化和動 態(tài)內(nèi)容緩存,提高了性能PHP腳本的緩存性能,使得PHP腳本在編譯的狀態(tài)下,對服務(wù)器的開銷幾乎完全消除。它還有對腳本起優(yōu)化作用,以加快其執(zhí)行效率。 使PHP程序代碼執(zhí)效率能提高1-10倍。

具體的解決方案有以下幾種:

1、squid + Apache + PHP + eAccelerator

使用Apache負載PHP,使用squid進行緩存,html或圖片的請求可以直接由squid返回給用戶。很多大型網(wǎng)站都采用這種架構(gòu)。

2、nginx/Apache + PHP(fastcgi) + eAccelerator

使用nginx或Apache負載PHP,PHP使用fastcgi方式運行,效率較高。

3、nginx + Apache + PHP + eAccelerator

此方案綜合了nginx和Apache的優(yōu)點,使用Apache負載PHP,nginx負責(zé)解析其他Web請求,使用nginx的rewrite模塊,Apache端口不對外開放。

數(shù)據(jù)庫

開源的數(shù)據(jù)庫中,MySQL在性能、穩(wěn)定性和功能上是首選,可以達到百萬級別的數(shù)據(jù)存儲,網(wǎng)站初期可以將MySQL和Web服務(wù)器放在一起,但是當(dāng)訪問 量達到一定規(guī)模后,應(yīng)該將MySQL數(shù)據(jù)庫從Web Server上獨立出來,在單獨的服務(wù)器上運行,同時保持Web Server和MySQL服務(wù)器的穩(wěn)定連接。

當(dāng)數(shù)據(jù)庫訪問量達到更大的級別,可以考慮使用MySQL Cluster等數(shù)據(jù)庫集群或者庫表散列等解決方案。

總的來說,LAMP架構(gòu)的網(wǎng)站性能會遠遠優(yōu)于Windows IIS + ASP + Access(例如月光博客)這樣的網(wǎng)站,可以負載的訪問量也非常大,國內(nèi)的大量個人網(wǎng)站如果想要支撐大訪問量,采用LAMP架構(gòu)是一個不錯的方案。

綜上所述,基于LAMP架構(gòu)設(shè)計具有成本低廉、部署靈活、快速開發(fā)、安全穩(wěn)定等特點,是Web網(wǎng)絡(luò)應(yīng)用和環(huán)境的優(yōu)秀組合。[1]?

LAMP安裝



適用環(huán)境


系統(tǒng)支持:CentOS-5 (32bit/64bit)、CentOS-6 (32bit/64bit)等linux系統(tǒng)

內(nèi)存要求:≥256M

安裝了什么


1、Apache

2、MySQL

3、PHP

4、phpmyadmin 3.5.1

5、ZendOptimizer 3.3.9(可選,只適合PHP 5.2.17)

6、xcache 1.3.2(可選)

7、pure-ftpd-1.0.36(可選)

如何安裝


安裝方法見參考資料[2]?

安裝其它


1、執(zhí)行腳本pureftpd. sh安裝pure-ftpd。

2、執(zhí)行腳本zend. sh安裝ZendOptimizer。

3、執(zhí)行腳本xcache. sh安裝xcache。

使用提示


LAMP腳本使用

lamp add(del,list):創(chuàng)建(刪除,列出)虛擬主機。

lamp ftp(add|del|list):創(chuàng)建(刪除,列出)ftp用戶。

lamp uninstall:一鍵卸載lamp(卸載之前注意備份好數(shù)據(jù)!)。

程序目錄

mysql目錄: /usr/local/mysql

mysqldata目錄:/usr/local/mysql/data

php目錄: /usr/local/php

apache目錄: /usr/local/apache

進程管理

apache啟動(停止|重啟|重載配置文件):service httpd start(stop|restart|reload)

mysql(停止|重啟|重載配置文件):service mysqld start(stop|restart|reload)

vsftpd(停止|重啟|重載配置文件):service vsftpd start(stop|restart|reload)

配置文件路徑

apache:/etc/httpd/conf

mysql:/etc/my.cnf

php:/etc/php.ini /etc/php.d

pure-ftpd:/etc/pure-ftpd.conf

使用注意

1、mysqlroot密碼存放在/root/my.cnf文件中,添加虛擬主機的時候需要調(diào)用。如果修改了root密碼,請手動更新my.cnf文件


LAMP(Linux- Apache-MySQL-PHP)網(wǎng)站架構(gòu)是目前國際流行的Web框架,該框架包括:Linux操作系統(tǒng),Apache網(wǎng)絡(luò)服務(wù)器,MySQL數(shù)據(jù)庫,Perl、PHP或者Python編程語言,所有組成產(chǎn)品均是開源軟件,是國際上成熟的架構(gòu)框架,很多流行的商業(yè)應(yīng)用都是采取這個架構(gòu)。LAMP具有通用、跨平臺、高性能、低價格的 優(yōu)勢,因此LAMP無論是性能、質(zhì)量還是價格都是企業(yè)搭建網(wǎng)站的首選平臺。

二 Mysql 配置

1首先下載mysql-5.5.33包組(mariadb-5.5.36-linux-x86_64.tar.gz),然后解壓mariadb-5.5.36-linux-x86_64.tar.gz到/usr/local

[root@localhost ~]# tar xfmariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local

2 準(zhǔn)備數(shù)據(jù)存放的文件系統(tǒng)

? a 新建一個sda3

? ? ? ?[root@localhost~]# fdisk /dev/sda

? ? ? ?Command (m for help): n

Commandaction

? ?e ?extended

? ?p ?primary partition (1-4)

p ? ?

Partitionnumber (1-4): 3 ? ??

Firstcylinder (7859-13054, default 7859):

Usingdefault value 7859

Lastcylinder, +cylinders or +size{K,M,G} (7859-13054, default 13054): +20G ? ? ?

?

Command(m for help): t

Partitionnumber (1-4): 3

Hex code(type L to list codes): 8e ? ?(文件系統(tǒng)為LVM)

Changedsystem type of partition 3 to 8e (Linux LVM)

?

Command (m for help): w

?

b讀入磁盤中

? ?[root@localhost ~]# kpartx -af /dev/sda

device-mapper: reload ioctl on sda1failed: Invalid argument

create/reload failed on sda1

device-mapper: reload ioctl on sda2failed: Invalid argument

create/reload failed on sda2

device-mapper: reload ioctl on sda3failed: Invalid argument

create/reload failed on sda3

?

? [root@localhost ~]# partx -a /dev/sda

BLKPG: Device or resource busy

error adding partition 1

BLKPG: Device or resource busy

error adding partition 2

BLKPG: Device or resource busy

error adding partition 3 ? ? ? ? (表示已經(jīng)讀入到磁盤中)

?

c 新建邏輯卷,并將其掛載至特定目錄,此處目錄設(shè)置為/mydata

? ?[root@localhost ~]# pvcreate /dev/sda3

?Physical volume "/dev/sda3" successfully created

[root@localhost ~]# vgcreate myvg/dev/sda3

?Volume group "myvg" successfully created

[root@localhost ~]# lvcreate -L 10G -nmydata myvg

?Logical volume "mydata" created

[root@localhost ~]# mke2fs -t ext4 -LMYDATA -b 4096 -m 3 /dev/myvg/mydata

? ?

? ? ?并且能開機掛載,編輯fastab文件

? ? ?/dev/mapper/vg0-root ? ?/ ? ? ? ? ? ? ? ? ? ? ? ext4 ? ?defaults ? ? ? ?1 1

UUID=90ebd4cf-95c1-4338-b0dd-19b2b1cb943d/boot ? ? ? ? ? ? ? ? ? ext4 ? ?defaults ? ? ? ?1 2

/dev/mapper/vg0-usr ? ? /usr ? ? ? ? ? ? ? ? ? ?ext4 ? ?defaults ? ? ? ?1 2

/dev/mapper/vg0-var ? ? /var ? ? ? ? ? ? ? ? ? ?ext4 ? ?defaults ? ? ? ?1 2

/dev/mapper/vg0-swap ? ?swap ? ? ? ? ? ? ? ? ? ?swap ? ?defaults ? ? ? ?0 0

tmpfs ? ? ? ? ? ? ? ? ? /dev/shm ? ? ? ? ? ? ? ?tmpfs ? defaults ? ? ? ?0 0

devpts ? ? ? ? ? ? ? ? ?/dev/pts ? ? ? ? ? ? ? ?devpts ?gid=5,mode=620 ?0 0

sysfs ? ? ? ? ? ? ? ? ? /sys ? ? ? ? ? ? ? ? ? ?sysfs ? defaults ? ? ? ?0 0

proc ? ? ? ? ? ? ? ? ? ?/proc ? ? ? ? ? ? ? ? ? proc ? ?defaults ? ? ? ?0 0

LABEL=MYDATA ? ? ? ? ? ?/mydata ? ? ? ? ? ? ? ? ext4 ? ?defaults ? ? ? ?0 0?

(開機掛載)

? ?

d ?新建用戶以安全方式運行進程,并創(chuàng)建鏈接

? ? [root@localhost ~]# groupadd -r mysql

[root@localhost ~]# useradd-g mysql -r mysql

[root@localhost ~]# idmysql

uid=496(mysql)gid=493(mysql) groups=493(mysql)

[root@localhost ~]#chown ?-R mysql.mysql /mydata/data/

[root@localhost ~]# ll -a/mydata/data/

total 8

drwxr-xr-x 2 mysql mysql4096 Aug 11 20:15 .

先進入/usr/local目錄下

[root@localhost local]# ln-sv mariadb-5.5.36-linux-x86_64 mysql

?

lrwxrwxrwx ?1 root root ? 27 Aug 11 20:18mysql -> mariadb-5.5.36-linux-x86_64

?

e 為mysql提供主配置文件

cd/usr/local/mysql/

?

mkdir /etc/mysql創(chuàng)建一個目錄,因為在/etc下有個my.cnf

cpsupport-files/my-large.cnf /etc/mysql/my.cnf

vim/etc/mysql/my.cnf

?

? ? ?port ? ? ? ? ? ?= 3306

socket ? ? ? ? ?=/tmp/mysql.sock

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 1M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size= 16M

# Try number of CPU's*2 for thread_concurrency

thread_concurrency = 8

datadir = /mydata/data ? ?(指定mysql數(shù)據(jù)文件的存放位置)

?

開始初始化

[root@localhostmysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data/

(此處必須在 mysql 目錄下,要在scripts初始化,會報錯)

?

f ?為mysql提供sysv服務(wù)腳本

? ?[root@localhostmysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

??

然后添加到服務(wù)列表中

? ?[root@localhost mysql]# chkconfig --addmysqld

? [root@localhost mysql]# chkconfig --list mysqld

mysqld ? ? ? ? ? ?0:off1:off2:on3:on4:on5:on6:off

?

啟動服務(wù)

root@localhost mysql]# service mysqld start

Starting MySQL... ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [ ?OK ?]

[root@localhost mysql]# ss -tnl

State ? ? Recv-Q Send-Q ? ? ? ? ? ? ? ?Local Address:Port ? ? ? ? ? ? ? ? ?Peer Address:Port

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*:52971 ? ? ? ? ? ? ? ? ? ? ? ? ? ? *:* ? ?

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :::50732 ? ? ? ? ? ? ? ? ? ? ? ? ? ?:::* ? ?

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :::111 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?:::* ? ?

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*:111 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *:* ? ?

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :::22 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :::* ? ?

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*:22 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*:* ? ?

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ?127.0.0.1:631 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *:* ? ?

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?::1:631 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?:::* ? ?

LISTEN ? ?0 ? ? ?100 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?::1:25 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :::* ? ?

LISTEN ? ?0 ? ? ?100 ? ? ? ? ? ? ? ? ? ? ? ?127.0.0.1:25 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*:* ? ?

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ?127.0.0.1:6010 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*:* ? ?

LISTEN ? ?0 ? ? ?128 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?::1:6010 ? ? ? ? ? ? ? ? ? ? ? ? ? ? :::* ? ?

LISTEN ? ? 0 ? ? 50 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*:3306 ? ? ? ? ? ? ? ? ? ? ? ? ? ? *:* ? (3306端口已啟動)

?

設(shè)置權(quán)限

? ?[root@localhostmysql]#chmod +x /etc/rc.d/init.d/mysqld

?

?

g ?編輯環(huán)境變量

[root@localhost~]# vim /etc/profile.d/mysql.sh

exportPATH=/usr/local/mysql/bin:$PATH

?

h導(dǎo)出頭文件和庫文件

? ?ln -sv /usr/local/mysql/include ?/usr/include/mysql

??

[root@localhost~]# vim /etc/ld.so.conf.d/mysql.conf (新建)

? ? ? ? ? ? ? ? ? ?/usr/local/mysql/lib

? ?讓系統(tǒng)重新載入

[root@localhost ~]#ldconfig -v | grep mysql

/usr/local/mysql/lib:

? ? ? ? ? ? ? ? ? ?libmysqld.so.18 -> libmysqld.so.18

? ? ? ? ? ? ? ? ? ?libmysqlclient.so.18 ->libmysqlclient_r.so.18.0.0

/usr/lib64/mysql:

? ? ? ? ? ? ? ? ?libmysqlclient.so.16 -> libmysqlclient.so.16.0.0

? ? ? ? ? ? ? ? ?libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0


三 Apache2.4.9 編譯安裝

首先檢測pcre-devel ?"Development tools" "Server Platform Development" ?這個三個包組裝了沒

yum -y install pcre-devel

yum -y groupinstall "Development tools"

yum -y groupinstall "Server Platform Development


然后編譯安裝apr

# tar xf apr-1.5.0.tar.bz2

# cd apr-1.5.0

# ./configure --prefix=/usr/local/apr

# make && make install

在編譯apr-util

# tar xf apr-util-1.5.3.tar.bz2

# cd apr-util-1.5.3

# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

# make && make install

編譯安裝httpd2.4.9

# tar xf httpd-2.4.9.tar.bz2

# cd httpd-2.4.9

# ./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

# make && make install

(為了不和系統(tǒng)的httpd沖突,我們指定其安裝路徑為/usr/local/apache,配置文件裝到/etc/httd24中,同時一會兒的服務(wù)也要改為httpd24 )


修改httpd的主配置文件,設(shè)置其Pid文件的路徑

[root@web httpd24]# vim /etc/httpd24/httpd.conf?

#添加下面一行

PidFile "/var/run/httpd.pid"


提供SysV服務(wù)腳本/etc/rc.d/init.d/httpd,內(nèi)容


#!/bin/bash

#

# httpd ? ? ? ?Startup script for the Apache HTTP Server

#

# chkconfig: - 85 15

# description: Apache is a World Wide Web server. ?It is used to serve \

# ? ? ? ?HTML files and CGI.

# processname: httpd

# config: /etc/httpd/conf/httpd.conf

# config: /etc/sysconfig/httpd

# pidfile: /var/run/httpd.pid

# Source function library.

. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then

? ? ? ? . /etc/sysconfig/httpd

fi

# Start httpd in the C locale by default.

HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if

# mod_ssl needs a pass-phrase from the user.

INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server

# with the thread-based "worker" MPM; BE WARNED that some modules may not

# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.

apachectl=/usr/local/apache/bin/apachectl

httpd=${HTTPD-/usr/local/apache/bin/httpd}

prog=httpd

pidfile=${PIDFILE-/var/run/httpd.pid}

lockfile=${LOCKFILE-/var/lock/subsys/httpd}

RETVAL=0

start() {

? ? ? ? echo -n $"Starting $prog: "

? ? ? ? LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS

? ? ? ? RETVAL=$?

? ? ? ? echo

? ? ? ? [ $RETVAL = 0 ] && touch ${lockfile}

? ? ? ? return $RETVAL

}

stop() {

? echo -n $"Stopping $prog: "

? killproc -p ${pidfile} -d 10 $httpd

? RETVAL=$?

? echo

? [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}

}

reload() {

? ? echo -n $"Reloading $prog: "

? ? if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then

? ? ? ? RETVAL=$?

? ? ? ? echo $"not reloading due to configuration syntax error"

? ? ? ? failure $"not reloading $httpd due to configuration syntax error"

? ? else

? ? ? ? killproc -p ${pidfile} $httpd -HUP

? ? ? ? RETVAL=$?

? ? fi

? ? echo

}

# See how we were called.

case "$1" in

? start)

? start

? ;;

? stop)

? stop

? ;;

? status)

? ? ? ? status -p ${pidfile} $httpd

? RETVAL=$?

? ;;

? restart)

? stop

? start

? ;;

? condrestart)

? if [ -f ${pidfile} ] ; then

? ? stop

? ? start

? fi

? ;;

? reload)

? ? ? ? reload

? ;;

? graceful|help|configtest|fullstatus)

? $apachectl $@

? RETVAL=$?

? ;;

? *)

? echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"

? exit 1

esac

exit $RETVAL

而后為此腳本賦予執(zhí)行權(quán)限:

# chmod +x /etc/rc.d/init.d/httpd

加入服務(wù)列表:

# chkconfig --add httpd


wKiom1PrVenQPQEzAAAuDD309YE097.png


3 編譯安裝php-5.4.26

先解決依賴關(guān)系,不過首先要解決yum源問題,

# yum -y groupinstall "X Software Development"?


編譯安裝php-5.4.26

# tar xf php-5.4.26.tar.bz2

# cd php-5.4.26

./configure --prefix=/usr/local/php5 --with-mysql=--with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysqli=--with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml ?--enable-sockets --enable-fpm --with-mcrypt ?--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2

(因為本機是沒有裝mysql,所以文中紅色部分是本機沒裝mysql的編譯)

# make

# make install



然后為

為php提供配置文件:

# cp php.ini-production /etc/php.ini



配置php-fpm

?

為php-fpm提供SysV init腳本,并將其添加至服務(wù)列表:

# cp sapi/fpm/init.d.php-fpm ?/etc/rc.d/init.d/php-fpm

# chmod +x /etc/rc.d/init.d/php-fpm

# chkconfig --add php-fpm

# chkconfig php-fpm on


為php-fpm提供配置文件:

# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf?

# vim /usr/local/php/etc/php-fpm.conf

pm.max_children = 50

pm.start_servers = 5

pm.min_spare_servers = 2

pm.max_spare_servers = 8

pid = /usr/local/php/var/run/php-fpm.pid?

然后重啟服務(wù)

# service php-fpm start

查看端口

# netstat -tnlp | grep php-fpm

tcp ? ? ? ?0 ? ? ?0 127.0.0.1:9000 ? ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?689/php-fpm?


配置http-2.4.9

在Apache httpd 2.4以后已經(jīng)專門有一個模塊針對FastCGI的實現(xiàn),此模塊為mod_proxy_fcgi.so,它其實是作為mod_proxy.so模塊的 擴充,因此,這兩個模塊都要加載

? ? ? ?LoadModule proxy_module modules/mod_proxy.so

? ? ? ?LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so


配置虛擬主機支持使用fcgi

? ? ?1)要使用虛擬主機,首先要關(guān)閉中心主機,再開啟虛擬主機的模塊兒,也是在/etc/httpd24/httpd.conf中

? ? ?在相應(yīng)的虛擬主機中添加類似如下兩行。

ProxyRequests Off ?關(guān)閉正向代理

ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/PATH/TO/DOCUMENT_ROOT/$1


然后編輯apache配置文件httpd.conf,讓apache能識別php格式的頁面,并支持php格式的主頁

?

?# vim /etc/httpd/httpd.conf

?1、添加如下二行

? ?AddType application/x-httpd-php ?.php

? ?AddType application/x-httpd-php-source ?.phps


?2、定位至DirectoryIndex index.html


轉(zhuǎn)載于:https://blog.51cto.com/10116624/1642336

總結(jié)

以上是生活随笔為你收集整理的模块式lamp fpm式lamp的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。