23rewr 发表于 2014-11-21 17:24:12

LAMP网站平台搭建

适用环境:RHEL5.9/5.10 x86_64

—— 准备工作:
# yum-yinstall openssl-devel
# yum-yinstall ncurses-devel libtermcap-devel
# yum-yinstall libxml2-devel
# yum-yremove httpdmysql-servermysql php-mysql

###############################START ######################

1. 编译安装 httpd
1)安装
# tarzxf/软件包路径/httpd-2.2.26.tar.gz-C/usr/src/
# cd/usr/src/httpd-2.2.26/
[root@mailhttpd-2.2.26]# ./configure --prefix=/usr/local/httpd \
--enable-so --enable-rewrite --enable-cgi \
--enable-charset-lite --enable-ssl \
--enable-suexec\
--with-suexec-caller=daemon\
--with-suexec-docroot=/usr/local/httpd/htdocs

[root@mailhttpd-2.2.26]# make
[root@mailhttpd-2.2.26]# makeinstall

2)建立 httpd 控制脚本(注意添加chkconfig识别参数)
# cp-f/usr/local/httpd/bin/apachectl/etc/init.d/httpd
# vim/etc/init.d/httpd         
#!/bin/bash
#chkconfig: 35 85 15
#description: Apache is a World Wide Web Server
.. ..

# chmod+x/etc/init.d/httpd
# chkconfig--addhttpd

2. 编译安装 mysql (可以与 httpd 安装同时进行)
1)准备mysql运行账户
# useradd-M-u 49 -s /sbin/nologinmysql

2)安装
# tarzxf/软件包路径/mysql-5.1.62.tar.gz-C/usr/src/
# cd/usr/src/mysql-5.1.62/
[root@mailmysql-5.1.62]# ./configure --prefix=/usr/local/mysql \
--with-charset=utf8\
--with-collation=utf8_general_ci--with-extra-charsets=gbk,gb2312

[root@mailmysql-5.1.62]# make
[root@mailmysql-5.1.62]# makeinstall

[root@mailmysql-5.1.62]# cd/usr/local/mysql/
# bin/mysql_install_db --user=mysql

3)调整mysql目录权限
# chown-R root:mysql/usr/local/mysql/
# chown-R mysql/usr/local/mysql/var/

4)建立my.cnf配置文件
# cp-f /usr/local/mysql/share/mysql/my-medium.cnf/etc/my.cnf
# vim/etc/my.cnf
#skip-locking
skip-external-locking
.. ..

5)mysql执行优化、添加库路径
# ln-sf/usr/local/mysql/bin/*/usr/local/bin/
# vim/etc/ld.so.conf.d/mysql-64.conf
/usr/local/mysql/lib/mysql
#ldconfig

6)建立 mysqld 服务控制脚本
# cp-f /usr/local/mysql/share/mysql/mysql.server/etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# chkconfig --add mysqld

3. 编译安装 php

1)安装
# tarzxf/软件包路径/php-5.4.24.tar.gz-C/usr/src/
# cd/usr/src/php-5.4.24/
[root@mailphp-5.4.24]# ./configure--prefix=/usr/local/php\
--enable-mbstring--enable-sockets \
--with-apxs2=/usr/local/httpd/bin/apxs--with-mysql=/usr/local/mysql \
--with-config-file-path=/usr/local/php

[root@mailphp-5.4.24]# make
[root@mailphp-5.4.24]# makeinstall

2)启用httpd的PHP网页支持
# vim/usr/local/httpd/conf/httpd.conf
.. ..
LoadModulephp5_modulemodules/libphp5.so
<IfModuledir_module>
    DirectoryIndex index.html index.php
</IfModule>
AddTypeapplication/x-httpd-php.php
.. ..

4. 启动LAMP平台、测试

# servicemysqldrestart
# servicehttpdrestart

# vim /usr/local/httpd/htdocs/test2.php
<?php
   $link=mysql_connect('localhost','root','1234567');
    if($link) echo "Success !!";
    else echo "Failure !!";
    mysql_close();
?>

从浏览器访问http://服务器地址/test2.php,应显示“Success!!”

###############################END ######################################

页: [1]
查看完整版本: LAMP网站平台搭建