九LAMP的安装与配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了九LAMP的安装与配置相关的知识,希望对你有一定的参考价值。
9.1、php与httpd的结合工作方式
常见PHP开源软件:
论坛:phpwind、discuz 、phpbb 博客系统:wordpress 门户站点:drupal、xooms 数据库:phpMyAdmin、Workbench、mysql Front、Navicat for MySQL、Toad CMS(Content Management System)内容管理系统:Drupal、joomla |
PHP与httpd的结合方式:
Module作为模块,需要时加载:
prefork: 一个请求用一个进程处理,稳定性好、大并发场景下消耗资源较多;事先创建进程,按需维 持适当的进程,模块块设计,核心比较小,各种功能都模块添加(包括php),支持运行配置,支持单独编译模块,支持多种方式的虚拟主机配置。 worker: 一个进程多个线程,一个线程响应一个请求 event: 一个线程响应多个请求,事件驱动,主要目的在于实现单线程响应多个请求 |
Cgi(Common gateway interface):通用网关接口,为HTTP服务器与其他机器上的程序服务通信的一种交流工具。(CGI程序必须运行在网络服务器,每次HTTP服务遇到动态程序时都需要成新启动解析器)
Fastcgi,可伸缩的,高速的在HTTP服务器和动态脚本语言间通信的接口,优点是把动态语言和HTTP服务器相分离。其主要行为是将CGI解释器进程保持在内存中并因此获得较高的性能。CGI解释器的反复加载是CGI性能低下的主要原因,如果CGI解释器保持在内存中并接受FastCGI进程管理器调度,则可以提供良好的性能、伸缩性、Fail- Over特性等等。
LAMP配置顺序:httpd --> MySQL --> php --> XCache(缓存器/优化器)
rpm格式配置lamp
# yum -y install httpd php php-mysql mysql-server mysql php-mcrypt
9.2、编译安装LAMP
软件版本:
apacge:httpd-2.4.25.tar.gz 依赖包:apr-1.5.2.tar.gz apr-util-1.5.4.tar.gz mysql:mysql-5.5.55-linux2.6-x86_64.tar.gz php: php-5.6.30-src.zip |
#wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.25.tar.gz #wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz #wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz #wget http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz #wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
1、安装apache
[[email protected] app]# tar xf apr-1.5.2.tar.gz [[email protected] app]# cd apr-1.5.2 [[email protected] apr-1.5.2]## ./configure --prefix=/usr/local/apr [[email protected] apr-1.5.2]## make && make install [[email protected] app]# tar xf apr-util-1.5.4.tar.gz [[email protected] app]# cd apr-util-1.5.4 [[email protected] apr-util-1.5.4]./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ [[email protected] apr-util-1.5.4]make && make install [[email protected] home]#yum install pcre-devel -y [[email protected] app]# tar xf httpd-2.4.25.tar.gz [[email protected] app]# cd httpd-2.4.25 [[email protected] httpd-2.4.25]# ./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 [[email protected] httpd-2.4.25]#make && make install [[email protected] httpd24]# vim /etc/httpd24/httpd.conf #修改配置文件 PidFile "/var/run/httpd.pid" #添加该行 ServerName 127.0.0.1:80 #修改服务名称 #提供服务脚本 [[email protected] httpd24]# cp /home/app/httpd-2.4.25/build/rpm/httpd.init /etc/rc.d/init.d/httpd [[email protected] init.d]# vim /etc/rc.d/init.d/httpd #修改相关参数 CONFFILE=/etc/httpd24/httpd.conf apachectl=/usr/local/apache/bin/apachectl httpd=${HTTPD-/usr/local/apache/bin/httpd} pidfile=${PIDFILE-/var/run/${prog}.pid} lockfile=${LOCKFILE-/var/lock/subsys/${prog}} RETVAL=0 prog=httpd [[email protected] init.d]# chmod +x /etc/rc.d/init.d/httpd #为此脚本赋予执行权限 [[email protected] init.d]# chkconfig --add httpd #加入服务列表 [[email protected] init.d]# service httpd start #启动测试 Starting httpd: [ OK ]
2、通用二进制格式安装MySQL
[[email protected] app]# tar xf mysql-5.5.55-linux2.6-x86_64.tar.gz [[email protected] app]# ln -sv /home/app/mysql-5.5.55-linux2.6-x86_64 /usr/local/mysql `/usr/local/mysql‘ -> `/home/app/mysql-5.5.55-linux2.6-x86_64‘ [[email protected] app]# cd mysql [[email protected] mysql]# chown -R root:mysql . [[email protected] mysql]# scripts/mysql_install_db --user=mysql #初始化 [[email protected] mysql]# cp support-files/my-large.cnf /etc/my.cnf #提供配置文件 [[email protected] mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld #服务脚本 [[email protected] mysql]# service mysqld start #启动测试 Starting MySQL.. SUCCESS! [[email protected] profile.d]# vim /etc/mysql.sh #添加环境变量 [[email protected] profile.d]# source mysql.sh [[email protected] profile.d]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.55-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> quit Bye [[email protected] profile.d]#
3、安装PHP
# yum -y groupinstall "Desktop Platform Development" #解决依赖关系 # yum -y install bzip2-devel libmcrypt-devel [[email protected] app]# tar xf php-5.6.30.tar.gz [[email protected] app]# cd php-5.6.30 [[email protected] php-5.6.30]# ./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 --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts [[email protected] php-5.6.30]# make [[email protected] php-5.6.30]# make test [[email protected] php-5.6.30]# make install [[email protected] php-5.6.30]# cp php.ini-production /etc/php.ini #提供配置文件
4、修改apache相关配置
# vim /etc/httpd/httpd.conf AddType application/x-httpd-php .php #添加两行 AddType application/x-httpd-php-source .phps ... <IfModule dir_module> DirectoryIndex index.php index.html #修改该行 </IfModule>
5、测试
[[email protected] php-5.6.30]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] [[email protected] htdocs]# vim /usr/local/apache/htdocs/123.php <?php $link = mysql_connect(‘127.0.0.1‘); if ($link) echo "Success..."; else echo "Failure..."; mysql_close(); ?> [[email protected] htdocs]# vim /usr/local/apache/htdocs/index..php <?php phpinfo() ?>
本文出自 “随风而飘” 博客,请务必保留此出处http://yinsuifeng.blog.51cto.com/10173491/1932921
以上是关于九LAMP的安装与配置的主要内容,如果未能解决你的问题,请参考以下文章