天天看點

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