码迷,mamicode.com
首页 > 系统相关 > 详细

【Linux】LAMP环境搭建(简易版)

时间:2017-05-11 00:18:55      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:sam   server   浏览器   2.4   http   libxml2   php.ini   授权   efault   

一. 辅助软件包安装

准备工作:1.Linux系统准备  恢复快照(初始化安装)   设置IP   关闭SELINUX  配置yum源
         2.yum -y install gcc gcc-c++
         3.关闭防火墙
         4.复制源码包 解压缩
         vim tar.sh    
        cd /lamp
        /bin/ls *.tar.gz > ls.list
            for TAR in `cat ls.list`
        do
        /bin/tar -zxf $TAR
        done
        /bin/rm ls.list

        chmod 777 tar.sh
        ./tar.sh

        5.空间是否足够
        df -h 

    安装libxml2
    yum -y install python-devel         必须安装

    cd /lamp/libxml2-2.9.1
    ./configure --prefix=/usr/local/libxml2/
    make 
    make install

    安装libmcrypt
    cd /lamp/libmcrypt-2.5.8
    ./configure --prefix=/usr/local/libmcrypt/
    make 
    make install

    安装libltdl
    cd /lamp/libmcrypt-2.5.8/libltdl
    ./configure --enable-ltdl-install
    make
    make install


    安装mhash 
    cd /lamp/mhash-0.9.9.9
    ./configure 
    make
    make install

    安装mcrypt
    cd /lamp/mcrypt-2.6.8
    LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib      ./configure --with-libmcrypt-prefix=/usr/local/libmcrypt
    make  
    make install

    安装zlib
    cd /lamp/zlib-1.2.3         
    ./configure
    make
    make install 

    安装libpng
    cd /lamp/libpng-1.2.31
    ./configure --prefix=/usr/local/libpng
    make
    make install

    安装jpeg6
    mkdir /usr/local/jpeg6  
    mkdir /usr/local/jpeg6/bin
    mkdir /usr/local/jpeg6/lib
    mkdir /usr/local/jpeg6/include
    mkdir -p /usr/local/jpeg6/man/man1

    cd /lamp/jpeg-6b
    ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
    make    
    make install

    安装freetype
    cd /lamp/freetype-2.3.5
    ./configure --prefix=/usr/local/freetype/
    make
    make install

二. Apache服务安装

    cp  -r  /lamp/apr-1.4.6  /lamp/httpd-2.4.7/srclib/apr
    cp  -r  /lamp/apr-util-1.4.1  /lamp/httpd-2.4.7/srclib/apr-util

    cd /lamp/pcre-8.34  
    ./configure && make && make install

     cd /lamp/httpd-2.4.7
    ./configure --prefix=/usr/local/apache2/ --sysconfdir=/usr/local/apache2/etc/ --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared
    make
    make install

    启动Apache测试:
    /usr/local/apache2/bin/apachectl start
    ps  aux | grep httpd
    netstat –tlun | grep :80

    浏览器测试 192.168.183.251    It works!

    开机自启动
    vim /etc/rc.local
    /usr/local/apache2/bin/apachectl start

三. MySQL服务安装

    安装ncurses
    yum -y install ncurses-devel

    安装cmake bison 
    yum -y install cmake  bison

    安装MySQL
    1. groupadd mysql
       useradd -g  mysql mysql

      cd /lamp/mysql-5.5.48
      cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql    -DMYSQL_UNIX_ADDR=/tmp/mysql.sock  -DEXTRA_CHARSETS=all   -DDEFAULT_CHARSET=utf8    -DDEFAULT_COLLATION=utf8_general_ci    -DWITH_MYISAM_STORAGE_ENGINE=1   -DWITH_INNOBASE_STORAGE_ENGINE=1    -DWITH_MEMORY_STORAGE_ENGINE=1  -DWITH_READLINE=1    -DENABLED_LOCAL_INFILE=1   -DMYSQL_USER=mysql  -DMYSQL_TCP_PORT=3306

      make  && make install

    2.初始化数据库系统表  修改配置文件  二次授权
    cd /usr/local/mysql/
    chown -R mysql .
    chgrp -R mysql .

    /usr/local/mysql/scripts/mysql_install_db --user=mysql

    chown -R root .
    chown -R mysql data


    cp support-files/my-medium.cnf /etc/my.cnf

    二次授权
    /usr/local/mysql/scripts/mysql_install_db --user=mysql

    3. 启动服务  初始化密码  开机自启动

    /usr/local/mysql/bin/mysqld_safe --user=mysql &

    vim /etc/rc.local
    /usr/local/mysql/bin/mysqld_safe --user=mysql &

    /usr/local/mysql/bin/mysqladmin -uroot password 123456

    /usr/local/mysql/bin/mysql -u root -p     登录 

四. PHP软件安装

    yum -y install "libtool*"

    cd /lamp/php-7.0.7
    ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs  --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-mcrypt=/usr/local/libmcrypt/   --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets  --with-pdo-mysql=/usr/local/mysql --with-gd   --without-pear

    make  && make install

    生成php.ini
    mkdir /usr/local/php/etc/
    cp /lamp/php-7.0.7/php.ini-production /usr/local/php/etc/php.ini  

    vim /usr/local/apache2/etc/httpd.conf
    AddType application/x-httpd-php .php .phtml 
    AddType application/x-httpd-php-source .phps

    重启Apache服务:/usr/local/apache2/bin/apachectl stop
              /usr/local/apache2/bin/apachectl start

    测试:vim /usr/local/apache2/htdocs/test.php    
    <?php       phpinfo();   ?>

    192.168.183.251/test.php

###五. 收尾 软件安装 环境变量

    环境变量
    vim /etc/profile
    export PATH="/usr/local/mysql/bin:$PATH"
    export PATH="/usr/local/apache2/bin:$PATH"
    export PATH="/usr/local/php/bin:$PATH"


    source  /etc/profile


    安装openssl

    yum -y install openssl-devel   必须安装
    cd /lamp/php-7.0.7/ext/openssl
    mv config0.m4 config.m4                否则报错:找不到config.m4
    /usr/local/php/bin/phpize 
    ./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config 
    make
    make install

    vim /usr/local/php/etc/php.ini
    extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20151012/"

    extension="openssl.so";

    /usr/local/apache2/bin/apachectl stop
    /usr/local/apache2/bin/apachectl start

    安装phpMyAdmin

    cp -r /lamp/phpMyAdmin-4.1.4-all-languages /usr/local/apache2/htdocs/phpmyadmin
    cd /usr/local/apache2/htdocs/phpmyadmin
    cp config.sample.inc.php config.inc.php
    vim config.inc.php
    $cfg[‘Servers‘][$i][‘auth_type‘] = ‘http‘;

    测试 192.168.183.251/phpmyadmin/index.php


    项目迁移:  1.源码迁移  
               2.数据库迁移 
               3.修改配置 
               4.测试

【Linux】LAMP环境搭建(简易版)

标签:sam   server   浏览器   2.4   http   libxml2   php.ini   授权   efault   

原文地址:http://www.cnblogs.com/peilanluo/p/6838803.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!