编译安装LAMP
一、安装mariadb
二、安装httpd
三、php编译
四、apache的代理指令
五、其他LAMP结合的方式 c---httpd[modules] 1.httpd基于模块生成子进程,处理动态请求, 2.httpd使用fcgi模块,反向代理到fpm服务,fpm负责加载资源并处理动态资源 PHP是cpu密集型 mariadb即是IO密集型也是CPU密集型 一般建议fpm和httpd在同一个主机上,mariadb在同一个主机上 但是建议做实验的时候,三个机器同时做 动态资源是瓶颈: ps aux | egrep -i "httpd|fpm|mysql" //这三个服务都启动了 ab -n 1000 -c 200 http://192.168.4.100/pmd/index.php //测试动态资源响应速度 ab -n 1000 -c 100 http://192.168.4.100/a.html //速度接近10倍 编译安装LAMP: httpd:编译安装,httpd-2.4,apr,apr-utils php5:编译安装php5.4,php5.3 mariadb:通用二进制安装,mariadb-5.5版本注意:任何一个程序包被编译操作依赖时,需要安装此程序包的“开发”组件,其包名一般为name-resolve-VERSION需要先安装mairadb,因为php依赖一、安装mariadb 二进制tar xvf mariadb-10.1.8-linux-glibc_214-x86_64.tar.gz -C /usr/local/cd /usr/local/ln -sv mariadb-10.1.8-linux-x86_64/ mysqlid mysql || useradd -r mysqlcd mysqlchown root:mysql ./*mkdir /mydata/data/ -pvchown mysql.mysql /mydata/data/ -Rcp support-files/mysql.server /etc/rc.d/init.d/mysqldchmod +x chkconfig --add mysqldmkdir /etc/mysqlcp support-files/my-large.cnf /etc/mysql/my.cnfvim my.cnf [mysqld] data_dir = /mydata/data skip_name_resolve = on innodb_file_per_table = on scripts/mysql_install_db --user=mysql --skip-name-resolve --datadir=/mydata/dataservice mysqld start后续:vim /etc/profile.d/mysql.sh export PATH=/usr/local/mysql/bin:$PATH. /etc/profile.d/mysql.sh vim /etc/ld.so.conf.d/mysql.conf/usr/local/mysql/libldconfigldconfig -p |grep mysql ln -sv /usr/local/mysql/include/ /usr/include/错误:libjemalloc.so.1: cannot open shared object file: No such file or directory libjemalloc.so.1 //找不到yum install jemalloc -y httpd-2.4.9php-5.4.26yum group install "Server Platform Development" "Development Tools"yum install apr-devel -yyum install apr-util-devel -yyum install pcre-devel -yyum install openssl-devel -y 二、安装httpdtar xvf httpd-2.4.9.tar.bz2 -C /usr/local/ln -sv httpd-2.4.9/ httpd./configure --prefix=/usr/local/apache24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-rewrite --with-zlib --with-pcre --with-apr=/usr --with-apr-util=/usr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork //默认使用的是prefork模型make -j 4 && make install编译安装http2.4# 各编译参数详解 --prefix:#安装路径 --sysconfdir:#指定配置文件路径 --enable-so:#DSO兼容,DSO=Dynamic Shared Object,动态共享对象,可实现模块动态生效 --enable-ssl:#支持SSL/TLS,可以实现https访问 --enable-cgi:#支持CGI脚本(默认对非线程的MPM模式开启) --enable-rewrite:#启用Rewrite功能,url重写 --enable-deflate:#支持压缩 --with-z:#使用指定的zlib库,不指定路径会自动寻找 --with-pcre:#使用指定的PCRE库,不指定路径会自动寻找,支持perl扩展的正则表达式 --with-apr:#指定apr安装路径 --with-apr-util:#指定apr-util安装路径 --enable-modules:#支持动态启用的模块,可选参数有“all”,“most”,“few”,“reallyall” --enable-mpms-shared:#支持动态加载的MPM模块,可选“all” --with-mpm:#设置默认启用的MPM模式vim /etc/profile.d/apache.sh export PATH=/usr/local/apache24/bin:$PATHsource /etc/profile.d/apache.shapachectl start浏览器测试一下vim /usr/lib/systemd/system/httpd.service //提供unit启动脚本 三、php编译要确定自己的mpm使用的是哪个模块profork则,php编译成php进程式的模块的php5,worker或event,php5对应php5-zts因为:进程式的mpm和线程式的mpm是不兼容的 yum install libxml2-devel libmcrypt-devel bzip2-devel -y./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-png-dir --with-jpeg-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache24/bin/apxs --with-mycrypt --with-config-file-path=/etc/ --with-config-file-scan-dir=/etc/php.d --with-bz2make -j 4 && make install //编译为httpd的模块cp php.ini-production /etc/php.inivim httpd.conf AddType application/x-httpd-php .php Directory index.php index.htm编辑测试页为index.php四、apache的代理指令 这几个都是APACHE的代理指令:1、ProxyPass: 语法:ProxyPass [path] !|url 它主要是用作URL前缀匹配,不能有正则表达式,它里面配置的Path实际上是一个虚拟的路径,在反向代理到后端的url后,path是不会带过去的,使用示例: 1)、ProxyPass /images/ ! 这个示例表示,/images/的请求不被转发。 2)、ProxyPass /mirror/foo/ http://backend.example.com/ 我们假设当前的服务地址是http://example.com/,如果我们做下面这样的请求: http://example.com/mirror/foo/bar 那将被转成内部请求: http://backend.example.com/bar 注:配置的时候,不需要被转发的请求,要配置在需要被转发的请求前面。2、ProxyPassMatch: 语法:ProxyPassMatch [regex] !|url 这个实际上是url正则匹配,而不是简单的前缀匹配,匹配上的regex部分是会带到后端的url的,这个是与ProxyPass不同的。使用示例: 1、ProxyPassMatch ^/images ! 这个示例表示对/images的请求,都不会被转发。 2、ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com$1 这个示例表示对所有gif图片的请求,都被会转到后端,如此时请求http://example.com/foo/bar.gif, 那内部将会转换为这样的请求http://backend.example.com/foo/bar.gif。 3、ProxyPassReverse 语法:ProxyPassReverse [路径] url 它一般和ProxyPass指令配合使用,此指令使Apache调整HTTP重定向应答中Location, Content-Location, URI头里的URL,这样可以避免在Apache作为反向代理使用时,。后端服务器的HTTP重定向造成的绕过反向代理的问题。参看下面的示例: ProxyPass /example http://www.example.com/ ProxyPassReverse /example http://www.example.com/ ProxyPassReverse的作用就是反向代理,如果没有加这样的反向代理设置的情况下,访问http://www.test.com /example/a,如果www.example.com对请求进行了redirect至http://www.example.com/b,那么,客 户端就会绕过反向代理,进而访问http://www.test.com/example/b。如果设置了反向代理,则会在转交HTTP重定向应答到客户 端之前调整它为http://www.test.com/example/a/b,即是在原请求之后追加上了redirect的路径。 var html = document.getElementById("artContent").innerHTML; document.getElementById("artContent").innerHTML = html; 五、其他centos7上实现lamp(module)机制, 1.三者分离于三台主机 2.一个虚拟主机用于提供phpMyadmin对mysql进行管理,基于图形化;另一个提供wordpress 3.xcache 4.为phpmyadmin提供https虚拟主机Centos7,lamp(php-fpm) 1.三者分离于三台主机 2.一个虚拟主机用于提供phpMyadmin对mysql进行管理,基于图形化;另一个提供wordpress 3.xcache Centos7:编译安装lamp 1.三者分离于三台主机 2.一个虚拟主机用于提供phpMyadmin对mysql进行管理,基于图形化;另一个提供wordpress 3.xcache 4.尝试mpm为非prefork机制 编译安装参考博客:http://blog.51cto.com/cuchadanfan/1688813
本文转自MT_IT51CTO博客,原文链接:http://blog.51cto.com/hmtk520/2063428,如需转载请自行联系原作者