您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
马哥linux运维学习笔记-编译安装LAMP之配置httpd以FastCGI方式与php整合
发布时间:2019-02-08 09:13:33编辑:雪饮阅读()
编译安装apache2.4.4
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
编译安装mysql5.6.10
[root@localhost src]# cp -r mysql-5.6.10-linux-glibc2.5-i686 /usr/local/mysql
[root@localhost mysql]# groupadd -r -g 306 mysql
[root@localhost mysql]# useradd -g 306 -r -u 306 mysql
[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
[root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf
配置文件
[root@localhost mysql]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
datadir = /mydata/data
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@localhost mysql]# chown -R root .
开启mysql
[root@localhost php-5.4.13]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL [ OK ]
fpm方式编译php5.4.13
安装依赖
php5.4.13的i386编译需要依赖以下rpm
libmcrypt-2.5.7-5.el5.i386.rpm
libmcrypt-devel-2.5.7-5.el5.i386.rpm
mhash-0.9.2-6.el5.i386.rpm
mhash-devel-0.9.2-6.el5.i386.rpm
编译
./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 --enable-fpm --with-mcrypt --with-config-file-path=/tec --with-config-file-scan-dir=/etc/php.d --with-bz2
make
make install
配置
[root@localhost php-5.4.13]# cp php.ini-production /etc/php.ini
[root@localhost php-5.4.13]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
fpm配置
[root@localhost php-5.4.13]# vim /usr/local/php/etc/php-fpm.conf
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 100
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 5
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 5
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 8
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
启动
[root@localhost php-5.4.13]# chmod +x /usr/local/src/php-5.4.13/sapi/fpm/init.d.php-fpm
[root@localhost php-5.4.13]# /usr/local/src/php-5.4.13/sapi/fpm/init.d.php-fpm start
Starting php-fpm done
虚拟主机
中心主机配置文件去除注释:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
Include /etc/httpd/extra/httpd-vhosts.conf
中心主机配置文件添加注释:
DocumentRoot "/usr/local/apache/htdocs"
虚拟主机配置如:
[root@localhost php-5.4.13]# cat /etc/httpd/extra/httpd-vhosts.conf
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
DocumentRoot "/www/a.org/"
ServerName www.a.org
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/www/a.org/$1
<Directory "/www/a.org">
Options none
AllowOverride none
Require all granted
</Directory>
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
hosts配置:
[root@localhost php-5.4.13]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.5 www.a.org
站点文件
[root@localhost php-5.4.13]# mkdir -p /www/a.org
[root@localhost php-5.4.13]# cat /www/a.org/index.html
this is fpm module of html
[root@localhost php-5.4.13]# cat /www/a.org/index.php
<?php
phpinfo();
?>
关联php
中心主机dir_module配置:
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
中心主机mime_module新增addtype:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
重启apache
[root@localhost pma]# /usr/local/apache/bin/apachectl restart
编译xcache3.0.1
编译
[root@localhost xcache-3.0.1]# /usr/local/php/bin/phpize
[root@localhost xcache-3.0.1]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
[root@localhost xcache-3.0.1]# make
[root@localhost xcache-3.0.1]# make install
配置
[root@localhost xcache-3.0.1]# mkdir -p /etc/php.d
[root@localhost xcache-3.0.1]# cp xcache.ini /etc/php.d/
[root@localhost xcache-3.0.1]# head /etc/php.d/xcache.ini
;; this is an example, it won't work unless properly configured into php.ini
[xcache-common]
;; non-Windows example:
extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache.so
;; Windows example:
; extension = php_xcache.dll
[xcache.admin]
xcache.admin.enable_auth = On
xcache.admin.user = "mOo"
重启php
[root@localhost xcache-3.0.1]# /usr/local/src/php-5.4.13/sapi/fpm/init.d.php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
关键字词:linux,httpd,fastcgi,php,mysql5.6.10,xcache3.0.1