Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4073
  • 博文数量: 4
  • 博客积分: 125
  • 博客等级: 入伍新兵
  • 技术积分: 55
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-08 17:41
文章分类

全部博文(4)

文章存档

2011年(4)

我的朋友
最近访客

分类: LINUX

2011-08-10 14:49:25

构建LAMP网站服务平台
Apache
1:安装HTTPD软件包
~]# ls /media/cdrom/Server/*httpd*
/media/cdrom/Server/httpd-2.2.3-6.el5.i386.rpm
/media/cdrom/Server/httpd-devel-2.2.3-6.el5.i386.rpm
/media/cdrom/Server/httpd-manual-2.2.3-6.el5.i386.rpm
/media/cdrom/Server/system-config-httpd-1.3.3.1-1.el5.noarch.rpm
[root@s1 ~]# rpm -ivh /media/cdrom/Server/httpd-2.2.3-6.el5.i386.rpm
2:[root@s1 mnt]# tar -zxvf httpd-2.2.9.tar.gz -C /usr/src/
3:配置编译选项
[root@s1 mnt]# cd /usr/src/httpd-2.2.9/
[root@s1 httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-cgi --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/apache2/htdocs
4:编译服务程序和安装
[root@s1 httpd-2.2.9]# make && make install
5:在HTTPD.CONF文件中添加:SERVERNAME“配置行,设置WEB服务的域名
[root@s1 ~]# vi /usr/local/apache2/conf/httpd.conf
ServerName
6:启动、终止HTTPD服务
[root@s1 ~]# /usr/local/apache2/bin/apachectl -t
Syntax OK
[root@s1 ~]# /usr/local/apache2/bin/apachectl restart
httpd not running, trying to start
[root@s1 ~]# /usr/local/apache2/bin/apachectl start
httpd (pid 20911) already running
[root@s1 ~]# netstat -anpt |grep :80
tcp        0      0 :::80                       :::*                        LISTEN      20911/httpd    
7:构建虚拟WEB主机
(1)在HTTPD服务器的网页目录建立两个文件夹benetcom accpcom ,并分别建立两个测试网页
    [root@s1 ~]# cd /usr/local/apache2/htdocs/
[root@s1 htdocs]# mkdir benetcom accpcom
[root@s1 htdocs]# echo "" > benetcom/index.html
[root@s1 htdocs]# echo "" > accpcom/index.html
(2)修改HTTPD.CONF文件 添加虚拟主机配置
[root@s1 htdocs]# vi /usr/local/apache2/conf/httpd.conf
NameVirtualHost 172.16.16.166

DocumentRoot /usr/local/apache2/htdocs/benetcom
ServerName
ErrorLog logs/
CustomLog logs/www,benet.com.access.log common


DocumentRoot /usr/local/apache2/htdocs/accpcom
ServerName
ErrorLog logs/
CustomLog logs/www,accp.com.access.log common

(3)建立系统用户的个人主页
[root@s1 ~]# vi /usr/local/apache2/conf/httpd.conf
UserDir public_html

AllowOverride none
Options none
Order allow,deny
Allow from all
建立个人主页测试文件
[root@s1 ~]# su - huang
[huang@www ~]$ mkdir public_html
[huang@www ~]$ echo "huang's home page " >> public_html/index.html
[huang@www ~]$ ls -ld /home/huang/
drwx------ 3 huang huang 4096 Apr 29 16:16 /home/huang/
[huang@www ~]$ chmod o+x /home/huang/
[huang@www ~]$ ls -ld /home/huang/
drwx-----x 3 huang huang 4096 Apr 29 16:16 /home/huang/
在客户机浏览器中访问个人主页

设置Apache开机自动运行:

# vi /etc/rc.d/rc.local

在最下面加入一行

/usr/local/apache/bin/apachectl start
 
Mysql
1:安装MYSQL
[root@s1 ~]# useradd -M -s /sbin/nologin mysql
[root@s1 mnt]# tar -zxvf mysql-5.0.56.tar.gz -C /usr/src/
[root@s1 ~]# cd /usr/src/mysql-5.0.56/
[root@s1 mysql-5.0.56]# ./configure --prefix=/usr/local/mysql
[root@s1 mysql-5.0.56]# make && make install
2:建立配置文件
[root@s1 mysql-5.0.56]# cp support-files/my-medium.cnf /etc/my.cnf
3:初始化数据库
[root@s1 mysql-5.0.56]# /usr/local/mysql/bin/mysql_install_db --user=mysql
[root@s1 mysql-5.0.56]# chown -R root.mysql /usr/local/mysql/
[root@s1 mysql-5.0.56]# chown -R mysql /usr/local/mysql/var/
4:调整lib库路径
[root@s1 mysql-5.0.56]# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
[root@s1 mysql-5.0.56]# ldconfig
5:MYSQL启动控制
[root@s1 mysql-5.0.56]# /usr/local/mysql/bin/mysqld_safe --user=mysql &
[root@s1 mysql-5.0.56]# netstat -ntpl |grep 3306
6:将MYSQL添加为系统服务
[root@s1 mysql-5.0.56]# cp support-files/mysql.server /etc/init.d/mysqld
[root@s1 mysql-5.0.56]# chmod +x /etc/init.d/mysqld
[root@s1 mysql-5.0.56]# chkconfig --add mysqld
[root@s1 mysql-5.0.56]# chkconfig mysqld on
7:设置MYSQL程序的执行路径
[root@s1 mysql-5.0.56]# export PATH=$PATH:/usr/local/mysql/bin/
[root@s1 mysql-5.0.56]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
8:登陆及退出MYSQL环境
[root@s1 ~]# mysql -u root
[root@s1 ~]# mysqladmin -u root password "huang"
[root@s1 ~]# mysql -u root -p
 
5.2构建PHP环境....................................................................
1:安装PHP软件包
[root@s1 mnt]# tar -jxvf php-5.2.6.tar.bz2 -C /usr/src/
[root@s1 mnt]# cd /usr/src/php-5.2.6/
[root@s1 php-5.2.6]# ./configure --prefix=/usr/local/php5 --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5
[root@s1 php-5.2.6]# make && make install
[root@s1 php-5.2.6]# cp php.ini-dist /usr/local/php5/php.ini
2:设置HTTP.CONF文件
[root@s1 php-5.2.6]# vi /usr/local/apache2/conf/httpd.conf
 DirectoryIndex index.html index.php
LoadModule php5_module        modules/libphp5.so
AddType application/x-httpd-php .php
 
vi /usr/local/apache/htdocs/test.php
 phpinfo();
?>
 
 
阅读(334) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:编译安装LAMP及编译代码详解

给主人留下些什么吧!~~