zoukankan      html  css  js  c++  java
  • LAMP

    一、下载MySQL


    1.查看自己Linux系统是多少位的,然后决定下载多少位的MySQL

    uname -i
    反馈:x86_64  64位 或者  i386  32位

    2.使用yum安装下载工具‘wget’

    yum install wget -y

    3.切换到指定的目录下,软件包下载到该目录下

    cd /usr/local/src/

    4.去MySQL官网下载MySQL,需注册,找到合适的版本

    http://dev.mysql.com/downloads/mysql/

    或者去搜狐的下载

    http://mirrors.sohu.com/

    64位下载软件包

    wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz

    32位下载软件包

    wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz

    下载

    wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.47-linux2.6-x86_64.tar.gz

    5.解压

    tar zxvf mysql-5.5.47-linux2.6-x86_64.tar.gz

    6.把解压好的MySQL放在MySQL目录下

    mv mysql-5.5.47-linux2.6-x86_64.tar.gz /usr/local/mysql

    7.创建MySQL用户,并不允许登录

    useradd -s /sbin/nologin mysql

    8.创建数据库文件存放的目录,并更改所有者和所属组。

    mkdir -p /data/mysql
    chown -R mysql:mysql !$

    二、安装MySQL

    1.切换到MySQL安装目录下,开始安装

    cd /usr/local/mysql
    ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

    --user定义数据库的所属主

    --datadir定义数据库的安装位置

    2.检查安装是否出错

    echo $?

    反馈0说明没有错误,反馈1说明报错。

    三、配置MySQL

    1.拷贝配置文件,并重命名。因为my.cnf文件已存在,直接覆盖就可以。

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

    2.拷贝启动脚本文件,修改启动脚本权限

    cp support-files/mysql.server /etc/init.d/mysqld
    chmod 755 !$

    3.修改启动脚本,(没有vim使用" yum install vim -y "来安装)

    vim /etc/init.d/mysqld

    需要把

    basedir=
    datadir=

    修改为

    basedir=/usr/local/mysql
    datadir=/data/mysql

    basedir定义MySQL的安装目录
    datadir定义MySQL数据库的文件存放目录

    4.加入系统服务,设置开机启动MySQL

    chkconfig --add mysqld
    chkconfig mysqld on

    5.启动MySQL

    service mysqld start

    6.检查MySQL是否启动

    ps aux |grep mysqld

     MySQL安装,配置,启动完成。                                                                                   

    一、下载Apache

    1.切换到下载目录

    cd /usr/local/src

    2.下载Apache,Apache的官网是:http://www.apache.org/

    Download - HTTP - 找到中国的镜像站.cn

    wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.18.tar.bz2

    3.解压缩

     tar -jvxf httpd-2.4.18.tar.bz2

    二、配置编译参数

    1.切换到httpd目录下

    cd httpd-2.4.18

    2.编译参数,非常全的参数介绍 http://blog.chinaunix.net/uid-20784749-id-1844507.html

    编译介绍: http://www.linuxidc.com/Linux/2015-04/116060.htm

    常用参数: http://www.cnblogs.com/xianglf/archive/2010/12/16/1908174.html

    ./configure 
    --prefix=/usr/local/apache2 
    --with-included-apr 
    --enable-so 
    --enable-deflate=shared 
    --enable-expires=shared 
    --enable-rewrite=shared 
    --with-pcre

    ./configure   编译安装

    --prefix  编译安装完成后生成一个目录,该软件所有的文件都会被复制到这个目录里面,为什么要指定这个目录呢?为了以后维护方便,如果不指定,文件会被复制到系统下各个目录,用prefix的另一个好处就是方便卸载和移植软件。把删除该目录,整个软件卸载的干干净净,移植只需要把这个目录拷贝到另一台机器即可。

    --with-included-apr  如果是开发者则使用此选项,利于连接apache的代码或者是调试apache,其消除了由于版本或者编译中跟APR或者APR-util代码产生的不匹配;

    --enable-so   让apache核心装载DSO

    --enable-deflate=shared  表示共享的方式编译压缩, apache开启gizp的压缩功能。网页压缩。扩展:http://blog.csdn.net/yybjroam05/article/details/7726516

    --enable-expires=shared  网站需要用到缓存功能,支持 HTTP 控制

    --enable-rewrite=shared  支持 URL 重写

    --with-pcre

    错误1

    configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

    apache-2.2与新出的apache-2.4安装不同的地方在于,2.4版的已经不自带apr库,所以在安装apache-2.4之前,需要下载apr。

    cd /usr/local/src/
    wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.2.tar.bz2

    wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.5.4.tar.bz2

    解压

    tar -jxvf apr-1.5.2.tar.bz2
    tar -jxvf apr-util-1.5.4.tar.bz2

    拷贝到指定目录下

     cp -rf apr-1.5.2 ./httpd-2.4.18/srclib/apr
    cp -rf apr-util-1.5.4 ./httpd-2.4.18/srclib/apr-util
    猜测可能是以前安装用过./configure 来直接安装导致安装文件已经不太“干净”
    解决方法:
    1、执行make clean后,重新编译安装。
    2、删除目录,重新解压安装包,进行编译安装,可解决上面的问题。

    重新执行 configure 命令。

    错误2

    checking for gcc... no
    checking for cc... no
    checking for cl.exe... no

    没有gcc编译器

    yum install gcc -y

    重新执行 configure 命令。

    错误3

    configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org

    配置:错误:pcre-config libpcre不见了。PCRE是必需的,可以从http://pcre.org

    yum -y install pcre-devel

    错误4

    checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

    检查是否启用mod_deflate……配置:错误:mod_deflate一直要求但是不能建立由于先决条件失败

    yum install  zlib-devel -y

    检查编译参数是否正确

    echo $?

    3.make && make install

    make
    echo $?
    make install
    echo $?

    Apeche编译安装、启动成功                                                                                            

    一、下载php

    1.切换到下载目录

     cd /usr/local/src/

    2.下载php,php的官网是:http://www.php.net/

    Downloads  -  Current Stable PHP  -  php-*.*.*.tar.*  -  China  - cn2.php.net 

    wget http://cn2.php.net/distributions/php-7.0.2.tar.gz

    3.解压缩

     tar zxf php-7.0.2.tar.gz

    二、配置编译

    1.切换到php目录下

    cd php-7.0.2

    2.编译参数

     编译来至(全)http://blog.csdn.net/godmatrix/article/details/5969558

     ./configure 
    --with-apr=/usr/local/apr 
    --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-mcrypt
    --with-openssl
    --enable-soap
    --enable-gd-native-ttf
    --enable-mbstring
    --enable-sockets
    --enable-exif
    --disable-ipv6
     
    去掉了
    --with-mcrypt 
    不知道会有什么影响



    ./configure
    配置,安装
    --with-apr=/usr/local/apr    
    指定apr代码的目录  
    --prefix=/usr/local/php     
    指定php安装目录.
    --with-apxs2=/usr/local/apache2/bin/apxs 
    让Apache服务器能够支持PHP。整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到 apache,要求 apache 要打开SO模块
    --with-config-file-path=/usr/local/php/etc  
    指定php.ini配置文件的位置

    --with-mysql=/usr/local/mysql
    MySQL安装的目录,对mysql的支持

    --with-libxml-dir
    打开对libxml2库的支持

    --with-gd
    打开对gd库的支持

    --with-jpeg-dir
    --with-png-dir
    打开对jpeg图片和png图片的支持

    --with-freetype-dir
    打开对freetype字体库的支持

    --with-iconv-dir
    打开对iconv函数库,种字符集间的转换

    --with-zlib-dir
    打开对zlib库的支持

    --with-bz2
    打开对bz2文件的支持

    --with-openssl
    打开openssl的支持,加密传输时用到的

    --with-mcrypt
    算法,mhash和mcrypt都是算法的扩展

    --enable-soap
    打开soap的支持

    --enable-gd-native-ttf
    支持True Type 字符串 函数库

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

    --enable-sockets
    打开sockets支持

    --enable-exif
    图片的元数据支持

    --disable-ipv6

    不支持ipv6

    错误1

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

    配置:错误:xml2-config不见了。请检查你的libxml2安装。

    检查有没有安装libxml2

     rpm -qa |grep  libxml2
    yum install libxml2 libxml2-devel -y

    错误2

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

    配置:错误:找不到OpenSSL的< evp.h >

    yum install openssl openssl-devel -y

    错误3

    Configure: error: Please reinstall the BZip2 distribution

    配置:错误:请重新安装BZip2分布

    yum install bzip2 bzip2-devel -y

    错误4

    Configure: error: libjpeg.(a|so) not found

    配置:错误:libjpeg。(还)没有找到

     yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y

    错误5

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

    配置:错误:mcrypt。没有找到。请重新安装libmcrypt。

     解决:

    搜索:libmcrypt-第一个-Download Source-libmcrypt-*.*.*.tar.gz

      安装epel-release源

     yum install epel-release

    yum install libmcrypt-devel

    继续./configure

    echo $?

    反馈0

    3.编译安装

    make
    echo $?
    make install
    echo $?

    4.拷贝PHP主配置文件

     cp php.ini-production /usr/local/etc/php.ini

    5.修改apache的配置文件

    vim /usr/local/apache2/conf/httpd.conf
    
    
    1.找到 #ServerName www.example.com:80
    改为
    ServerName localhost:80
    2.找到<IfModule dir_module>
        DirectoryIndex index.html 
    </IfModule>
    改为
    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
    
    3.找到AddType application/x-compress .Z
        AddType application/x-gzip .gz .tgz
    改为
    AddType application/x-compress .Z
        AddType application/x-gzip .gz .tgz
        AddType application/x-httpd-php .php
    
    4.找到
    <Directory />

    AllowOverride none
    Require all denied

    </Directory>

    改为

    <Directory />
    Options FollowSymLinks
    AllowOverride none
    Order deny,allow
    Allow from all
    </Directory>

    1.ServerName www.example.com:80    打开服务器占用80端口

    2.DirectoryIndex index.html index.php   目录索引支持php

    3. AddType application/x-httpd-php .php  应用类型支持php

    4.Allow from all  允许访问web内容目录

    6.检查配置文件是否错误

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

    7.启动apache服务

    /usr/local/apache2/bin/apachectl start

    8.查看进程

     ps aux |grep httpd

    9.浏览器访问IP 

    是否显示 it works!显示说明成功。如果没有显示

    10.关闭防火墙。

    永久关闭SElinux,重启生效。

     vim /etc/selinux/config
    找到
    SELINUX=enforcing
    改为
    SELINUX=disabled

    临时关闭

     setenforce 0

    getenforce  查看当前SElinux防火墙状态

     setenforce 0 是临时关闭

     setenforce 1 是临时打开

    enforcing - SELinux security policy is enforced.打开
    permissive - SELinux prints warnings instead of enforcing.打开不拦截
    disabled - No SELinux policy is loaded.关闭,默认

    也可以

    清空iptables规则  

     iptables -F 

    保存 

     service iptables save

    11.重启mysql apache

    service mysqld restart ; /usr/local/apache2/bin/apachectl restart

     12.测试解析php

    cd /usr/local/apache2/htdocs

    php主配置文件vim /usr/local/apache2/conf/httpd.conf指定的文档根目录的路径DocumentRoot"/usr/local/apache2/htdocs"

    vim 1.txt    随便写点东西
    http://192.168.1.116/1.txt
    vim 2.php
    <?php
    phpinfo();
    ?>
    http://192.168.1.116/2.php

    中间解析php失败,

    ./configure

    make clean

    ./configure

    成功

    扩展:

    1.修改真机DNS

    windows记事本打开,添加

    C:WindowsSystem32driversetcHOSTS
    1927168.1.116 www.wangshaojun.com www.denny.com www.qqq.com

    2.修改apache虚拟主机配置文件,先创建存放文档的根目录

    mkdir /data/www
    vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
    把最下面两段修改为
    <VirtualHost *:80>
        DocumentRoot "/data/www"
        ServerName www.wangshaojun.com
        ServerAlias www.denny.com
       # ErrorLog "logs/dummy-host.example.com-error_log"
       # CustomLog "logs/dummy-host.example.com-access_log" common
    </VirtualHost>
    
    
    
    <VirtualHost *:80>     虚拟主机配置  80端口
        DocumentRoot "/data/www"       指定文档根目录,把论坛安装在此目录下, servername访问则是访问论坛。
        ServerName www.wangshaojun.com       服务器名称
        ServerAlias www.denny.com            服务器别名
       # ErrorLog "logs/dummy-host.example.com-error_log"          错误日志
       # CustomLog "logs/dummy-host.example.com-access_log" common     访问日志           
    </VirtualHost>




  • 相关阅读:
    Reverses CodeForces
    Palindrome Partition CodeForces
    Victor and String HDU
    Harry and magic string HDU
    Interesting HDU
    I Love Palindrome String HDU
    Substring UVA
    小明系列故事――女友的考验 HDU
    Walk Through Squares HDU
    使用ionic来build安卓apk时,报CordovaError: Requirements check failed for JDK 1.8 or greater
  • 原文地址:https://www.cnblogs.com/wangshaojun/p/5104168.html
Copyright © 2011-2022 走看看