LAMP平台搭建

以红冒企业版RHEL5为例,构建LAMP平台。测试主机192.168.1.1,并准备好相关软件编译安装:httpd-2.2.17.tar.gz、 mysql-5.1.55.tar.gz、libmcrypt-2.5.8.tar.gz、mhash-0.9.9.9.tar.gz、mcrypt-2.6.8.tar.gz、php-5.3.6.tar.gz、phpMyAdmin-3.3.10-all-languages.tar.gz等。

一、搭建httpd。
1编辑IP地址
vim /etc/sysconfig/network-scripts/ifcfg-eth0
2删除之前rpm包装的软件。
rpm -e httpd httpd-manual webalizer subversion mod_python mod_ssl mod_perl system-config-httpd php php-cli php-ldap php-common mysql dovecot –nodeps
3解包httpd到/usr/src/
tar zxf httpd-2.2.17.tar.gz -C /usr/src/
cd /usr/src/httpd-2.2.17/
编译安装,
./configure –prefix=/usr/local/httpd –enable-so –enable-rewrite –enable-charset-lite –enable-cgi
make && make install
开启服务
/usr/local/httpd/bin/apachectl start

二、搭建mysql

解压mysql到/usr/src/,如果之前用rpm包装过,一定要清除

 tar zxf mysql-5.1.55.tar.gz -C /usr/src/
 cd /usr/src/mysql-5.1.55/

编译安装mysql

 ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312 && make && make install

建立配置文件
cp support-files/my-medium.cnf /etc/my.cnf
初始化数据库
cd /usr/local/mysql/bin/
./mysql_install_db –user=mysql
chown -R root.mysql /usr/local/mysql/
chown -R mysql /usr/local/mysql/var/
优化执行路径、程序路径
ln -s /usr/local/mysql/bin/ /usr/local/bin/
ln -s /usr/local/mysql/lib/mysql/
/usr/bin/
ln -s /usr/local/mysql/include/mysql/* /usr/include/

添加系统服务
cd /usr/src/mysql-5.1.55/

cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod a+x /etc/rc.d/init.d/mysqld 

chkconfig –add mysqld

开启mysql服务并添加用户密码

/etc/init.d/mysqld start
mysqladmin -u root password '123456'

三、搭建PHP
1删除之前rpm包装的php
rpm –e php php-cli php-ldap php-common php-mysql –nodeps
2 安装扩展工具库
Libmcrypt:
tar zxf libmcrypt-2.5.8.tar.gz -C /usr/src/
cd /usr/src/libmcrypt-2.5.8/
./configure && make && make install
ln -s /usr/local/lib/libmcrypt.* /usr/lib/
mhash:
tar zxf mhash-0.9.9.9.tar.gz -C /usr/src/

  cd /usr/src/mhash-0.9.9.9/
  ./configure && make && make install
  ln -s /usr/local/lib/libmhash.* /usr/lib/

mcrypt:
tar zxf mcrypt-2.6.8.tar.gz -C /usr/src/

    cd /usr/src/mcrypt-2.6.8/
    ./configure && make && make install

3安装php
tar zxf php-5.3.6.tar.gz -C /usr/src/

 cd /usr/src/php-5.3.6/
 ./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php5 --enable-mbstring && make && make install

4php.ini配置调整,一般复制即可,不用修改
cp /usr/src/php-5.3.6/php.ini-development /usr/local/php5/php.ini

5配置http.conf
vim /usr/local/httpd/conf/httpd.conf
(在LoadModule php5_module modules/libphp5.so添加AddType application/x-httpd-php .php

LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php

(还要在DirectoryIndex添加index.php)

DirectoryIndex index.php index.html


重启httpd服务
/usr/local/httpd/bin/apachectl restart

6测试PHP页面

vim /usr/local/httpd/htdocs/test.php
$link=mysql_connect('localhost','root','123456');
if($link) echo " success!!!!“;
mysql_close();
phpinfo();
?>

7部署phpMyAdmin系统
tar zxf phpMyAdmin-3.3.10-all-languages.tar.gz
mv phpMyAdmin-3.3.10-all-languages phpmyadmin
(更改名字,否则在浏览器上打名字挺烦的)
mv phpmyadmin /usr/local/httpd/htdocs/phpmyadmin
(复制到存放网页的目录)
若在页面中测试,见如下图,则说明链接数据库成功以及phpadmin部署成功!!

在此输入图片描述
在此输入图片描述
end

你可能感兴趣的:(LAMP平台搭建)