LAMP編譯安裝(續)

搭建環境:Centos 6.8,httpd2.4.18,mysql 5.6.23,php 5.6.17 php

接上篇http://zhoufan.blog.51cto.com/4278592/1830297 ,上篇使用httpd和php模塊化安裝,php編譯安裝--with-apxs2,此篇文章做爲補充,使用fastcgi,php獨立運行。html

httpd和mysql安裝均前面同樣。mysql

tar -xf php-5.6.17.tar.xz        
cd php-5.6.17

若是沒有安裝MySQL(基本就是分佈式安裝的模式)sql

 ./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --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  --enable-maintainer-zts

若是已經安裝MySQL(基本就是單機模式)apache

 ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl --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  --enable-maintainer-zts

其實php編譯模塊不一樣點只是把 --with-apxs2=/usr/local/apache/bin/apxs替換爲 --enable-fpm而已。api

make ZEND_EXTRA_LIBS='-liconv' 
make install

複製PHP配置及設置開機啓動(其實LNMP就是使用的php-fpm,此處就作過多描述)bash

cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
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
service php-fpm start

在http中增長反向代理模塊
socket

LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_module modules/mod_proxy.so

配置虛擬主機支持使用fcgi,在相應的主機中添加相似以下兩行。分佈式

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

定位DirectoryIndexide

DirectoryIndex  index.php  index.html


LAMP yum安裝(通常網站訪問量不高,YUM安裝是最有效的一種方法)

安裝Apache及其擴展

yum -y install httpd
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

安裝配置MySQL

yum -y install mysql mysql-server mysql-devel

mysql secure_installation(編譯安裝能夠使用這個,刪除測試庫,設置密碼均更方便)

service mysqld start
/usr/bin/mysql_secure_installation

安裝php及其擴展

yum -y install php php-mysql
yum -y install gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap

啓動httpd服務

service httpd start

設置開啓啓動項

chkconfig httpd on
chkconfig mysqld on
相關文章
相關標籤/搜索