用源代码搭建LAMP环境

来源:互联网 发布:聚焦网络 编辑:程序博客网 时间:2024/05/17 01:20

1:LAMP环境的搭建方法:

第一种:RPM包安装方式

第二种:源代码包编译安装方式

https:443
http:80

客户端------WEB服务器------MYSQL数据库
当客户端发送请求时  WEB服务器通过PHP连接后台MYSQL数据库
同样:perl/java/python都可以用来连接后台的数据库
MYSQL有专门自己的存储集群

MYSQL的三种架构:单机/AB复制/集群

相关软件包:
[root@stu15 ~]# rpm -qa | grep mysql
mysql-5.0.45-7.el5    客户端应用程序
mysql-server-5.0.45-7.el5   服务器端的应用程序
php-mysql-5.1.6-23.el5    php用来连接数据库的工具

当php被apache编译成模块时:
[root@stu15 ~]# ls /etc/httpd/modules/libphp5.so
/etc/httpd/modules/libphp5.so

如果是采用rpm包安装的话,php有自己的配置文件:
[root@stu15 conf.d]# pwd
/etc/httpd/conf.d
[root@stu15 conf.d]# ls
php.conf  proxy_ajp.conf  README  welcome.conf
叫php.conf
php是一种编程语言

MYSQL是一种关系型数据库管理系统(RDBMS)
MYSQL--databases--表--记录
数据库在文件系统里面都是以目录的形式存在的:/var/lib/mysql下(rpm包安装方式的情况下)
且下面的所有的目录都是700,默认情况下,系统中有两个数据库:mysql/test 其中test是用来测试用的,而mysql则是用来存放用户、表定义、索引之类的东东!而下面的mysql.sock是套接字文件,是用来和客户端连接用的,当mysql服务启动时就存在该文件,如果没启动,则没有!!

采用源码包搭建LAMP环境
相关软件包及文档:
[root@stu15 lamp]# ls
AdobeReader_chs-7.0.0-2.i386.rpm
Discuz!_6.0.0_SC_GBK.pcpop.zip
httpd-2.2.11.tar.bz2
lamp.txt
mysql
mysql-5.1.34.tar.gz
mysql-cluster-gpl-6.3.20-linux-i686-glibc23.tar.gz
php-5.2.9.tar.bz2
phpBB
phpMyAdmin-3.1.4-all-languages.tar.bz2

现装apache
[root@stu15 lamp]# tar jxvf httpd-2.2.11.tar.bz2 -C /usr/local/src
现解压,进入解压目录
[root@stu15 httpd-2.2.11]# pwd
/usr/local/src/httpd-2.2.11
[root@stu15 httpd-2.2.11]# ls
ABOUT_APACHE      CHANGES        include         modules           srclib
acinclude.m4      config.layout  INSTALL         NOTICE            support
Apache.dsw        configure      InstallBin.dsp  NWGNUmakefile     test
apachenw.mcp.zip  configure.in   LAYOUT          os                VERSIONING
build             docs           libhttpd.dsp    README
BuildAll.dsp      emacs-style    LICENSE         README.platforms
BuildBin.dsp      httpd.dsp      Makefile.in     ROADMAP
buildconf         httpd.spec     Makefile.win    server
下面的INSTALL文件主要是用来告诉你如何安装的
[root@stu15 httpd-2.2.11]# vim INSTALL
 10      $ ./configure --prefix=PREFIX
 11      $ make
 12      $ make install
 13      $ PREFIX/bin/apachectl start
也可以查看./configure的相关帮助
[root@stu15 httpd-2.2.11]# ./configure --help
编译前的准备:
./configure --prefix=/usr/local/apache2 --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl
编译:
make
安装:
make install
安装完成:
[root@stu15 apache2]# pwd
/usr/local/apache2
[root@stu15 apache2]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
下面的一系列目录
conf是放配置文件
htdocs是放网页的
logs是用来存放日志的
modules是用来存放模块的
[root@stu15 bin]# pwd
/usr/local/apache2/bin
[root@stu15 bin]# ls
ab            apu-1-config  dbmmanage    htcacheclean  htpasswd   logresolve
apachectl     apxs          envvars      htdbm         httpd      rotatelogs
apr-1-config  checkgid      envvars-std  htdigest      httxt2dbm
apache的启动文件:apachectl
测试文件:ab

启动服务:
[root@stu15 bin]# ./apachectl start
httpd (pid 3163) already running
[root@stu15 ~]# /usr/local/apache2/bin/apachectl restart
现在就可以通过浏览器来访问了
因为命令比较长,可以写一个简单的脚本来执行
如果想apache开机就启动,可以把该命令放到/etc/rc.d/rc.local里面

 

如何开启https的443端口呢?
首先在服务器端产生一对公私钥
产生证书请求:
[root@stu15 ~]# mkdir k
[root@stu15 ~]# cd k
[root@stu15 k]#

[root@stu15 k]# openssl req -new -out server.csr
Generating a 1024 bit RSA private key
......++++++
...++++++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:beijing
Locality Name (eg, city) [Newbury]:
Organization Name (eg, company) [My Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@stu15 k]# ls
privkey.pem  server.csr
生成两个临时文件

生成私钥
[root@stu15 k]# openssl rsa -in privkey.pem -out server.key
Enter pass phrase for privkey.pem:
writing RSA key
[root@stu15 k]# ls
privkey.pem  server.csr  server.key

生成证书:
[root@stu15 k]# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365
Signature ok
subject=/C=CN/ST=beijing/L=Newbury/O=My Company Ltd
Getting Private key
[root@stu15 k]# ls
privkey.pem  server.crt  server.csr  server.key
我们想要的两个文件server.crt/server.key都有了,下面则将这两个文件防止不同的位置
在这之前我们得修改一下apache的主配置文件:
[root@stu15 ~]# vim /usr/local/apache2/conf/httpd.conf
修改其445行 将其#号注释去掉
445 Include conf/extra/httpd-ssl.conf
保存退出
然后我们来查看一下:server.crt/server.key两个文件的放置位置帮助:
[root@stu15 extra]# pwd
/usr/local/apache2/conf/extra
[root@stu15 extra]# ls
httpd-autoindex.conf  httpd-languages.conf           httpd-ssl.conf
httpd-dav.conf        httpd-manual.conf              httpd-userdir.conf
httpd-default.conf    httpd-mpm.conf                 httpd-vhosts.conf
httpd-info.conf       httpd-multilang-errordoc.conf
查看httpd-ssl.conf
[root@stu15 extra]# vim httpd-ssl.conf
99 SSLCertificateFile "/usr/local/apache2/conf/server.crt"
107 SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
进入/usr/local/apache2/conf目录下面
cp /root/k/server.key .
cp /root/k/server.crt .

重新启动apache服务
[root@stu15 ~]# /usr/local/apache2/bin/apachectl restart
这样服务器的443端口就打开了
[root@stu15 ~]# nmap 192.168.0.158
Starting Nmap 4.11 (
http://www.insecure.org/nmap/ ) at 2010-01-19 11:34 CST
Interesting ports on 192.168.0.158:
Not shown: 1673 closed ports
PORT     STATE SERVICE
80/tcp   open  http
111/tcp  open  rpcbind
443/tcp  open  https
640/tcp  open  unknown
913/tcp  open  unknown
1000/tcp open  cadlock
2049/tcp open  nfs
Nmap finished: 1 IP address (1 host up) scanned in 13.108 seconds
测试:
https://192.168.0.158
即可访问

直接把apache2目录删掉就可以把源码包安装的卸载
[root@stu15 bin]# ./httpd -M
查看模块

源码安装MYSQL
[root@stu15 ~]# tar zxvf mysql-5.1.34.tar.gz -C /usr/local/src
进入解压目录:
[root@stu15 mysql-5.1.34]# pwd
/usr/local/src/mysql-5.1.34
[root@stu15 mysql-5.1.34]# ls
aclocal.m4      COPYING             ltmain.sh    server-tools
BUILD           dbug                Makefile     sql
ChangeLog       depcomp             Makefile.am  sql-bench
client          Docs                Makefile.in  sql-common
CMakeLists.txt  EXCEPTIONS-CLIENT   man          storage
cmd-line-utils  extra               missing      strings
config          include             mysql-test   support-files
config.guess    install-sh          mysys        tests
config.h.in     INSTALL-SOURCE      netware      unittest
config.log      INSTALL-WIN-SOURCE  plugin       vio
config.status   libmysql            pstack       win
config.sub      libmysqld           README       ylwrap
configure       libmysql_r          regex        zlib
configure.in    libtool             scripts
编译前的准备:
[root@stu15 mysql-5.1.34]# ./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql --with-extra-charsets=all  --exec-prefix=/usr/local/mysql --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-innodb --with-plugins=partition
编译:
make
安装:
make install

安装完成后的相关目录:
[root@stu15 mysql]# pwd
/usr/local/mysql
[root@stu15 mysql]# ls
bin  docs  include  lib  libexec  mysql-test  share  sql-bench
[root@stu15 bin]# ls
innochecksum       mysql_client_test           mysql_secure_installation
msql2mysql         mysql_config                mysql_setpermission
myisamchk          mysql_convert_table_format  mysqlshow
myisam_ftdump      mysqld_multi                mysqlslap
myisamlog          mysqld_safe                 mysqltest
myisampack         mysqldump                   mysql_tzinfo_to_sql
my_print_defaults  mysqldumpslow               mysql_upgrade
mysql              mysql_find_rows             mysql_waitpid
mysqlaccess        mysql_fix_extensions        mysql_zap
mysqladmin         mysql_fix_privilege_tables  perror
mysqlbinlog        mysqlhotcopy                replace
mysqlbug           mysqlimport                 resolveip
mysqlcheck         mysql_install_db            resolve_stack_dump
现在我们来初始化MYSQL:
执行./mysql_install_db
默认情况/usr/local/mysql目录下没有var目录,当我们执行MYSQL初始化后在该目录下将会产生var目录
[root@stu15 bin]# ./mysql_install_db
Installing MySQL system tables...
100119 13:35:28 [Warning] Forcing shutdown of 1 plugins
OK
Filling help tables...
100119 13:35:28 [Warning] Forcing shutdown of 1 plugins
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h stu15.uplooking.com password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!
The latest information about MySQL is available at
http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/
[root@stu15 bin]# cd ..
[root@stu15 mysql]# ls
bin  docs  include  lib  libexec  mysql-test  share  sql-bench  var
[root@stu15 mysql]# cd var
[root@stu15 var]# ls
mysql  test

默认情况下var目录下存放的是缺省的数据库
如果MYSQL无法初始化的话,首先得查看系统中是否存在mysql用户,如果没有得创建
第二种情况就是mysql的rpm包惹的祸,我们可以将系统中原先安装的mysql的rpm包强制卸载
rpm -e mysql --nodeps

接下来我们得修改相关目录的权限
[root@stu15 local]# pwd
/usr/local
[root@stu15 local]# ll -d mysql/
drwxr-xr-x 11 root root 4096 01-19 13:35 mysql/
mysql目录的所属主和所属组都是root,进行如下修改:
[root@stu15 local]# chown .mysql mysql/ -R
[root@stu15 local]# ll -d mysql/
drwxr-xr-x 11 root mysql 4096 01-19 13:35 mysql/

还有var目录
[root@stu15 mysql]# pwd
/usr/local/mysql
[root@stu15 mysql]# ll -d var
drwx------ 4 root mysql 4096 01-19 13:35 var
[root@stu15 mysql]# chown mysql var -R
[root@stu15 mysql]# ll -d var
drwx------ 4 mysql mysql 4096 01-19 13:35 var

接下来我们就来启动mysql
[root@stu15 mysql]# ls
bin  docs  include  lib  libexec  mysql-test  share  sql-bench  var
[root@stu15 mysql]# cd bin
[root@stu15 bin]# ./mysqld_safe --user=mysql &
[1] 6374
[root@stu15 bin]# 100119 13:50:20 mysqld_safe Logging to '/usr/local/mysql/var/stu15.uplooking.com.err'.
100119 13:50:20 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var

[root@stu15 bin]#
查看var目录下的变化:
[root@stu15 var]# pwd
/usr/local/mysql/var
[root@stu15 var]# ls
ibdata1      ib_logfile1  stu15.uplooking.com.err  test
ib_logfile0  mysql        stu15.uplooking.com.pid
查看一下进程:
[root@stu15 var]# ps -e|grep mysql
 6374 pts/1    00:00:00 mysqld_safe
 6425 pts/1    00:00:00 mysqld
说明mysql已经启动,现在我们得测试进入MYSQL数据库
[root@stu15 bin]# pwd
/usr/local/mysql/bin
[root@stu15 bin]# ./mysql
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 1
Server version: 5.1.34 Source distribution
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql>
修改MYSQL数据库密码:
[root@stu15 bin]# ./mysqladmin -u root password 123
[root@stu15 bin]# ./mysql
ERROR 1045 (28000): Access denied for user
'root'@'localhost' (using password: NO)
[root@stu15 bin]# ./mysql -u root -p123
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 4
Server version: 5.1.34 Source distribution
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql>
或者:
[root@stu15 bin]# ./mysql -u root -p
Enter password:(在这里输入密码)
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 5
Server version: 5.1.34 Source distribution
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql>
MYSQL默认情况下提供了一个启动脚本在如下目录下:
[root@stu15 mysql]# pwd
/usr/local/mysql/share/mysql
[root@stu15 mysql]# ll mysql.server
-rwxr-xr-x 1 root mysql 12087 01-19 12:08 mysql.server
让其成为独立服务,并使其可以用service ----- stop/start/restart来操作
[root@stu15 mysql]# pwd
/usr/local/mysql/share/mysql
[root@stu15 mysql]# cp mysql.server /etc/init.d/
[root@stu15 mysql]# chkconfig --add mysql.server
[root@stu15 mysql]# service mysql.server restart
[root@stu15 ~]# service mysql.server restart
Shutting down MySQL.                                       [确定]
Starting MySQL.                                            [确定]
[root@stu15 mysql]# chkconfig --list mysql.server
mysql.server    0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
这个时候每次进入数据库都得进入mysql的安装目录的bin目录下执行命令:./mysql,为啥不进行从简呢?
[root@stu15 ~]# which mysql
/usr/bin/which: no mysql in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin)

vim /root/.bash_profile
10 PATH=$MYSQL_HOME:$PATH:$HOME/bin
11 MYSQL_HOME=/usr/local/mysql/bin
[root@stu15 ~]# source .bash_profile
[root@stu15 ~]# which mysql
/usr/local/mysql/bin/mysql
[root@stu15 ~]# echo $PATH
/usr/local/mysql/bin::/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/root/bin:/root/bin
[root@stu15 ~]# mysql
ERROR 1045 (28000): Access denied for user
'root'@'localhost' (using password: NO)
[root@stu15 ~]# mysql -u root -p123
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 2
Server version: 5.1.34 Source distribution
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql>

如何为数据库修改密码呢?
[root@stu15 ~]# mysqladmin -u root password 123456 -p123
[root@stu15 ~]# mysql -u root -p123456
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 4
Server version: 5.1.34 Source distribution
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql>

介绍几种创建数据库的方法:
[root@stu15 var]# ls
discuz   ib_logfile0  mysql  stu15.uplooking.com.err  test
ibdata1  ib_logfile1  phpbb  stu15.uplooking.com.pid
[root@stu15 var]# mkdir db1
[root@stu15 var]# chown mysql.mysql db1 -R
[root@stu15 var]# chmod 700 db1 -R
[root@stu15 var]# mysql -u root -p123456
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 5
Server version: 5.1.34 Source distribution
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database               |
+--------------------+
| information_schema |
| db1                             |
| discuz                         |
| mysql                          |
| phpbb                         |
| test                             |
+--------------------+
6 rows in set (0.08 sec)
mysql>
或者用:
[root@stu15 var]# mysqladmin create db1 -u root -p123456
所以说创建数据库有三种方法。对应的删除数据库也同样有三种方法。


安装PHP
[root@stu15 php-5.2.9]# tar jxvf php-5.2.9.tar.bz2 -C /usr/local/src
[root@stu15 php-5.2.9]# pwd
/usr/local/src/php-5.2.9
[root@stu15 php-5.2.9]# ls
acconfig.h        main                              README.TESTING
acconfig.h.in     makedist                          README.TESTING2
acinclude.m4      Makefile.frag                     README.UNIX-BUILD-SYSTEM
aclocal.m4        Makefile.gcov                     README.UPDATE_5_2
build             Makefile.global                   README.WIN32-BUILD-SYSTEM
buildconf         makerpm                           README.Zeus
buildconf.bat     missing                           regex
**************************部分省略************************************
编译前的准备:
[root@stu15 php]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php
编译:
make
安装:
make install

[root@stu15 php]# pwd
/usr/local/php
[root@stu15 php]# ls
bin  etc  include  lib  man
[root@stu15 php-5.2.9]# pwd
/usr/local/src/php-5.2.9
[root@stu15 php-5.2.9]# cp php.ini-dist /usr/local/php/php.ini
将该目录下的php.ini-dist拷贝到php的安装目录下,并改名字为php.ini
如果一切顺利的话,apache2/modules 下应该有个libphp5.so 的文件
[root@stu15 ~]# ll /usr/local/apache2/modules/libphp5.so
-rwxr-xr-x 1 root root 12814525 01-19 14:20 /usr/local/apache2/modules/libphp5.so
接下来我们来修改apache的主配置文件,为apache添加php支持
[root@stu15 ~]# vim /usr/local/apache2/conf/httpd.conf
98 LoadModule rewrite_module modules/mod_rewrite.so
99 LoadModule php5_module        modules/libphp5.so
211 <IfModule dir_module>
212     DirectoryIndex index.html index.php
213 </IfModule>
353     AddType application/x-compress .Z
354     AddType application/x-gzip .gz .tgz
355     AddType application/x-httpd-php .php
重新启动apache服务
apachectl stop
apachectl start
制作测试网页
[root@stu15 ~]# ll /usr/local/apache2/htdocs/
总计 8
-rw-r--r-- 1 root root 44 2004-11-21 index.html
-rw-r--r-- 1 root root 22 01-19 14:31 index.php
浏览器访问,即可!
文件index.php的内容:
  1 <?
  2     phpinfo()
  3 ?>
测试php和MYSQL的连接情况,查看1.php的内容:
  1 <?php
  2    mysql_connect("localhost","root","123") or die("NOT SCUSSFUL");
  3    echo "OK!";
  4 ?>
访问测试:
http://192.168.0.158/1.php


安装phpBB
[root@stu15 lamp]# pwd
/root/lamp
[root@stu15 lamp]# ll -d phpBB/
drwxr-xr-x 12 root root 4096 01-19 09:33 phpBB/
[root@stu15 lamp]# cp -r phpBB/ /usr/local/apache2/htdocs/
[root@stu15 phpBB]# ls
admin        db             includes        modcp.php    viewforum.php
cache        docs           index.php       posting.php  viewonline.php
cnphpbb.txt  extension.inc  install         privmsg.php  viewtopic.php
common.php   faq.php        language        profile.php
config.php   groupcp.php    login.php       search.php
contrib      images         memberlist.php  templates
[root@stu15 phpBB]# ll config.php
-rwxr-xr-x 1 root root 0 01-19 15:06 config.php
[root@stu15 phpBB]# chmod 666 config.php
[root@stu15 phpBB]# ll config.php
-rw-rw-rw- 1 root root 0 01-19 15:06 config.php
创建数据库:
[root@stu15 phpBB]# mysql -u root -p123456
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 15
Server version: 5.1.34 Source distribution
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql> create database phpbb;
Query OK, 1 row affected (0.02 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| discuz             |
| mysql              |
| phpbb              |
| test               |
+--------------------+
5 rows in set (0.00 sec)
打开浏览器输入:
http://192.168.0.158/phpBB进行安装
删除install/和contrib/目录
[root@stu15 phpBB]# ls
admin        db             includes        modcp.php    viewforum.php
cache        docs           index.php       posting.php  viewonline.php
cnphpbb.txt  extension.inc  install         privmsg.php  viewtopic.php
common.php   faq.php        language        profile.php
config.php   groupcp.php    login.php       search.php
contrib      images         memberlist.php  templates
[root@stu15 phpBB]# pwd
/usr/local/apache2/htdocs/phpBB
[root@stu15 phpBB]# rm -rf install/
[root@stu15 phpBB]# rm -rf contrib/

呵呵!该论坛就算是搭建成功了!用户可以进行注册!

但是该论坛可观性不怎么好!下面我们来搭建一个非常好看的论坛:discuz
相关软件包:
[root@stu15 lamp]# pwd
/root/lamp
[root@stu15 lamp]# ll phpMyAdmin-3.1.4-all-languages.tar.bz2
-rwxr-xr-x 1 root root 2659480 01-19 09:33 phpMyAdmin-3.1.4-all-languages.tar.bz2
解压:
[root@stu15 a]# unzip Discuz/!_6.0.0_SC_GBK.pcpop.zip
[root@stu15 a]# ls
Discuz!_6.0.0_SC_GBK.pcpop.zip  upload  usersguide  users_guide.htm  utilities
解压后把upload目录复制到/usr/local/apache2/htdocs目录下,改名为bbs
[root@stu15 htdocs]# pwd
/usr/local/apache2/htdocs
[root@stu15 htdocs]# ls
1.php  bbs  index.html  index.php  phpBB
修改权限:
[root@stu15 htdocs]# chown daemon bbs -R
[root@stu15 htdocs]# ll -d bbs
drwxr-xr-x 16 daemon daemon 4096 01-19 15:43 bbs
其中daemon是apache服务的用户

建立数据库:
[root@stu15 ~]# mysql -u root -p123456
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 25
Server version: 5.1.34 Source distribution
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql> create database discuz;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| discuz             |
| mysql              |
| phpbb              |
| test               |
+--------------------+
5 rows in set (0.00 sec)
mysql> grant all on discuz.* to
discuz@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)
用root用户不安全,这里我们用discuz用户。

测试:访问:http://192.168.0.158/bbs/install.php即可进行安装了!!
到此discuz论坛就搭建成功了!

用浏览器来管理MYSQL
相关软件:
[root@stu15 lamp]# ll phpMyAdmin-3.1.4-all-languages.tar.bz2
-rwxr-xr-x 1 root root 2659480 01-19 09:33 phpMyAdmin-3.1.4-all-languages.tar.bz2
将其解压到apache网页存放目录中
[root@stu15 lamp]# tar jxvf phpMyAdmin-3.1.4-all-languages.tar.bz2 -C /usr/local/apache2/htdocs/
[root@stu15 htdocs]# pwd
/usr/local/apache2/htdocs
[root@stu15 htdocs]# ls
1.php  bbs  index.html  index.php  phpBB  phpMyAdmin-3.1.4-all-languages
[root@stu15 htdocs]# mv phpMyAdmin-3.1.4-all-languages/ pma
[root@stu15 htdocs]# ls
1.php  bbs  index.html  index.php  phpBB  pma
修改配置文件:
[root@stu15 pma]# pwd
/usr/local/apache2/htdocs/pma
[root@stu15 pma]# ll config.sample.inc.php
-rw-r--r-- 1 root root 2095 2009-04-25 config.sample.inc.php
[root@stu15 pma]# mv config.sample.inc.php config.inc.php
好了!配置已经完成了!
测试:打开浏览器输入:
http://192.168.0.158/pma即可,输入MYSQL的用户名和密码,就可以登录MYSQL服务器

 

原创粉丝点击