天天看点

LAMP编译安装

运行ntsysv,开启以下服务:atd crond irqbalance microcode_ctl network sendmail sshd syslog

关闭SElinux 修改 /etc/selinux/config 文件中的 SELINUX= 为 disabled

更换163,sohu下载源

     mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.old

     cd /etc/yum.repos.d/   wget wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

     mv CentOS6-Base-163.repo CentOS-Base.repo  yum clean all   yum -y update 

      定时校正服务器时钟,定时与中国国家授时中心授时服务器同步

     crontab -e */30 * * * * ntpdate cn.pool.ntp.org > /dev/null 2>&1 

安装依赖包

<code>rpm -ivh  http://mirrors.ustc.edu.cn/epel/6Server/x86_64/epel-release-6-8.noarch.rpm # epel-release注意对应本身系统版本</code>

yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libtiff-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel fontconfig-devel zlib zlib-devel libevent-devel gcc gcc-c++ flex bison bzip2 bzip2-devel libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel 

 mysq 5.6编译安装则依赖于 cmake ncurses-devel bison

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql_data -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

The server quit without updating PID file [失败]/mysql_data/centos6.6.pid)  

#cd /data/mysql_data                //数据库文件存放目录

#vi centos6.6.pid         //编辑此文件,添加一个pid号码

1583  

保存退出。           //1583是我在系统中随意添加的号,只要保证系统进程里没有的ID都可以

#service mysqld start      正常启动 

mysql下载地址:

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

1. mysql安装

   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 

   cd /usr/local/mysql 

   mkdir -p /data/mysql 

   chown -R mysql:mysql /data/mysql 

   ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql 

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

   cp support-files/mysql.server /etc/init.d/mysqld

   chmod 755 /etc/init.d/mysqld 

   vim /etc/init.d/mysqld   #修改datadir

   chkconfig --add mysqld 

   chkconfig mysqld on 

   service mysqld start  

2. 安装apache

    apache下载地址:http://mirrors.sohu.com/apache/httpd-2.4.16.tar.gz ;

    wget  http://mirrors.sohu.com/apache/httpd-2.4.16.tar.gz 

    apr   http://apache.fayea.com//apr/apr-1.5.2.tar.gz

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

    pcre  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz

   下载apr apr-util 并tar 到httpd-2.4.16/srclib/ 

    tar zvxf httpd-2.4.16.tar.gz  

    cd httpd-2.4.16

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

apache2 -l 静态模块 -M动态模块 graceful 重新加载配置文件 

工作模式:

 ./configure --with-mpm=MPM          

 Choose the process model for Apache to use.MPM={beos|event|worker|prefork|mpmt_os2}

 apache 2.2默认为prefork模式,2.4为event模式                                    

3.  安装php

     php下载地址:http://mirrors.sohu.com/php/php-5.6.11.tar.gz ;

     wget http://mirrors.sohu.com/php/php-5.6.11.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 &amp;&amp; make install 

当mysql和php不在同一台机器上时,需要将php与mysql的关联改为

4. 配置apache结合php

       vim /usr/local/apache2/conf/httpd.conf 找到: AddType application/x-gzip .gz .tgz

       在该行下面添加: AddType application/x-httpd-php .php

       找到:

       &lt;IfModule dir_module&gt;

       DirectoryIndex index.html

       &lt;/IfModule&gt;

       将该行改为:

       DirectoryIndex index.html index.htm index.php

       找到:#ServerName www.example.com:80 修改为:ServerName localhost:80

5. 测试解析php

     vim /usr/local/apache2/htdocs/1.php

     写入:

             &lt;?php

             echo "php解析正常";

             ?&gt;

    保存后,继续测试  curl localhost/1.php

6.apache加入chkconfig

     cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

     vim /etc/init.d/httpd   

     在第一行#!/bin/sh下增加两行文字

     # chkconfig: 35 70 30

     # description: Apache

     保存退出

     chkconfig --level 35 httpd on    

7.MySQL加入到系统服务里面 

      cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld

      #把mysql的脚本文件拷到系统的启动目录下

      cd /etc/init.d/

      chkconfig --add mysqld #将mysql加到启动服务列表中

      chkconfig mysqld on #将系统启动时自动打开mysq服务

      Apache加到启动项里面:

  echo '/usr/local/apache2/bin/apachectl start ' &gt;&gt; /etc/rc.local