天天看點

LAMP配置

                        LAMP環境的配置方法一、環境

Centos 5

Apache 2.2

Mysql 5.1

PHP 5.2

二、Apache2.2的安裝

1.解壓Apache安裝包

[root@cent5]#tar zxvf httpd-2.2.21.tar.gz

2.配置Apache

[root@cent5]#cd httpd-2.2.21

[root@cent5 httpd-2.2.21]#useradd apache

[root@cent5 httpd-2.2.21]#groupadd apache

[root@cent5 httpd-2.2.21]#usermod -G apache apache

[root@cent5 httpd-2.2.21]# ./configure --prefix=/opt/httpd/ --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite --enable-ssl --enable-mods-shared=all  ---進行編譯

[root@cent5 httpd-2.2.21]#make && make install  ---安裝

[root@cent5]#/opt/httpd/bin/apachectl start ---啟動Apache服務

打開浏覽器輸入http://ip位址,如果出現“It works!"則安裝成功。

三、Mysql5.1的安裝

1.解壓Mysql5.1的安裝包

[root@cent5]#tar zxvf mysql-5.1.63.tar.gz

2.配置Mysql

[root@cent5]#groupadd mysql

[root@cent5]#useradd -s /sbin/nologin -g mysql -M mysql

[root@cent5 mysql-5.1.63]#./configure --prefix=/opt/mysql --with-unix-socket-path=/opt/mysql/tmp/mysql.sock --localstatedir=/opt/mysql/data --enable-assembler --enable-thread-safe-client --with-mysqld-user=mysql --with-big-tables --without-debug --with-pthread --enable-assembler --with-extra-charsets=complex --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase --with-plugin-PLUGIN --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static

正确的結果:

Thank you for choosing MySQL!

Remember to check the platform specific part of the reference manual

for hints about installing MySQL on your platform.

Also have a look at the files in the Docs directory.

[root@cent5 mysql-5.1.63]#make && make install

[root@cent5 mysql-5.1.63]#/bin/cp support-files/my-small.cnf /etc/my.cnf

[root@cent5 mysql-5.1.63]#mkdir -p /opt/mysql/data

[root@cent5 mysql-5.1.63]#/opt/mysql/bin/mysql_install_db --user=mysql

正确結果:

Installing MySQL system tables...

120514 21:55:04 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.

OK

Filling help tables...

[root@cent5 mysql-5.1.63]# chgrp -R mysql /opt/mysql/

[root@cent5 mysql-5.1.63]# cp support-files/mysql.server /etc/init.d/mysqld

[root@cent5 mysql-5.1.63]# chmod 700 /etc/init.d/mysqld 

[root@cent5 mysql-5.1.63]# /etc/init.d/mysqld restart

[root@cent5 mysql-5.1.63]# echo 'export PATH=$PATH:/opt/mysql/bin' >>/etc/profile

[root@cent5 mysql-5.1.63]# source /etc/profile

[root@cent5 mysql-5.1.63]#mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.63 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit

Bye

三、PHP的安裝

PHP的安裝一定要在Apache的安裝目錄内。

1.解壓libiconv-1.10.tar.tar

[root@cent5]#tar zxf libiconv-1.10.tar.tar

2.安裝libiconv 

 [root@cent5 libiconv-1.10]#./configure --prefix=/usr/local/libiconv

 [root@cent5 libiconv-1.10]#make && make install

3.解壓php-5.2.6.tar.gz

[root@cent5]#tar zxf php-5.2.6.tar.gz

4.檢查PHP所需要的安裝包

 [root@cent5]#rpm

-qa zlib libxml libjpeg freetype libpng gd 

curl libiconv  zlib-devel

libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel

5.如果沒有安裝用如下指令進行安裝

[root@cent5]#yum install  zlib libxml libjpeg freetype libpng gd  curl libiconv  zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel

6.安裝PHP

[root@cent5 php-5.2.6]# ./configure --prefix=/opt/httpd/php5.2.6 --with-apxs2=/opt/httpd/bin/apxs --with-mysql=/opt/mysql --with-ttf --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd  --with-jpeg-dir --with-png-dir --with-iconv=/usr/local/libiconv --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap --enable-mbstring --enable-static --enable-gd-native-ttf --with-curl

Thank you for using PHP.

[root@cent5 php-5.2.6]#make && make install

[root@cent5 php-5.2.6]#cp php.ini-dist /opt/httpd/php5.2.6/etc/php.ini

四、修改Apache配置檔案

1.将#ServerName

127.0.0.1:80的“#”去掉。

2.增加如下内容:

    AddType

application/x-httpd-php .php .php3

    AddType

application/x-httpd-php-source .phps

3.修改damon使用者為apache

  User

apache   

  Group

apache

4.測試檔案内容,儲存為.php的格式

<?

phpinfo ()

?>

5.找到:

   <IfModule dir_module>

       DirectoryIndex index.html

   </IfModule>

   将該行改為

        DirectoryIndex index.html index.htm index.php

上一篇: Python yield
下一篇: LAMP(源碼)

繼續閱讀