ewsd12 发表于 2015-6-1 08:34:34

LAMPG平台搭建

一、部署LAMP环境。
1.什么是lamp
LAMP   网站运行平台
L       Linux操作系统
A      Apache    提供网站服务的软件
M   MySQL    提供数据库服务的软件
P      PHP         动态网站开发语言
                         .php    .jsp   .asp    .html    .css   .htm.xml         
2.前期准备环境
service   httpdstop
chkconfighttpdoff

service mysql stop
chkconfigmysqloff
rm-rf/etc/my.conf
rm-rf/var/lib/mysql/*

yum-y   gcc    gcc-c++   make
yum -y groupinstall "开发工具" 
            develtools

注:请遵行以下安装顺序,php要在apache和mysql安装之后安装

3.安装源码apache
**源码安装apache需要daemon用户,如系统没有需要手动添加**
grep   "daemon" /etc/passwd
useradd-M   -s/sbin/nologin   daemon

依赖包,需要先安装
yum -y install openssl-devel.x86_64


--prefix=:指定安装目录
--enable-so:支持动态加载模块
--enable-rewrite :支持网站地址重写
--enable-cgi:支持CGI程序脚本
--enable-ssl:支持SSL加密      rpm -q   openssl    openssl-devel
--enable-charset-lite:支持多语言编码

rewrite   网站服务器修改客户端访问自己的URL地址
               http://www.baidu.com/a/music/a.mp3

./configure --prefix=/usr/local/http2 --enable-so--enable-rewrite--enable-cgi--enable-ssl   --enable-charset-lite

make
make   install



目录说明 
cd/usr/local/http2/
htdocs   网页文件目录   
conf/httpd.conf    主配置文件
logs日志文件存放目录( 访问日志、错误日志)   
bin    保存可执行命令
          apachectl    启动/停止 源码网站服务的名
modules模块文件存放

netstat -utnalp | grep :80
/usr/local/httpd/bin/apachectlstart/stop

进程名   httpd
进程所有者   daemon
端口80

# ls /usr/local/http2/htdocs/
index.html
# yum -yinstall   elinks

# elinks   --dump   http://localhost
                                 It works!

# echo11111111> /usr/local/http2/htdocs/a.html
# elinks--dumphttp://localhost/a.html
   11111111
#

# ls /usr/local/http2/logs/
access_logerror_loghttpd.pid
#


4.安装源码mysql
rpm -qa | grep-i    mysql
service mysqlstop
chkconfigmysqloff
grepmysql/etc/passwd
useradd-M-s /sbin/nologin   mysql
rm-rf   /etc/my.cnf


yum -y install *curses*
yum -y install *termcap*
./configure--prefix=/usr/local/mysql --with-charset=utf8--with-collation=utf8_general_ci    --with-extra-charsets=gbk,gb2312
make   
make   install

初始化授权库(MySQL库)
cd   /usr/local/mysql/bin/
./mysql_install_db    --user=mysql
chown-Rmysql:mysql/usr/local/mysql/
数据库目录:   安装目录/var/      

创建主配置文件/etc/my.cnf
cd   mysql-5.1.62/support-files/
cp my-medium.cnf /etc/my.cnf

启动源码数据库服务
netstat -utnalp | grep :3306
/usr/local/mysql/bin/mysqld_safe--user=mysql   &


登陆数据库服务器
默认数据库管理员root 从本机登陆没有密码
# /usr/local/mysql/bin/mysql-uroot-p
Enter password: 回车

设置数据库管理员从数据库服务器本机登陆的密码
/usr/local/mysql/bin/mysqladmin-hlocalhost -urootpassword "123";

重置数据库管理员从数据库服务器本机登陆的密码
/usr/local/mysql/bin/mysqladmin-hlocalhost -uroot-ppassword "456";

停止源码数据库服务
killall-9   mysqld
pkill    -9   mysqld

5.安装源码的php
yum -y install *libxml2*
./configure--prefix=/usr/local/php    --enable-mbstring
--with-apxs2=/usr/local/http2/bin/apxs   
--with-mysql=/usr/local/mysql   
--enable-sockets    --with-config-file-path=/usr/local/php/etc
make
makeinstall

--prefix=:指定安装目录
--enable-mbstring:支持多字节字符
--with-apxs2:指定httpd的模块工具位置
--with-mysql:指定mysql的安装位置
--enable-sockets:启用套接字支持
--enable-sockets:指定配置路径
--with-config-file-path=:指定配置路径

# ls /usr/local/http2/modules/
httpd.exp    libphp5.so

# grep -i "libphp5" /usr/local/http2/conf/httpd.conf
LoadModule php5_module      modules/libphp5.so
#


创建php的配置文件 php.ini
cd   php-5.4.19
cp   php.ini-production    /usr/local/php/etc/php.ini


配置apache 支持php程序
vim /usr/local/http2/conf/httpd.conf
311   AddType application/x-compress .Z
312   AddType application/x-gzip .gz .tgz
313   AddType application/x-httpd-php   .php
170   DirectoryIndex   index.php   index.html
:wq
# /usr/local/http2/bin/apachectlstop
# /usr/local/http2/bin/apachectlstart

测试 网站服务是否能解释php页面
# vim   /usr/local/http2/htdocs/test.php
<?php
echo "helloworld!!!";
?>
#

elinks--dump    http://localhost/test.php

# cat a.php
<?php
phpinfo();
?>
#

测试php能否连接MySQL数据库
netstat-untlap| grep:3306
vimlinkdb.php
<?php
$a=mysql_connect("localhost","root","123");
if($a){
   echo "ok";
}else{
   echo "no";
}
?>
:wq


LAMP   192.168.1.200
MYSQL   192.168.1.100


6.在LAMP平台上发布Discuz论坛
unzipDiscuz_X3.0_SC_UTF8.zip
mv upload/   /usr/local/http2/htdocs/bbs
chown -Rdaemonconfig data uc_client uc_server

# mysql -uroot -p456
mysql> grantall on bbsdb.* to bbsuser@"localhost" identified by "123456";
quit;

安装论坛
http://localhost/bbs/

访问论坛
http://服务器地址/bbs/

管理论坛
http://服务器地址/bbs/admin.php

amdin
654321

18:30       mysqlphpadmin(mysql图形管理工具)
               PHP代理



页: [1]
查看完整版本: LAMPG平台搭建