34fw 发表于 2015-1-14 08:55:06

构建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 --nodeps3解包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-cgimake && 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'


三、搭建PHP1删除之前rpm包装的phprpm –e php php-cli php-ldap php-common php-mysql –nodeps2 安装扩展工具库Libmcrypt:tar zxf libmcrypt-2.5.8.tar.gz -C /usr/src/cd /usr/src/libmcrypt-2.5.8/./configure && make && make installln -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 install3安装phptar 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.confvim /usr/local/httpd/conf/httpd.conf(在LoadModule php5_module modules/libphp5.so添加AddType application/x-httpd-php .php)LoadModule php5_module modules/libphp5.soAddType 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
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部署成功!!

页: [1]
查看完整版本: 构建LAMP平台