lamp源码安装

os: centos 6.3

httpd-2.4.3mysql-5.5.28 +  php-5.4.8

1. 安装那些,你懂的

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers cmake

2. mysql安装

tar zxvf mysql-5.5.28.tar.gz

cd mysql-5.5.28

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1  -DWITH_READLINE=1  -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data  -DMYSQL_USER=mysql  -DMYSQL_TCP_PORT=3306 

make && make install
//安装mysql默认的数据库  
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

cp support-files/my-medium.cnf /usr/local/mysql/my.cnf //copy配置文件  
chown -R mysql:mysql /usr/local/mysql //更改权限  

vim /usr/local/mysql/my.cnf  

//加上以下内容  
[mysqld]  
basedir = /usr/local/mysql  
datadir = /usr/local/mysql/data  
log-error = /usr/local/mysql/mysql_error.log  
pid-file = /usr/local/mysql/mysql.pid  
user = mysql  
tmpdir          = /tmp  
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start  //启动mysql

2. 安装apache

tar zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install
cd ../

tar  zxvf apr-util-1.5.1.tar.gz
cd apr-util-1.5.1
./configure --prefix=/usr/local/apr-util
make && make install
cd ../

tar zxvf httpd-2.4.3.tar.gz
cd httpd-2.4.3
./configure --prefix=/usr/local/httpd --enable-rewrite --enable-so --enable-cgi --enable-suexec --enable-ssl --enable-charset-lite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre

make && make install

3. 安装php

tar zxvf libmcrypt-2.5.7.tar.gz
cd  libmcrypt-2.5.7
./configure --prefix=/usr/local/libmcrypt
make && make install
cd ../

tar zxvf pcre-8.31.tar.gz
cd pcre-8.31
./configure --prefix=/usr/local/pcre
make && make install
cd ../


tar zxvf  php-5.4.8.tar.gz
cd  php-5.4.8
./configure --prefix=/usr/local/php --with-apache2=/usr/local/httpd --with-apxs2=/usr/local/httpd/bin/apxs --enable-fpm --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=/usr/local/libmcrypt --enable-soap --enable-mbstring

make && make install

cp php.ini-development  /usr/local/php/lib/php.ini

4. 修改httpd.conf

mkdir /var/www
chmod 755 /var/www

cp /usr/local/httpd/conf/httpd.conf /usr/local/httpd/conf/httpd.conf~

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

#LoadModule rewrite_module modules/mod_rewrite.so    //除去#

以下是目录权限设置
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    #AllowOverride none
    #Require all denied
</Directory>

DocumentRoot "/var/www/"
<Directory "/var/www">
 Options Indexes FollowSymLinks
 AllowOverride All
 Order deny,allow
 Deny from all
 Allow from all
</Directory>

增加 index.php
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>

修改
<Files ".ht*">
   #Require all denied
    Order allow,deny
    Deny from all
    Satisfy All
</Files>

增加
AddType application/x-httpd-php .php

基本OK了,建个php文件试试吧

<?php

phpinfo();

 

posted @ 2012-11-03 23:52  tywei  阅读(103)  评论(0)    收藏  举报