zoukankan      html  css  js  c++  java
  • LAMP第一部分-环境搭建

    安装lamp环境,第一步先安装mysql,因为后面的apache,php有些选项需要mysql作为依赖

    1. 安装mysql
    cd /usr/local/src/
    wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz(mysql已经编译好的包)
    注意:上面的地址是32位机器用的,如果你的机器是64位,下载这个包(http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-x86_64-icc-glibc23.tar.gz)安装方法是一样的。
    tar zxvf /usr/local/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
    mv mysql-5.1.40-linux-i686-icc-glibc23 /usr/local/mysql
    useradd -s /sbin/nologin mysql                #在linux系统下添加系统用户mysql,且不允许登录
    cd /usr/local/mysql
    mkdir -p /data/mysql                              # 创建mysql的存放数据的目录,(这将作为以后mysql的根目录)
    chown -R mysql:mysql /data/mysql        #  修改mysql根目录所属主和所属组
    ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql      #mysql初始化,通过脚本创建mysql数据库用户
    cp support-files/my-large.cnf /etc/my.cnf                                     #复制mysql安装下提供的配置到/etc目录下,并改名为my.cnf
    cp support-files/mysql.server /etc/init.d/mysqld                           # 把mysql服务mysqld添加到系统服务列表中,之后可以通过service mysqld start 启动
    chmod 755 /etc/init.d/mysqld
    vim /etc/init.d/mysqld   #修改datadir      # 修改mysqld 的根目录为datadir=/data/mysql
    chkconfig --add mysqld
    chkconfig mysqld on
    service mysqld start

     

     

    2. 安装apache
    wget  http://archive.apache.org/dist/httpd/httpd-2.2.27.tar.bz2
    tar jvxf httpd-2.2.27.tar.bz2 
    cd httpd-2.2.27
    ./configure --prefix=/usr/local/apache2  --enable-mods-shared=most  --enable-so             #指定安装路径,且apache模块工作模式为共享模式

    如果这一步你出现了这样的错误:

    error: mod_deflate has been requested but can not be built due to prerequisite failures
    

    解决办法是:

    yum install -y zlib-devel
    

    为了避免在make的时候出现错误,所以最好是提前先安装好一些库文件:

    yum install -y pcre pcre-devel apr apr-devel
    


    make && make install

    启动apache之前先检验配置文件是否正确:

    /usr/local/apache2/bin/apachectl -t
    

     

    3.  安装php
    wget http://cn2.php.net/distributions/php-5.3.28.tar.gz
    tar zxf php-5.3.28.tar.gz
    cd php-5.3.28
    ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6
    make && make install

    报错:

    configure: error: xml2-config not found. Please check your libxml2 installation.
    

    解决办法是:

    yum install -y libxml2-devel
    

    还有错误:

    configure: error: Cannot find OpenSSL's <evp.h>
    

    解决办法是:

    yum install -y openssl openssl-devel
    

    错误:

    checking for BZip2 in default path... not found
    configure: error: Please reinstall the BZip2 distribution
    

    解决办法:

    yum install -y bzip2 bzip2-devel
    

    错误:

    configure: error: png.h not found.
    

    解决办法:

    yum install -y libpng libpng-devel
    

    错误:

    configure: error: freetype.h not found.
    

    解决办法:

    yum install -y freetype freetype-devel
    

    错误:

    configure: error: mcrypt.h not found. Please reinstall libmcrypt.
    

    解决办法:

    rpm -ivh "http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"
    yum install -y  libmcrypt-devel
    

    因为centos6.x 默认的yum源没有libmcrypt-devel 这个包,只能借助第三方yum源。

    编译:

    4. 配置apache结合php
    vim /usr/local/apache2/conf/httpd.conf找到:
    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
    </Directory>
    改为:
    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Allow from all
    </Directory>                                           #访问控制

    找到:
    AddType application/x-gzip .gz .tgz
    在该行下面添加:
    AddType application/x-httpd-php .php      #添加解析php应用
    找到:
    <IfModule dir_module>
        DirectoryIndex index.html
    </IfModule>
    将该行改为:
    <IfModule dir_module>
        DirectoryIndex index.html index.htm index.php    #允许访问php 文件
    </IfModule>
    找到:
    #ServerName www.example.com:80
    修改为:
    ServerName localhost:80

     

     

    5. 测试解析php
    vim /usr/local/apache2/htdocs/1.php
    写入:
    <?php
        echo "php解析正常";
    ?>
    保存后,继续测试:
    curl localhost/1.php

  • 相关阅读:
    暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)
    暑假集训(1)第八弹 -----简单迷宫(Poj3984)
    暑假集训(1)第七弹 -----Oil Deposits(Poj1562)
    暑假集训(1)第六弹 -----简单计算器(Hdoj1237)
    暑假集训(1)第五弹 -----Rails(Uva514)
    暑假集训(1)第四弹 -----Find a way(Hdu2612)
    暑假集训(1)第三弹 -----Dungeon Master(Poj2251)
    暑假集训(1)第二弹 -----Catch the cow(Poj3278)
    EF框架搭建(一)
    领域驱动有感<上>
  • 原文地址:https://www.cnblogs.com/the-study-of-linux/p/5212699.html
Copyright © 2011-2022 走看看