天天看點

Centos 6.5下的LAMP環境搭建

安裝步驟:

必須先安裝apache或者mysql,之後才能安裝php

1. 安裝mysql

cd /usr/local/src/

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

注意:上面的位址是32位機器用的,如果你的機器是64位,下載下傳這個包

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

tar zxvf/usr/local/src/mysql-5.1.72-linux-x86_64-glibc23.tar.gz

mv mysql-5.1.72-linux-x86_64-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

         {basedir=/usr/local/mysql

         {datadir=/data/mysql

chkconfig --add mysqld

chkconfig mysqld on

service mysqld start

2. 安裝apache

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

tar jvxf httpd-2.2.31.tar.bz2 

cd httpd-2.2.31

./configure \

--prefix=/usr/local/apache2 \

--with-included-apr \

--enable-so \

--enable-deflate=shared \

--enable-expires=shared \

--enable-rewrite=shared \

--with-pcre

make && make install

注:重新開機不了?

         出現:httpd:couldnot reliably detemire the server's fally qualified domain name

         解決:vim/usr/local/apache2/conf/httpd.conf

         将#ServerNamelocalhost:80前的#去掉即可。

3.  安裝php

wget http://mirrors.sohu.com/php/php-5.4.35.tar.gz

tar zxf php-5.4.35.tar.gz

cd php-5.4.35

 ./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

 注:出現錯誤大多為依賴包沒有安裝,隻許yum裝上依賴包即可

   若出現:configure:error: mcrypt.h not found. Please reinstall libmcrypt.

   則需要:1、rpm -ivh "http://www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm"(centos6系列64位)

           rpm -ivh "http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm "(32位)        

       2、yum install -y  libmcrypt-devel

make&& make install

Apache與php之間的連接配接(php解析)

vim/usr/local/apache2/conf/httpd.conf

     1、找到AddTypeapplication/x-gzip .gz .tgz

       在其後面添加AddTypeapplication/x-httpd-php .php

    2、找到<IfModule dir_module>

              DirectoryIndex index.html

          </IfModule>

       改為<IfModule dir_module>

          DirectoryIndex index.html index.htm index.php

本文轉自 sykmiao 51CTO部落格,原文連結:http://blog.51cto.com/syklinux/1728883,如需轉載請自行聯系原作者