• LNMP搭建随笔


    LNMP(即Linux+Nginx+MYSQL+PHP)是目前非常热门的动态网站部署架构,一般是指:

    lnmp架构图片

    Linux:如RHEL、Centos、Debian、Fedora、Ubuntu等系统。

    Nginx:高性能、低消耗的HTTP与反向代理服务程序。

    MYSQL:热门常用的数据库管理软件。

    PHP:一种能够在服务器端执行的嵌入HTML文档的脚本语言。

    通过将这四种开源软件部署在一起,便成为了一个免费、高效、扩展性强、资源消耗低的动态网站环境了。

    1. 下载软件和编译

      1.1 下载所有需要使用的软件包到/usr/local/src目录(17个文件):

    [root@larry ~]# cd /usr/local/src
    [root@larry src]# wget -i download.txt
    

      1.2. 安装编译工具及库文件(需要安装的程序比较多,请复制全!):

    [root@larry ~]# yum install -y apr* autoconf automake bison bzip2 bzip2* compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
    

      执行后效果如下:

    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    ………………省略部分安装过程………………
    Installing:
     apr                         x86_64       1.4.8-3.el7               rhel7       103 k
     apr-devel                   x86_64       1.4.8-3.el7               rhel7       188 k
     apr-util                    x86_64       1.5.2-6.el7               rhel7        92 k
     apr-util-devel              x86_64       1.5.2-6.el7               rhel7        76 k
     autoconf                    noarch       2.69-11.el7               rhel7       701 k
     automake                    noarch       1.13.4-3.el7              rhel7       679 k
     bison                       x86_64       2.7-4.el7                 rhel7       578 k
     bzip2-devel                 x86_64       1.0.6-12.el7              rhel7       218 k
     compat-dapl                 x86_64       1:1.2.19-3.el7            rhel7       109 k
     compat-db-headers           noarch       4.7.25-27.el7             rhel7        48 k
     compat-db47                 x86_64       4.7.25-27.el7             rhel7       795 k
     compat-gcc-44               x86_64       4.4.7-8.el7               rhel7        10 M
     compat-gcc-44-c++           x86_64       4.4.7-8.el7               rhel7       6.3 M
     compat-glibc                x86_64       1:2.12-4.el7              rhel7       1.2 M
     compat-glibc-headers        x86_64       1:2.12-4.el7              rhel7       452 k
     compat-libcap1              x86_64       1.10-7.el7                rhel7        19 k
     compat-libf2c-34            x86_64       3.4.6-32.el7              rhel7       155 k
     compat-libgfortran-41       x86_64       4.1.2-44.el7              rhel7       142 k
     compat-libtiff3             x86_64       3.9.4-11.el7              rhel7       135 k
     compat-openldap             x86_64       1:2.3.43-5.el7            rhel7       174 k
     cpp                         x86_64       4.8.2-16.el7              rhel7       5.9 M
     fontconfig-devel            x86_64       2.10.95-7.el7             rhel7       128 k
     freetype-devel              x86_64       2.4.11-9.el7              rhel7       355 k
     gcc                         x86_64       4.8.2-16.el7              rhel7        16 M
     gcc-c++                     x86_64       4.8.2-16.el7              rhel7       7.1 M
     gettext-devel               x86_64       0.18.2.1-4.el7            rhel7       315 k
     kernel-headers              x86_64       3.10.0-123.el7            rhel7       1.4 M
     keyutils-libs-devel         x86_64       1.5.8-3.el7               rhel7        37 k
     krb5-devel                  x86_64       1.11.3-49.el7             rhel7       611 k
     libXpm-devel                x86_64       3.5.10-5.1.el7            rhel7        36 k
     libcom_err-devel            x86_64       1.42.9-4.el7              rhel7        30 k
     libcurl-devel               x86_64       7.29.0-19.el7             rhel7       296 k
     libjpeg-turbo-devel         x86_64       1.2.90-5.el7              rhel7        99 k
     libpng-devel                x86_64       2:1.5.13-5.el7            rhel7       122 k
     libselinux-devel            x86_64       2.2.2-6.el7               rhel7       174 k
     libsepol-devel              x86_64       2.1.9-3.el7               rhel7        71 k
     libstdc++-devel             x86_64       4.8.2-16.el7              rhel7       1.5 M
     libtiff-devel               x86_64       4.0.3-14.el7              rhel7       471 k
     libtool                     x86_64       2.4.2-20.el7              rhel7       588 k
     libtool-ltdl-devel          x86_64       2.4.2-20.el7              rhel7       167 k
     libxml2-devel               x86_64       2.9.1-5.el7               rhel7       1.0 M
     mpfr                        x86_64       3.1.1-4.el7               rhel7       203 k
     nasm                        x86_64       2.10.07-7.el7             rhel7       402 k
     ncurses-devel               x86_64       5.9-13.20130511.el7       rhel7       713 k
     ncurses-term                noarch       5.9-13.20130511.el7       rhel7       543 k
     ntp                         x86_64       4.2.6p5-18.el7            rhel7       539 k
     openssl-devel               x86_64       1:1.0.1e-34.el7           rhel7       1.2 M
     patch                       x86_64       2.7.1-8.el7               rhel7       110 k
     pcre-devel                  x86_64       8.32-12.el7               rhel7       477 k
     php-common                  x86_64       5.4.16-21.el7             rhel7       559 k
     php-gd                      x86_64       5.4.16-21.el7             rhel7       122 k
     t1lib                       x86_64       5.1.2-14.el7              rhel7       166 k
     telnet                      x86_64       1:0.17-59.el7             rhel7        63 k
     zlib-devel                  x86_64       1.2.7-13.el7              rhel7        49 k
    Installing for dependencies:
     cyrus-sasl-devel            x86_64       2.1.26-17.el7             rhel7       309 k
     expat-devel                 x86_64       2.1.0-8.el7               rhel7        56 k
     gettext-common-devel        noarch       0.18.2.1-4.el7            rhel7       368 k
     git                         x86_64       1.8.3.1-4.el7             rhel7       4.3 M
     glibc-devel                 x86_64       2.17-55.el7               rhel7       1.0 M
     glibc-headers               x86_64       2.17-55.el7               rhel7       650 k
     libX11-devel                x86_64       1.6.0-2.1.el7             rhel7       979 k
     libXau-devel                x86_64       1.0.8-2.1.el7             rhel7        14 k
     libdb-devel                 x86_64       5.3.21-17.el7             rhel7        38 k
     libmpc                      x86_64       1.0.1-3.el7               rhel7        51 k
     libverto-devel              x86_64       0.2.5-4.el7               rhel7        12 k
     libxcb-devel                x86_64       1.9-5.el7                 rhel7       1.0 M
     libzip                      x86_64       0.10.1-8.el7              rhel7        49 k
     m4                          x86_64       1.4.16-9.el7              rhel7       256 k
     openldap-devel              x86_64       2.4.39-3.el7              rhel7       796 k
     perl-Data-Dumper            x86_64       2.145-3.el7               rhel7        47 k
     perl-Error                  noarch       1:0.17020-2.el7           rhel7        32 k
     perl-Git                    noarch       1.8.3.1-4.el7             rhel7        52 k
     perl-TermReadKey            x86_64       2.30-20.el7               rhel7        31 k
     perl-Test-Harness           noarch       3.28-2.el7                rhel7       302 k
     perl-Thread-Queue           noarch       3.02-2.el7                rhel7        17 k
     xorg-x11-proto-devel        noarch       7.7-8.el7.1               rhel7       281 k
     xz-devel                    x86_64       5.1.2-8alpha.el7          rhel7        44 k
    ………………省略部分安装过程………………
    Complete!
    

       1.3. 安装cmake编译工具(解压与编译过程已省略): 

    [root@larry ~]# cd /usr/local/src
    [root@larry src]# ls
    zlib-1.2.8.tar.gz       libmcrypt-2.5.8.tar.gz  pcre-8.35.tar.gz
    cmake-2.8.11.2.tar.gz   libpng-1.6.12.tar.gz    php-5.5.14.tar.gz
    Discuz_X3.2_SC_GBK.zip  libvpx-v1.3.0.tar.bz2   t1lib-5.1.2.tar.gz
    freetype-2.5.3.tar.gz   mysql-5.6.19.tar.gz     tiff-4.0.3.tar.gz
    jpegsrc.v9a.tar.gz      nginx-1.6.0.tar.gz      yasm-1.2.0.tar.gz
    libgd-2.1.0.tar.gz      openssl-1.0.1h.tar.gz
    [root@larry src]# tar xzvf cmake-2.8.11.2.tar.gz
    [root@larry src]# cd cmake-2.8.11.2/
    [root@larry cmake-2.8.11.2]# ./configure
    [root@larry cmake-2.8.11.2]# make 
    [root@larry cmake-2.8.11.2]# make install
    

    2. 配置Mysql服务

      2.1. 创建用于执行mysql服务程序的帐号:

    [root@larry cmake-2.8.11.2]# cd ..
    [root@larry src]# useradd mysql -s /sbin/nologin
    

      2.2. 创建数据库程序和文件的目录,并设置目录的所属与所组:

    [root@larry src]# mkdir -p /usr/local/mysql/var
    [root@larry src]# chown -Rf mysql:mysql /usr/local/mysql
    

      2.3. 安装Mysql服务程序(解压与编译过程已省略,大约需要30分钟):

    [root@larry src]# tar xzvf mysql-5.6.19.tar.gz
    [root@larry src]# cd mysql-5.6.19/
    [root@larry mysql-5.6.19]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/var -DSYSCONFDIR=/etc
    [root@larry mysql-5.6.19]# make
    [root@larry mysql-5.6.19]# make install
    

      2.4. 删除系统默认的配置文件:

    [root@larry mysql-5.6.19]# rm -rf /etc/my.cnf
    

      2.5. 生成系统数据库(生成信息已省略,大约需要15分钟):

    [root@larry mysql-5.6.19]# cd /usr/local/mysql
    [root@larry mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var
    

      2.6. 创建配置文件的软连接文件:

    [root@larry mysql]# ln -s my.cnf /etc/my.cnf 
    

      2.7. 将mysqld服务程序添加到开机启动项:

    [root@larry mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
    [root@larry mysql]# chmod 755 /etc/init.d/mysqld
    [root@larry mysql]# chkconfig mysqld on
    

      2.8. 编辑启动项的配置文件:

    [root@larry mysql]# vi /etc/rc.d/init.d/mysqld 
    //分别修改第46与47行,basedir为程序安装路径,datadir为数据库存放目录。
    basedir=/usr/local/mysql
    datadir=/usr/local/mysql/var
    

      2.9. 重启mysqld服务程序:

    [root@larry mysql]# service mysqld start
    Starting MySQL. SUCCESS! 
    

      2.10. 把mysql服务程序命令目录添加到环境变量中(永久生效):

    [root@larry mysql]# vi /etc/profile
    //在配置文件的最下面追加:
    export PATH=$PATH:/usr/local/mysql/bin
    [root@larry mysql]# source /etc/profile
    

      2.11. 将mysqld服务程序的库文件链接到默认的位置:

    [root@larry mysql]# mkdir /var/lib/mysql
    [root@larry mysql]# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
    [root@larry mysql]# ln -s /usr/local/mysql/include/mysql /usr/include/mysql
    [root@larry mysql]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
    

      2.12. 初始化mysqld服务程序:

    [root@larry mysql]# mysql_secure_installation 
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    In order to log into MySQL to secure it, we'll need the current
    password for the root user.  If you've just installed MySQL, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.
    Enter current password for root (enter for none): 
    OK, successfully used password, moving on...
    Setting the root password ensures that nobody can log into the MySQL
    root user without the proper authorisation.
    Set root password? [Y/n] y  
    New password: 输入要为root用户设置的数据库密码。
    Re-enter new password: 重复再输入一次密码。
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    By default, a MySQL installation has an anonymous user, allowing anyone
    to log into MySQL without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    Remove anonymous users? [Y/n] y(删除匿名帐号)
     ... Success!
    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.
    Disallow root login remotely? [Y/n] y(禁止root用户从远程登陆)
     ... Success!
    By default, MySQL comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    Remove test database and access to it? [Y/n] y(删除test数据库并取消对其的访问权限)
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!
    
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    Reload privilege tables now? [Y/n] y(刷新授权表,让初始化后的设定立即生效)
     ... Success!
    All done!  If you've completed all of the above steps, your MySQL
    installation should now be secure.
    Thanks for using MySQL!
    Cleaning up...
    

    3. 配置Nginx服务 

    Nginx是一款相当优秀的用于部署动态网站的服务程序,Nginx最初是为俄罗斯门户站点而设计的网站服务软件,作为作为一款轻量级的网站服务软件,因其稳定性和丰富的功能而深受信赖,但最最最被认可的是低系统资源、占用内存少并发能力强,目前国内如新浪、网易、腾讯等门户站均在使用,市场占有份额一直保持在15-16%左右(2015年最新数据)。
    Nginx与Apache
    Nginx程序的稳定性来自于它采用了分阶段的资源分配技术,使得CPU与内存占用率会非常低,所以使用Nginx程序部署动态网站环境不仅十分的稳定、高效,而且消耗更少的系统资源,丰富的模块功能也几乎与Apache程序数量相同,现在已经完全的支持了proxy、rewrite、mod_fcgi、ssl、vhosts等常用模块。而且还支持了热部署技术,即能够可以7*24不间断提供服务,即便运行数月也无须重启,而且还可以在不暂停服务的情况下直接对Nginx服务程序进行升级。

    坦白来讲,虽然Nginx程序的代码质量非常高,代码很规范,技术成熟,模块扩展也很容易,但Nginx依然存在不少问题,比如Nginx是由俄罗斯人创建的,所以在资料文档方面还并不完善,中文教材的质量更是鱼龙混杂,但Nginx近年来增长势头迅猛,预测未来应该能够在轻量级HTTP服务器市场有不错的未来。

      3.1. 安装PCRE(Perl兼容的正则表达式库,解压与编译过程已省略):

    [root@larry ~]# cd /usr/local/src
    [root@larry src]# mkdir /usr/local/pcre
    [root@larry src]# tar xzvf pcre-8.35.tar.gz 
    [root@larry src]# cd pcre-8.35
    [root@larry pcre-8.35]# ./configure --prefix=/usr/local/pcre
    [root@larry pcre-8.35]# make
    [root@larry pcre-8.35]# make install 
    

      3.2. 安装openssl服务程序(解压与编译过程已省略): 

    [root@larry pcre-8.35]# cd /usr/local/src
    [root@larry src]# mkdir /usr/local/openssl
    [root@larry src]# tar xzvf openssl-1.0.1h.tar.gz
    [root@larry src]# cd openssl-1.0.1h
    [root@larry openssl-1.0.1h]# ./config --prefix=/usr/local/openssl
    [root@larry openssl-1.0.1h]# make
    [root@larry openssl-1.0.1h]# make install 
    

      3.3. 把openssl服务程序命令目录添加到环境变量中(永久生效):

    [root@larry pcre-8.35]# vi /etc/profile
    //将配置文件最下面的参数追加参数为:
    export PATH=$PATH:/usr/local/mysql/bin:/usr/local/openssl/bin
    [root@larry pcre-8.35]# source /etc/profile
    

      3.4. 安装zlib数据压缩函数库(解压与编译过程已省略):

    [root@larry pcre-8.35]# cd /usr/local/src
    [root@larry src]# mkdir /usr/local/zlib
    [root@larry src]# tar xzvf zlib-1.2.8.tar.gz 
    [root@larry src]# cd zlib-1.2.8
    [root@larry zlib-1.2.8]# ./configure --prefix=/usr/local/zlib
    [root@larry zlib-1.2.8]# make
    [root@larry zlib-1.2.8]# make install
    

      3.5. 创建用于执行nginx服务的用户:

    [root@larry zlib-1.2.8]# cd ..
    [root@larry src]# useradd www -s /sbin/nologin
    

      3.6. 安装nginx服务程序(openssl,zlib,pcre要写成源码解压路径!!!):

    [root@larry src]# tar xzvf nginx-1.6.0.tar.gz 
    [root@larry src]# cd nginx-1.6.0/
    [root@larry nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35
    [root@larry nginx-1.6.0]# make
    [root@larry nginx-1.6.0]# make install
    

      3.7. 创建nginx程序脚本(将下面的参数直接复制进去即可):

    [root@larry nginx-1.6.0]# vi /etc/rc.d/init.d/nginx
    
    #!/bin/bash
    # nginx - this script starts and stops the nginx daemon
    # chkconfig: - 85 15
    # description: Nginx is an HTTP(S) server, HTTP(S) reverse 
    # proxy and IMAP/POP3 proxy server
    # processname: nginx
    # config: /etc/nginx/nginx.conf
    # config: /usr/local/nginx/conf/nginx.conf
    # pidfile: /usr/local/nginx/logs/nginx.pid
    # Source function library.
    . /etc/rc.d/init.d/functions
    # Source networking configuration.
    . /etc/sysconfig/network
    # Check that networking is up.
    [ "$NETWORKING" = "no" ] && exit 0
    nginx="/usr/local/nginx/sbin/nginx"
    prog=$(basename $nginx)
    NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
    [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
    lockfile=/var/lock/subsys/nginx
    make_dirs() {
    # make required directories
    user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=([^ ]*).*/1/g' -`
            if [ -z "`grep $user /etc/passwd`" ]; then
                    useradd -M -s /bin/nologin $user
            fi
    options=`$nginx -V 2>&1 | grep 'configure arguments:'`
    for opt in $options; do
            if [ `echo $opt | grep '.*-temp-path'` ]; then
                    value=`echo $opt | cut -d "=" -f 2`
                    if [ ! -d "$value" ]; then
                            # echo "creating" $value
                            mkdir -p $value && chown -R $user $value
                    fi
            fi
    done
    }
    start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
    }
    stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
    }
    restart() {
    #configtest || return $?
    stop
    sleep 1
    start
    }
    reload() {
    #configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
    }
    force_reload() {
    restart
    }
    configtest() {
    $nginx -t -c $NGINX_CONF_FILE
    }
    rh_status() {
    status $prog
    }
    rh_status_q() {
    rh_status >/dev/null 2>&1
    }
    case "$1" in
    start)
            rh_status_q && exit 0
            $1
            ;;
    stop)
            rh_status_q || exit 0
            $1
            ;;
    restart|configtest)
    $1
    ;;
    reload)
            rh_status_q || exit 7
            $1
            ;;
    force-reload)
            force_reload
            ;;
    status)
            rh_status
            ;;
    condrestart|try-restart)
            rh_status_q || exit 0
            ;;
    *)
    echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
    exit 2
    esac
    更改nginx文件的权限为755
    [root@larry nginx-1.6.0]# chmod 755 /etc/rc.d/init.d/nginx

      3.8. 重启nginx服务程序并添加到开机启动项:

    [root@larry nginx-1.6.0]# /etc/rc.d/init.d/nginx restart
    Stopping nginx:                                            [FAILED]
    Starting nginx:                                            [  OK  ]
    [root@larry nginx-1.6.0]# chkconfig nginx on
    

      3.9. 此时可以通过访问IP来判断nginx服务是否顺利运行:

    尝试访问网页

    4. 配置php服务

      4.1. 安装yasm汇编器(解压与编译过程已省略):

    [root@larry nginx-1.6.0]# cd /usr/local/src
    [root@larry src]# tar zxvf yasm-1.2.0.tar.gz
    [root@larry src]# cd yasm-1.2.0
    [root@larry yasm-1.2.0]# ./configure
    [root@larry yasm-1.2.0]# make
    [root@larry yasm-1.2.0]# make install
    

      

    安装yasm汇编器(解压与编译过程已省略):

    [root@linuxprobe nginx-1.6.0]# cd /usr/local/src
    [root@linuxprobe src]# tar zxvf yasm-1.2.0.tar.gz
    [root@linuxprobe src]# cd yasm-1.2.0
    [root@linuxprobe yasm-1.2.0]# ./configure
    [root@linuxprobe yasm-1.2.0]# make
    [root@linuxprobe yasm-1.2.0]# make install
    

    安装libmcrypt加密算法扩展库(解压与编译过程已省略):

    [root@linuxprobe yasm-1.2.0]# cd /usr/local/src
    [root@linuxprobe src]# tar zxvf libmcrypt-2.5.8.tar.gz
    [root@linuxprobe src]# cd libmcrypt-2.5.8
    [root@linuxprobe libmcrypt-2.5.8]# ./configure
    [root@linuxprobe libmcrypt-2.5.8]# make
    [root@linuxprobe libmcrypt-2.5.8]# make install
    

    安装libvpx视频编码器(解压与编译过程已省略):

    [root@linuxprobe libmcrypt-2.5.8]# cd /usr/local/src
    [root@linuxprobe src]# tar xjvf libvpx-v1.3.0.tar.bz2
    [root@linuxprobe src]# cd libvpx-v1.3.0
    [root@linuxprobe libvpx-v1.3.0]# ./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
    [root@linuxprobe libvpx-v1.3.0]# make
    [root@linuxprobe libvpx-v1.3.0]# make install
    

    安装Tiff标签图像文件格式(解压与编译过程已省略):

    [root@linuxprobe libvpx-v1.3.0]# cd /usr/local/src
    [root@linuxprobe src]# tar zxvf tiff-4.0.3.tar.gz
    [root@linuxprobe src]# cd tiff-4.0.3
    [root@linuxprobe tiff-4.0.3]# ./configure --prefix=/usr/local/tiff --enable-shared
    [root@linuxprobe tiff-4.0.3]# make
    [root@linuxprobe tiff-4.0.3]# make install
    

    安装libpng图片(png格式)函数库(解压与编译过程已省略):

    [root@linuxprobe tiff-4.0.3]# cd /usr/local/src
    [root@linuxprobe src]# tar zxvf libpng-1.6.12.tar.gz
    [root@linuxprobe src]# cd libpng-1.6.12
    [root@linuxprobe libpng-1.6.12]# ./configure --prefix=/usr/local/libpng --enable-shared
    [root@linuxprobe libpng-1.6.12]# make
    [root@linuxprobe libpng-1.6.12]# make install
    

    安装freetype字体引擎(解压与编译过程已省略):

    [root@linuxprobe libpng-1.6.12]# cd /usr/local/src
    [root@linuxprobe src]# tar zxvf freetype-2.5.3.tar.gz
    [root@linuxprobe src]# cd freetype-2.5.3
    [root@linuxprobe freetype-2.5.3]# ./configure --prefix=/usr/local/freetype --enable-shared
    [root@linuxprobe freetype-2.5.3]# make
    [root@linuxprobe freetype-2.5.3]# make install
    

    安装jpeg图片(jpeg格式)函数库(解压与编译过程已省略):

    [root@linuxprobe freetype-2.5.3]# cd /usr/local/src
    [root@linuxprobe src]# tar zxvf jpegsrc.v9a.tar.gz
    [root@linuxprobe src]# cd jpeg-9a
    [root@linuxprobe jpeg-9a]# ./configure --prefix=/usr/local/jpeg --enable-shared
    [root@linuxprobe jpeg-9a]# make
    [root@linuxprobe jpeg-9a]# make install
    

    安装libgd图像处理程序(解压与编译过程已省略):

    [root@linuxprobe jpeg-9a]# cd /usr/local/src
    [root@linuxprobe src]# tar zxvf libgd-2.1.0.tar.gz
    [root@linuxprobe src]# cd libgd-2.1.0
    [root@linuxprobe libgd-2.1.0]# ./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx
    [root@linuxprobe libgd-2.1.0]# make
    [root@linuxprobe libgd-2.1.0]# make install
    

    安装t1lib图片生成函数库(解压与编译过程已省略):

    [root@linuxprobe cd libgd-2.1.0]# cd /usr/local/src
    [root@linuxprobe src]# tar zxvf t1lib-5.1.2.tar.gz
    [root@linuxprobe src]# cd t1lib-5.1.2
    [root@linuxprobe t1lib-5.1.2]# ./configure --prefix=/usr/local/t1lib --enable-shared
    [root@linuxprobe t1lib-5.1.2]# make
    [root@linuxprobe t1lib-5.1.2]# make install
    

    将函数库文件放至合适的位置:

    [root@linuxprobe t1lib-5.1.2]# cd /usr/local/src
    [root@linuxprobe src]# ln -s /usr/lib64/libltdl.so /usr/lib/libltdl.so
    [root@linuxprobe src]# cp -frp /usr/lib64/libXpm.so* /usr/lib/
    

    安装php服务程序(命令比较长,请一定要复制完整!!!):

    [root@linuxprobe src]# tar -zvxf php-5.5.14.tar.gz
    [root@linuxprobe src]# cd php-5.5.14
    [root@linuxprobe php-5.5.14]# export LD_LIBRARY_PATH=/usr/local/libgd/lib
    [root@linuxprobe php-5.5.14]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype
    [root@linuxprobe php-5.5.14]# make
    [root@linuxprobe php-5.5.14]# make install
    

    复制php服务程序的配置文件到安装目录:

    [root@linuxprobe php-5.5.14]# cp php.ini-production /usr/local/php/etc/php.ini
    

    删除默认的php配置文件:

    [root@linuxprobe php-5.5.14]# rm -rf /etc/php.ini
    

    创建php配置文件的软连接到/etc/目录中:

    [root@linuxprobe php-5.5.14]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    [root@linuxprobe php-5.5.14]# ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf
    [root@linuxprobe php-5.5.14]# ln -s /usr/local/php/etc/php.ini /etc/php.ini

    编辑php服务程序的配置文件:

    [root@linuxprobe php-5.5.14]# vim /usr/local/php/etc/php-fpm.conf
    //将第25行参数前面的分号去掉。
    pid = run/php-fpm.pid
    //修改第148和149行,将user与group修改为www。
    user = www
    group = www
    

    添加php-fpm服务程序到开机启动项:

    [root@linuxprobe php-5.5.14]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
    [root@linuxprobe php-5.5.14]# chmod +x /etc/rc.d/init.d/php-fpm
    [root@linuxprobe php-5.5.14]# chkconfig php-fpm on
    

    为了保障网站的安全性,禁用掉不安全的功能:

    [root@linuxprobe php-5.5.14]# vim /usr/local/php/etc/php.ini
    //修改第305行的disable_functions参数,追加参数为:
    disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
    

    配置nginx服务程序支持php:

    [root@linuxprobe php-5.5.14]# vim /usr/local/nginx/conf/nginx.conf
    //将第2行前面的#号去掉并修改为user www www ;
    //将第45行参数修改为index index.html index.htm index.php;
    //将第65-71行前面的#号去掉,修改为:
    location ~ .php$ {
      root           html;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include        fastcgi_params;
      }
    

    重启nginx与php-fpm服务程序:

    [root@linuxprobe php-5.5.14]# systemctl restart nginx
    [root@linuxprobe php-5.5.14]# systemctl restart php-fpm

     

     

     

     




  • 相关阅读:
    js学习(4) 函数
    Js学习(3) 数组
    NGUI的UILabel
    unity模型部分替换
    工作流程
    unity 资源内存管理
    unity 跑酷demo
    unity动画相关
    unity之C#回调函数
    maya导入unity
  • 原文地址:https://www.cnblogs.com/huolarry/p/5555257.html
Copyright © 2020-2023  润新知