Linux自学笔记——手动编译安装LAMP

本文主要演示编译安装LAMP:

第一部分:httpd 2.4.9 + mariadb-5.5.46 + php-5.4.26编译安装过程:

一、   编译安装apache

1.      解决依赖关系

httpd-2.4.9需要教新版本的apr和apr-util,因此需要事先对其进行升级。升级方式有两种,一种是通过源代码编译安装,一种是直接升级rpm包。这里选择使用编译源代码的方式运行。

首先下载这三个包httpd-2.4.9,apr-1.5.0.tar.bz2,apr-util-1.5.3.tar.bz2

image.png

准备开发环境,安装Development Tools ,Server Platform Development;使用命令yum groupinstall,这里不多阐述;

            1)      编译安装apr-1.5.0.tar.bz2

a.       解压缩apr-1.5.0.tar.bz2:

image.png

b.      进入apr-1.5.0目录;

image.png

c.       依次执行以下命令;

# ./configure --prefix=/usr/local/apr            设置安装目录;

# make && make install                           编译及安装;

            2)      编译安装apr-util

a.       解压apr-util-1.5.3.tar.bz2,并进入解压后的apr-util-1.5.3目录;

image.png

b.      依次执行以下命令;

# ./configure --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr  

# make && make install

       附:apache官方对APR的介绍:

The mission of the Apache Portable Runtime (APR) project is to create and maintain software libraries that provide a predictable and consistent interface to underlying platform-specific implementations. The primary goal is to provide an API to which software developers may code and be assured of predictable if not identical behaviour regardless of the platform on which their software is built, relieving them of the need to code special-case conditions to work around or take advantage of platform-specific deficiencies or features.

        3)      Httpd-2.4.9编译过程也要依赖于pcre-devel软件包,需要事先安装。此软件为系统光盘自带,找到并安装即可;

            image.png

2.      编译安装httpd-2.4.9

首先下载httpd2.4.9到本地,然后执行如下的安装过程;

        1)      解压缩httpd-2.4.9.tar.bz2包并进入解压后的目录;

            image.png


        2)      依次执行以下命令;

            设置安装路径等选项:# ./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

            image.png

编译安装:#make && make install

补充:

a.       构建MPM为静态模块

        在全部平台中,MPM都可以构建为静态模块。在构建时选择一种MPM,链接到服务器中。如果要改变MPM,必须重新构建。为了使用指定的MPM,请在执行configure脚本时,使用参数--with-mpm=NAME。NAME时指定的MPM名称。编译完成后,,可以使用./httpd –l 来选择MPM。此命令会列出编译到服务器程序中的所有模块,包括MPM。

    b.      构建MPM为动态模块

        UNIX或类似平台中,MPM可以构建为动态模块,与其它动态模块一样在运行时加载。构建MPM为动态模块允许通过修改LoadModule指令来改变MPM,而不用重新构建服务器程序。在执行configure脚本时,使用--enable-mpms-shared选项即可启用此特性。当给出的参数为all时,所有此平台支持的MPM模块都会被安装。还可以在参数中给出模块列表。默认MPM,可以自动选择或者在执行configure脚本时通过--with-mpm选项来之指定,然后出现在生成的服务器配置文件中。编辑Loadmodule指令内容可以选择不同的MPM。

        3)      修改httpd的主配置文件,设置其pid路径;

            编辑/etc/httpd24/httpd.conf,添加如下行即可;

            PidFile “/var/run/httpd/httpd.pid”

            image.png

       4)      提供脚本配置文件/etc/rc.d/init.d/httpd24;

            修改相应为如下内容;

            image.png

            配置文件所有内容如下:

            #!/bin/bash

            #

            # httpd        Startup script for the Apache HTTP Server

            #

            # chkconfig: - 85 15

            # description: Apache is a World Wide Web server.  It is used to serve \

            #        HTML files and CGI.

            # processname: httpd

            # config: /etc/httpd/conf/httpd.conf

            # config: /etc/sysconfig/httpd

            # pidfile: /var/run/httpd.pid

             

            # 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-/var/run/httpd.pid}

            lockfile=${LOCKFILE-/var/lock/subsys/httpd}

            RETVAL=0

             

            start() {

                    echo -n $"Starting $prog: "

                    LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS

                    RETVAL=$?

                    echo

                    [ $RETVAL = 0 ] && touch ${lockfile}

                    return $RETVAL

            }

             

            stop() {

              echo -n $"Stopping $prog: "

              killproc -p ${pidfile} -d 10 $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=$?

                    echo $"not reloading due to configuration syntax error"

                    failure $"not reloading $httpd due to configuration syntax error"

                else

                    killproc -p ${pidfile} $httpd -HUP

                    RETVAL=$?

                fi

                echo

            }

             

            # See how we were called.

            case "$1" in

              start)

              start

              ;;

              stop)

              stop

              ;;

              status)

                    status -p ${pidfile} $httpd

              RETVAL=$?

              ;;

              restart)

              stop

              start

              ;;

              condrestart)

              if [ -f ${pidfile} ] ; then

                stop

                start

              fi

              ;;

              reload)

                    reload

              ;;

              graceful|help|configtest|fullstatus)

              $apachectl $@

              RETVAL=$?

              ;;

              *)

              echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"

              exit 1

            esac

             

            exit $RETVAL

       5)      为此脚本赋予权限;

            image.png

        6)      加入服务列表;

            image.png

       7)      测试;

            image.png

 

二、   安装mariadb-5.5.46

1.      准备数据存放的文件系统;

新建一个逻辑卷,并将其挂在至特定目录即可。这里建逻辑卷的过程不再阐述;

这里假设其逻辑卷挂载目录为/mydata,而后需要创建/mydata/data目录作为mysql数据的存放目录。

image.png

2.      新建用户以安全方式运行进程:

image.png

3.      安装并初始化mariadb-5.5.46

        1)      首先下载二进制mariadb安装包至本地,

            image.png

        2)      解压缩文件至/usr/local目录;

            image.png

        3)      创建软连接;

            image.png

        4)      进入mysql目录,修改目录内文件属主属组;

            image.png

        5)      运行脚本,生成元数据库;指明用户和数据库存放位置;

            image.png

4.      为mysql提供主配置文件;

        1)      复制文件;

            image.png


        2)      编辑配置文件/etc/my.cnf;

            image.png


5.      为mysql提供sysv服务脚本;

        1)      复制脚本文件;

            image.png

        2)      添加脚本文件执行权限;

            image.png

        3)      添加服务列表;

            image.png

        4)      测试使用mysql;

              image.png


    为了使用mysql的安装符合系统使用规范,并将其开发组件导出给系统使用,这里还需要执行如下步骤;

6.      输出mysql的man手册至man命令的查找路径;

编辑/etc/man.config,添加如下行;

image.png


7.      输出mysql头文件至系统头文件路径下/usr/include;可以通过简单的创建链接实现;

image.png


8.      输出mysql的库文件给系统查找路径;

image.png


9.      修改PATH环境变量,让系统可以直接使用mysql相关命令。

image.png


至此,mariadb全部安装完成;

 

三、   编译安装php-5.4.26

1.      解决依赖关系:

首先配置号yum源(系统安装及epel源)后执行如下命令

# yum -y groupinstall "Desktop Platform Development"

# yum -y install bzip2-devel libmcrypt-devel libxml2-devel

2.      编译安装php-5.4.26

        1)      下载源码至本地目录;

            image.png

        2)      解压缩文件并进入php-5.4.26目录;

          image.png

        3)      编译安装php,执行如下指令;

        # ./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

        image.png  

 

    各参数解释:

       --prefix=/usr/local/php 默认安装路径

--with-mysql=/usr/local/mysql 指明mysql安装路径,如果有特定路径就使用等号"="后面跟上路径,没有则省略等号"="

--with-openssl 使用OpenSSL

--with-mysqli=/usr/local/mysql/bin/mysql_config 定义mysqli接口

--enable-mbstring 支持多字节字符串支持

--with-freetype-dir 支持各种字体

--with-jpeg-dir 支持处理jpeg格式图片

--with-png-dir 支持处理png格式图片

--with-zlib 支持压缩库

--with-libxml-dir=/usr 支持处理xml文档

--enable-xml 支持xml

--enable-sockets 使php支持以sockets方式通信

--with-apxs2=/usr/local/apache/bin/apxs (关键)表示把php编译成Apache的模块

--with-mcrypt 支持加密解密库

--with-config-file-path=/etc 定义php配置文件(php.ini)放置路径

--with-config-file-scan-dir=/etc/php.d 其他配置文件查找路径

--with-bz2 支持bz2格式加密

--enable-maintainer-zts 仅针对mpm为event和worker的情况,编译成zts模块,如果是prefork则不需要

 

    说明:

        a.       这里为了支持apache的worker或event这两个MPM,编译时使用了--enable-maintainer-zts选项。

        b.      --with-config-file-path=/etc:指定配置文件php.ini地址;

        c.       –with-config-file-scan-dir=/etc/php.d:指定额外的ini文件目录;

        d.      如果使用php5.3以上版本,为了链接MYSQL数据库,可以指定mysqld,这样在本机就不需要先安装mysql或mysql开发包了。Mysqlnd从php5.3开始可用,可以编译时绑定到它(而不用具体的mysql客户端库绑定形成依赖),但从php5.4开始它就是默认设置了。

        #./configure --with-msyql=mysqlnd --with-pdo-mysql=mysqlnd --with-msyqli=msyqlnd

         4)      编译;

            #make && make install

         5)      为php提供配置文件;

            #cp php.ini-production /etc/php.ini

            image.png

            6)      编辑apache配置文件httpd.conf,以apache支持php

                #vim /etc/httpd24/httpd.conf

a.       添加以下两行;

    AddType application/x-httpd-php .php

    AddType application/x-httpd-php-source .phps

   image.png 

b.      定位至DirectoryIndex index.html

    修改为

        DirectoryIndex       index.php  index.html

    image.png

c.       编辑index.php

    image.png

            7)      测试;

               image.png 

 

四、     安装xcache,为php加速:

1.      压力测试,首先我们用ab命令访问在这台机器上部署的wordpress,进行压力测试,然后与安装xcache之后的压力测试做对比;

    image.png

2.      按如下步骤安装;

        1)      解压源码包等操作;

    image.png

        2)      编译安装;

        # ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config

        # make && make install

               安装结束时,会出现类似如下行:

               Build complete.

        Don't forget to run 'make test'.

        Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

3.      编辑php.ini,整合php和xcache:

        1)      首先将xcache提供的样例配置文件导入php.ini

            image.png


          说明:xcache.ini文件在xcache目录中;

        2)      接下来编辑/etc/php.d/xcache.ini,找到extension开头的行,修改为如下行:

            extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

            image.png


            Note:如果xcache.ini中有多条extension指令行,要确保此新增的行排在第一位;

        3)      再次访问压力测试;

          image.png

    可以发现,传输速率得到了很大的提升;

 

第二部分:配置apache-2.4.9以fpm方式的php-5.4.26

一、     apache、mysql的安装与前一部分相同;根据以上安装;

二、     编译安装php-5.4.26

1.      解决依赖关系

首先配置号yum源(系统安装及epel源)后执行如下命令

# yum -y groupinstall "Desktop Platform Development"

# yum -y install bzip2-devel libmcrypt-devel libxml2-devel

2.      编译安装php-5.4.26

        1)      下载源码至本地目录;

image.png  

        2)      解压缩文件并进入php-5.4.26目录;

          image.png 

        3)      编译安装php,执行如下指令;

        # ./configure --prefix=/usr/local/php5-fpm--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=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2

        4)      编译及安装;

        make && make install

3.      为php提供配置文件;

    #cp php.ini-production  /etc/php.ini

    image.png

4.      配置php-fpm;

        1)      为php-fpm提供SysV init脚本,将其添加至服务列表;

           image.png 

        2)      为php-fpm提供配置文件;

           image.png

        3)      编辑php-fpm配置文件;

            配置fpm的相关选项为你所需要的值,并启用pid文件;

            image.png

            启用pid文件:

            image.png

        4)      启动服务并测试;

          image.png  

5.      配置httpd,使apache支持php-fpm;

        1)      启动以下两个模块;

            image.png

        2)      添加文件类型;

            image.png

        3)      定位到DirectoryIndex  index.html,修改为以下;

            image.png

        4)      配置虚拟主机;

            image.png

    Note

    ProxyRequests Off:关闭正向代理

    ProxyPassMatch:把以.php结尾的文件请求发送到php-fpm进程,php-fpm至少需要知道运行的目录和URI,所以这里直接在fcgi://127.0.0.1:9000后指明了这两个参数,其它的参数的传递已经被mod_proxy_fcgi.so进行了封装,不需要手动指定。

6.      测试;

        1)      编辑index.php测试;

           image.png 

        2)      网页输入地址;

          image.png




本文转自 claude_liu 51CTO博客,原文链接:http://blog.51cto.com/claude666/2056707,如需转载请自行联系原作者

### 回答1: 《FPGA自学笔记——设计与验证》是一本关于FPGA设计和验证的入门教材。本书以VHDL和Verilog两种HDL语言为主要工具,通过实例讲解FPGA的基本概念、设计流程和验证方法。同时,本书还通过实例演示了如何使用Xilinx ISE和ModelSim这两个主流软件工具进行FPGA设计和验证。 本书的内容分为五个部分,分别是FPGA基础知识、FPGA设计流程、FPGA验证方法、FPGA性能优化以及FPGA应用实例。其中,FPGA基础知识部分介绍了FPGA的基本构成、组成部件以及通用数字电路设计知识;FPGA设计流程部分从设计输入、RTL设计、布局布线、实现生成等方面详细介绍了FPGA设计流程;FPGA验证方法部分主要介绍了功能验证和时序验证这两个方面的知识;FPGA性能优化部分介绍了FPGA的几种性能指标以及如何通过一定的优化方法提高FPGA性能;FPGA应用实例部分通过几个实例演示了如何应用FPGA进行数字电路设计。 本书的难度适中,适合初学者学习和参考,同时也可以作为FPGA初学者的参考书籍。本书涉及的知识点较为全面,可以为初学者提供一个全面的FPGA设计和验证入门指南。其内容易于理解,实例讲解深入浅出,对于想要学习FPGA设计和验证的人群来说是一本很好的参考书。 ### 回答2: 《FPGA自学笔记——设计与验证》PDF是一本很好的自学FPGA的书籍。这本书包含了FPGA基本概念、设计流程、Verilog HDL语言、开发工具、测试方法等多个主题,非常详尽地介绍了FPGA的基本知识和开发技巧。读这本书可以帮助我们更好地理解FPGA的原理和功能,从而更加熟练地掌握FPGA的设计和验证。 此外,这本书还提供了很多实例来帮助我们更好地理解FPGA的设计和验证。这些实例包含多种应用场景,例如数字逻辑、时序控制、通信等,能够帮助我们从不同角度学习FPGA的相关知识。而且,这本书还提供了实验指导,通过做实验来让我们更深入地理解FPGA的各种知识和技能。 总之,这本书《FPGA自学笔记——设计与验证》PDF是一本非常好的FPGA自学指南,通过阅读这本书,我们可以掌握FPGA基本知识和开发技能,更好地应用FPGA进行各种应用开发。我相信,读完这本书,你一定能够对FPGA有更深刻的认识,并且能够灵活运用FPGA进行各种应用开发。 ### 回答3: 《FPGA自学笔记——设计与验证》是一本以FPGA为研究对象的书籍。它详细介绍了FPGA的诸多特性和应用。该书主要分为两部分,第一部分介绍了FPGA的基本概念,并讲解了Verilog的语法和使用方法。第二部分是实践性较强的部分,通过编写案例代码进行实际操作。 该书着重强调了FPGA设计流程,通过案例演示了FPGA设计的全过程。该书还提供了大量的练习题和案例代码,读者可以通过反复练习和实际操作,逐渐掌握FPGA的设计和验证技能。 总体来说,《FPGA自学笔记——设计与验证》是一本非常实用的FPGA入门教材。它从基础知识入手,循序渐进地讲解了FPGA的各个方面。并且,该书重点讲解了如何运用Verilog语言进行FPGA设计,这对FPGA初学者来说是一个非常实用的指南。 如果你对FPGA领域感兴趣,且希望通过自学来掌握FPGA的基本操作和设计方法,那么《FPGA自学笔记——设计与验证》是一本非常值得推荐的书籍。  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值