1. 程式人生 > 實用技巧 >Centos7部署lamp: httpd2.4(event)+module模式

Centos7部署lamp: httpd2.4(event)+module模式

系統: Centos7

httpd版本: 2.4 使用event工作模式

安裝方法:

  1. 使用yum安裝httpd和mariadb

  2. 編譯安裝php,啟用多執行緒支援

一、安裝httpd和mariadb:

yum install -y httpd httpd-devel php-mysql mariadb-server

systemctl start mariadb //啟動mariadb

systemctl start httpd //啟動httpd

二、安裝PHP:

1.準備原始碼包

wKioL1hqF3jQVLrmAABv6yQRtZc347.png

2.安裝所需環境

yumgroupinstall -y "Development tools" "Server PlatformDevelopment"

yum install -y bzip2-devel libmcrypt-devel libxml2-developenssl-devel

3.安裝PHP

tar -xjvf php-5.4.26.tar.bz2

cd php-5.4.26

./configure--prefix=/usr/local/php --with-mysql --with-openssl --with-mysqli--enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir--with-zlib --with-libxml-dir=/usr --enable-xml--enable-sockets --with-apxs2 --with-mcrypt

--with-config-file-path=/etc/php--with-config-file-scan-dir=/etc/php/php.d --with-bz2 --enable-maintainer-zts

//使php支援多執行緒

make -j 4 && makeinstall //使用4執行緒編譯,能提高速度

mkdir /etc/php //用於存放php配置檔案,要和編譯時指定的一致

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

三、配置httpd:

vim /etc/httpd/conf.modules.d/00-mpm.conf

wKiom1hqF7jiR_IKAAItAKgsn0g463.png

vim /etc/httpd/conf/httpd.conf

wKioL1hqF9DxQ3rPAACyAw4oo6U801.png

wKiom1hqF-Wx0BS2AAGcOnMkZSc363.png

httpd -t //檢查配置

systemctl reload httpd //過載配置

wKioL1hqF_qjQq5mAACyafW99NY785.png

測試

vim /var/www/html/index.php //準備測試檔案

wKiom1hqGA7yVOy2AAAqnaq-o-c369.png

wKiom1hqGCOCVvhXAAFeHyP4r8c916.png

vim /var/www/html/db.php

wKioL1hqGDmhIuWeAAC7u4ND8jA108.png

wKiom1hqGE3RoGSpAAGIK8mOFnw406.png

四、整合xcache:

1.準備原始碼包

wKioL1hqGHCgUeD_AAB5xFg9eh4028.png

2.安裝xcache

tar -xjvf xcache-3.0.3.tar.bz2

cd xcache-3.0.3

/usr/local/php/bin/phpize //生成configure

wKioL1hqGIOAetWhAADAQ3V09pE537.png

./configure --enable-xcache--with-php-config=/usr/local/php/bin/php-config

make && make install

wKiom1hqGJnBknqzAAC-awMF0j0732.png

3.整合xcache

mkdir /etc/php/php.d//用於存放配置檔案,要和編譯php時指定的路徑一致

cp xcache-3.0.3/xcache.ini/etc/php/php.d //複製配置檔案

vim /etc/php/php.d/xcache.ini

wKioL1hqGL7wK2MFAAHUyenDufs930.png

systemctl reload httpd //過載配置檔案

wKioL1hqGNSi8PVkAAD1G0cszbs028.png


轉載於:https://blog.51cto.com/362475097/1888334