加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

LAMP的安置与配置

发布时间:2022-03-08 07:11:39 所属栏目:MySql教程 来源:互联网
导读:PHP与httpd的结合工作方式 常见PHP开源软件: 论坛:phpwind、discuz 、phpbb 博客系统:wordpress 门户站点:drupal、xooms 数据库:phpMyAdmin、Workbench、MySQL Front、Navicat for MySQL、Toad CMS(Content Management System)内容管理系统:Drupal
       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服务遇到动态程序时都需要成新启动解析器)
 
 LAMP的安装与配置
 
  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
 编译安装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
 
[root@mylinux app]# tar xf apr-1.5.2.tar.gz
[root@mylinux app]# cd apr-1.5.2
[root@mylinux apr-1.5.2]## ./configure --prefix=/usr/local/apr
[root@mylinux apr-1.5.2]## make && make install
 
[root@mylinux app]# tar xf apr-util-1.5.4.tar.gz
[root@mylinux app]# cd apr-util-1.5.4
[root@mylinux apr-util-1.5.4]./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@mylinux apr-util-1.5.4]make && make install
 
[root@mylinux home]#yum install pcre-devel -y
 
[root@mylinux app]# tar xf httpd-2.4.25.tar.gz
[root@mylinux app]# cd httpd-2.4.25
[root@mylinux 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
[root@mylinux httpd-2.4.25]#make && make install
[root@mylinux httpd24]# vim /etc/httpd24/httpd.conf     #修改配置文件
   PidFile  "/var/run/httpd.pid"                        #添加该行
   ServerName 127.0.0.1:80                              #修改服务名称
   
#提供服务脚本
[root@mylinux httpd24]# cp /home/app/httpd-2.4.25/build/rpm/httpd.init /etc/rc.d/init.d/httpd
[root@mylinux 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
 
[root@mylinux init.d]# chmod +x /etc/rc.d/init.d/httpd   #为此脚本赋予执行权限
[root@mylinux init.d]# chkconfig --add httpd             #加入服务列表
[root@mylinux init.d]# service httpd start               #启动测试
Starting httpd: [  OK  ]
 LAMP的安装与配置
 
 通用二进制格式安装MySQL
 
[root@mylinux app]# tar xf mysql-5.5.55-linux2.6-x86_64.tar.gz
[root@mylinux 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'
[root@mylinux app]# cd mysql
[root@mylinux mysql]# chown -R root:mysql .
[root@mylinux mysql]# scripts/mysql_install_db --user=mysql          #初始化
[root@mylinux mysql]# cp support-files/my-large.cnf /etc/my.cnf      #提供配置文件
[root@mylinux mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld #服务脚本
[root@mylinux mysql]# service mysqld start                           #启动测试
Starting MySQL.. SUCCESS!
[root@mylinux profile.d]# vim /etc/mysql.sh                          #添加环境变量
[root@mylinux profile.d]# source mysql.sh
[root@mylinux 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
[root@mylinux profile.d]#
 安装PHP
 
# yum -y groupinstall "Desktop Platform Development"    #解决依赖关系
# yum -y install bzip2-devel libmcrypt-devel
[root@mylinux app]# tar xf php-5.6.30.tar.gz
[root@mylinux app]# cd php-5.6.30
[root@mylinux 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
[root@mylinux php-5.6.30]# make
[root@mylinux php-5.6.30]# make test
[root@mylinux php-5.6.30]# make install
[root@mylinux php-5.6.30]# cp php.ini-production  /etc/php.ini   #提供配置文件
 修改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>
 测试
 
[root@mylinux php-5.6.30]# service httpd restart
Stopping httpd: [  OK  ]
Starting httpd: [  OK  ]
[root@mylinux 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();
?>
[root@mylinux htdocs]# vim /usr/local/apache/htdocs/index..php
<?php
phpinfo()
?>

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读