LAMP(Linux-Apache-MySQL-PHP)网站架构是目前国际流行的Web框架。该框架能够满足大流量、大并发量的网站需求;当然、也可以直接使用高性能的服务器、高性能的负载均衡硬件以及CDN加速等。若想真正的设计一个非常好的支撑高并发、高吞吐量的架构,除了必要的高性能的硬件之外,还必须要慎重的选择高性能的操作系统、高性能的网页服务器、高性能的数据库、高性能的编程语言等。

LAMP框架包括:

1. Linux操作系统

2. Apache网络服务器

3. MySQL数据库

4. Perl、PHP或者Python编程语言

LAMP具有Web资源丰富、轻量、快速开发、通用、跨平台、高性能、低价格等优势,正是由于LAMP在性能、价格、质量等上的绝对优势,因此很多企业搭建网站均首选LAMP网站架构。

------------------------------

下面开始搭建LAMP之旅!

------------------------------

安装前提

本文的实验是基于CentOS6.5 X64版本操作系统,并且安装的时候,选择软件包的时候,已经将开发工具包组选择并安装上。

安装依赖包

1. 将系统配置好网络(以保证能够联通外网)

[root@localhost ~]ping www.baidu.com

2. 实验如下命令进行安装
        [root@localhost ~]yum install wget gcc gcc-c++ make re2c curl curl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel zlib zlib-devel openssl openssl-devel freetype freetype-devel gd gd-devel perl perl-devel ncurses ncurses-devel bison bison-devel libtool gettext gettext-devel cmake bzip2 bzip2-devel pcre pcre-devel

编译安装Httpd软件
    1. 解压软件包
        [root@localhost ~]tar zxvf apr-1.5.0.tar.gz 
        [root@localhost ~]tar zxvf apr-util-1.5.3.tar.gz 
        [root@localhost ~]tar zxvf httpd-2.4.7.tar.gz

2. 移动并改名
        [root@localhost ~]mv apr-1.5.0 httpd-2.4.7/srclib/apr
        [root@localhost ~]mv apr-util-1.5.3 httpd-2.4.7/srclib/apr-util

3. 进入httpd并执行configure命令
        [root@localhost ~]cd httpd-2.4.7
        [root@localhost ~]./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --with-z --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support --enable-authn-dbm=shared --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-mods-shared=all --enable-ssl --enable-cgi
 
    4. 执行make && make install进行编译及安装
        [root@localhost ~]make && make install

5. 编辑httpd.conf
        [root@localhost ~]vi /etc/httpd/httpd.conf
            将ServerName www.example.com:80改成 ServerName localhost:80

6. 新建apache用户
        [root@localhost ~]useradd apache -M -s /sbin/nologin
            将User daemon 改为 User daemon
            将Group daemon 改为 Group daemon
 
    7. iptables添加80端口并重启服务

[root@localhost ~]iptables -F

[root@localhost ~]service iptables save

[root@localhost ~]vi /etc/sysconfig/iptables
            -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
        [root@localhost ~]service iptables restart

8. 创建apache启动脚本并赋予权限
        [root@localhost ~]vi /etc/init.d/httpd
            #!/bin/bash
            #
            # httpd Startup script for the Apache HTTP Server
            #
            # chkconfig: 2345 85 15    
            # description: The Apache HTTP Server is an efficient and extensible \
            #     server implementing the current HTTP standards.
            # processname: httpd
            # config: /etc/httpd/httpd.conf
            # config: /etc/sysconfig/httpd
            # pidfile: /var/run/httpd/httpd.pid
            #
            ### BEGIN INIT INFO
            # Provides: httpd
            # Required-Start: $local_fs $remote_fs $network $named
            # Required-Stop: $local_fs $remote_fs $network
            # Should-Start: distcache
            # Short-Description: start and stop Apache HTTP Server
            # Description: The Apache HTTP Server is an extensible server 
            # implementing the current HTTP standards.
            ### END INIT INFO
         
            # Source function library.
            . /etc/rc.d/init.d/functions
         
            if [ -f /etc/sysconfig/httpd ]; then
                . /etc/sysconfig/httpd
            fi
     
            # Start httpd in the C locale by default.
            HTTPD_LANG=${HTTPD_LANG-"C"}
         
            # This will prevent initlog from swallowing up a pass-phrase prompt if
            # mod_ssl needs a pass-phrase from the user.
            INITLOG_ARGS=""
         
            # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
            # with the thread-based "worker" MPM; BE WARNED that some modules may not
            # work correctly with a thread-based MPM; notably PHP will refuse to start.
         
            # Path to the apachectl script, server binary, and short-form for messages.
            apachectl=/usr/local/apache/bin/apachectl
            httpd=${HTTPD-/usr/local/apache/bin/httpd}
            prog=httpd
            pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}
            lockfile=${LOCKFILE-/var/lock/subsys/httpd}
            RETVAL=0
            STOP_TIMEOUT=${STOP_TIMEOUT-10}
         
            # The semantics of these two functions differ from the way apachectl does
            # things -- attempting to start while running is a failure, and shutdown
            # when not running is also a failure. So we just do it the way init scripts
            # are expected to behave here.
            start() {
                echo -n $"Starting $prog: "
                LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
                RETVAL=$?
                echo
                [ $RETVAL = 0 ] && touch ${lockfile}
                return $RETVAL
            }
         
            # When stopping httpd, a delay (of default 10 second) is required
            # before SIGKILLing the httpd parent; this gives enough time for the
            # httpd parent to SIGKILL any errant children.
            stop() {
                 echo -n $"Stopping $prog: "
                 killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
                 RETVAL=$?
                 echo
                 [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
            }
            reload() {
                echo -n $"Reloading $prog: "
                if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
                    RETVAL=6
                    echo $"not reloading due to configuration syntax error"
                    failure $"not reloading $httpd due to configuration syntax error"
                else
                    # Force LSB behaviour from killproc
                    LSB=1 killproc -p ${pidfile} $httpd -HUP
                    RETVAL=$?
                    if [ $RETVAL -eq 7 ]; then
                        failure $"httpd shutdown"
                    fi
                fi
                echo
            }
         
            # See how we were called.
            case "$1" in
                  start)
                 start
             ;;
              stop)
                 stop
             ;;
              status)
                status -p ${pidfile} $httpd
             RETVAL=$?
             ;;
              restart)
                 stop
                 start
             ;;
              condrestart|try-restart)
                 if status -p ${pidfile} $httpd >&/dev/null; then
                      stop
                      start
                 fi
             ;;
              force-reload|reload)
                reload
             ;;
              graceful|help|configtest|fullstatus)
                 $apachectl $@
                 RETVAL=$?
             ;;
              *)
                 echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-    reload|reload|status|fullstatus|graceful|help|configtest}"
                 RETVAL=2
            esac
         
            exit $RETVAL
        [root@localhost ~]chmod 755 /etc/init.d/httpd

9. 设置环境变量
        [root@localhost ~]vi /etc/profile
            PATH=/usr/local/apache/bin:$PATH
            export PATH
        [root@localhost ~]source /etc/profile
 
    10. 启动httpd 并配置为开机启动
        [root@localhost ~]service httpd start
        [root@localhost ~]chkconfig httpd on

编译安装mysql

1. 解压mysql
        [root@localhost ~]tar zxvf mysql-5.6.16.tar.gz
 
    2. 进入mysql目录并执行cmake
        [root@localhost ~]cd mysql-5.6.16
        [root@localhost ~]cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all    -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
 
    3. 编译安装mysql5.6
        [root@localhost ~]make && make install

4. 新建一个mysql用户
        [root@localhost ~]useradd -s /sbin/nologin -M mysql
 
    5. 新建一个数据目录并给定权限
        [root@localhost ~]mkdir -p /data/mysql

[root@localhost ~]mkdir -p /var/lib/mysql
        [root@localhost ~]chown -R mysql:mysql /usr/local/mysql

[root@localhost ~]chown -R mysql:mysql /usr/local/mysql

[root@localhost ~]chown -R mysql:mysql /var/lib/mysql
 
    6. 初始化数据库
        [root@localhost ~]cd /usr/local/mysql/scripts/
        [root@localhost ~]./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql
 
    7. 在CentOS6.5系统默认安装时,在/etc目录下会存在一个my.cnf,将此文件改名为/etc/my.cnf.org,并配置特定的my.cnf
        [root@localhost ~]mv /etc/my.cnf /etc/my.cnf.old
        [root@localhost ~]cp /usr/local/mysql/my.cnf /etc/
 
    8. 复制启动脚本到/etc/init.d    
        [root@localhost ~]cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
 
    9. iptables添加3306端口
        [root@localhost ~]vi /etc/sysconfig/iptables
            -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
        [root@localhost ~]service iptables restart

10. 设置环境变量
        [root@localhost ~]vi /etc/profile
            PATH=/usr/local/mysql/bin:$PATH
            export PATH
        [root@localhost ~]source /etc/profile

11. 启动mysql并设置开机启动
        [root@localhost ~]service mysqld start
        [root@localhost ~]chkconfig mysqld on

12. 初始化mysql的一些设置
        [root@localhost ~]mysql_secure_installation [回车]
        Enter current password for root (enter for none): [回车]
        Set root password? [Y/n] y
        Remove anonymous users? [Y/n] y
        Disallow root login remotely? [Y/n] y
        Remove test database and access to it? [Y/n] y
        Reload privilege tables now? [Y/n] y
 
        Thanks for using MySQL!

编译安装php
    1. 解压php
        [root@localhost ~]tar zxvf php-5.4.25.tar.gz
 
    2. 进入php目录并执行configure
        [root@localhost ~]cd php-5.4.25
        [root@localhost ~]./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql --with-mysqli --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gd --with-zlib-dir --with-mcrypt --enable-soap --enable-mbstring=all --enable-sockets --enable-ftp --enable-zip --with-gettext --without-pear 
 
    3. 编译安装php5.4
        [root@localhost ~]make && make install
 
    4. 设置环境变量
        [root@localhost ~]vi /etc/profile
            PATH=/usr/local/php/bin:$PATH
            export PATH
        [root@localhost ~]source /etc/profile
 
    5. 复制配置文件到etc目录并进行修改
        [root@localhost ~]cp /usr/src/php-5.4.25/php.ini-production /etc/php.ini
        [root@localhost ~]vi /etc/php.ini
            date.timezone =Asia/Shanghai
 
    6. 配置httpd支持php解析
        [root@localhost ~]vi /etc/httpd/httpd.conf
            在AddType application/x-gzip .gz .tgz处增加AddType application/x-httpd-php .php 
            将DirectoryIndex index.html  改为  DirectoryIndex index.html index.php
 
    7. 验证
        添加一个测试文件到/usr/local/apache/htdocs/phpinfo.php,看看httpd能否输出php页面

本文出自 “Keyman” 博客,请务必保留此出处http://keyman.blog.51cto.com/9807984/1676386

CentOS6.5下编译安装LAMP环境

标签:lamp centos

原文:http://keyman.blog.51cto.com/9807984/1676386

CentOS6.5下编译安装LAMP环境的更多相关文章

  1. centos6.7下编译安装lamp环境

    编译C源代码: 前提:提供开发工具及开发环境 通过“包组”提供开发组件,CentOS 6: "Development Tools", "Server Platform D ...

  2. Centos6.8下编译安装LAMP的操作记录梳理

    之前用的最多的web框架是LNMP,偶尔也会用到LAMP.接下来简单说下LAMP环境的部署记录,这里选择源码安装的方式: LAMP相关安装包下载地址:https://pan.baidu.com/s/1 ...

  3. 【Linux】Centos6.8下一键安装Lamp环境

    [下载地址] 以下三种都是快捷安装环境的工具,都提供相应的脚本,原理都相同,一个会了其他的也就都会了,我用的比较多的会是lnmp和oneinstack,最近在用的都是oneinstack,挺好用的. ...

  4. centos6.7下编译安装lnmp

    很多步骤不说明了,请参照本人的centos6.7下编译安装lamp,这次的架构是nginx+php-fpm一台服务器,mysql一台服务器 (1)首先编译安装nginx: 操作命令: yum -y g ...

  5. centos6.7下 编译安装MySQL5.7

    centos6.7下编译安装MySQL5.7 准备工作 #-----依赖包及MySQL和boost安装包----- #yum包安装: shell> yum -y install gcc-c++ ...

  6. Linux(CentOS6.5)下编译安装PHP5.6.22时报错”configure: error: ZLIB extension requires gzgets in zlib”的解决方式(确定已经编译安装Zlib,并已经指定Zlib路径)

    本文地址http://comexchan.cnblogs.com/,作者Comex Chan,尊重知识产权,转载请注明出处,谢谢!   今天在CentOS6.5下编译安装PHP时,一直报错 confi ...

  7. CentOS6.5_64bit下编译安装MySQL-5.6.23

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/44785511 ************************************** ...

  8. CentOS6.5下 yum安装LAMP

    CentOS下yum安装LAMP   1. 用yum安装Apache,Mysql,PHP. 1.1安装Apache yum install httpd httpd-devel 安装完成后,用/etc/ ...

  9. CentOS 6.3编译安装LAMP环境笔记

    转载地址:http://www.jb51.net/article/54969.htm 最近抽空在虚拟机上测试成功了LAMP各个最新版本的整合编译安装,算是把之前的博文整合精简,以下内容均在CENTOS ...

随机推荐

  1. bzoj 5277: [Usaco2018 Open]Out of Sorts【冒泡排序瞎搞】

    首先考虑快排的递归什么时候停下,显然是当前段只剩下一个数了,也就是一个数两边出现分隔符 然后再考虑计算冒泡长度这个操作,因为有分割,所以我们可以把这些放到一起冒泡,这和递归每个区间冒泡是等价的 所以答 ...

  2. bzoj 3875: [Ahoi2014&Jsoi2014]骑士游戏【dp+spfa】

    设f[i]为杀死i的最小代价,显然\( f[i]=min(k[i],s[i]+\sum f[to]) \) 但是这个东西有后效性,所以我们使用spfa来做,具体就是每更新一个f[i],就把能被它更新的 ...

  3. A - Supercentral Point CodeForces - 165A

    One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of point ...

  4. SSRS域账号下 User 'XXX' does not have required permissions的处理方法

    SSRS安装完成后,点击Report Manager URL,提示:User 'XXX' does not have required permissions. Verify that suffici ...

  5. Drawable(6)关于StateList的补充

    模板: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android=&quo ...

  6. ADO.net增删改的使用

    添加数据 -------------------------------------------------- //让用户输入要添加的内容 Console.WriteLine("请输入要添加 ...

  7. Android学习笔记(十四) Handler理论补充

    一.如何下载Android源码 在SDK Manager中选中Sources for Android SDK. 二.ThreadLocal初步介绍 1)执行ThreadLocal对象(static f ...

  8. 掌握Spark机器学习库-07-随机梯度下降

    1)何为随机梯度下降 优化方法 迭代更新,来寻找函数全局最优解的方法 与最小二乘法相比:适用于变量众多,模型更复杂 2)梯度 变化最快,“陡峭” 通过函数表达式来衡量梯度 3)随机梯度下降原理推导过程 ...

  9. 调度工具taskctl跨调度服务依赖实现

    调度工具taskctl虽然支持分布式调度,但是有的时候,不同重要程度的调度服务还是要区分开来,在区分开后,不同调度服务之间怎么实现依赖啦, 其实有很多方式,比如写文件,写数据库之类的,这些都可以根据用 ...

  10. 【PostgreSQL-9.6.3】进程及体系结构

    本文主要讲述了PG的几个主要进程,以及PG的核心架构.进程和体系结构详见下图: 从上面的体系结构图可以看出来,PG使用经典的C/S架构,进程架构.在服务器端有主进程.服务进程.子进程.共享内存以及文件 ...