感谢CU:和群里哥们儿的支持!!!!!
若要到论坛提问,请先看看:http://blog.163.com/share_feelings/blog/static/10351208020091188518275
安装mysql:(二进制源码文件的安装)
下载地址:http://dev.mysql.com/downloads/mysql/5.1.html#linux
是
这个,要不安装的方法就不同了!!!!!!
安装方法可以参考解压后的mysql-5.1.31-linux-i686-glibc23下的INSTALL-BINARY
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
将mysql-5.1.31-linux-i686-glibc23.tar.gz(编译好的二进制包无须编译安装)复制到/soft/server下:
mv /pack/mysql-5.1.31-linux-i686-glibc23.tar.gz /soft/server
cd /soft/server
tar -zvxf mysql-5.1.31-linux-i686-glibc23.tar.gz
(或 cd /soft/server
gunzip < /pack/mysql-5.1.31-linux-i686-glibc23.tar.gz | tar xvf -)
ln -s mysql-5.1.31-linux-i686-glibc23.tar.gz mysql
cd mysql
//若是用root编译的还要有:
chown -R mysql .
chgrp -R mysql .
初始化数据库(以前未安装mysql):
./scripts/mysql_install_db --user=mysql
此时有如下几个重要命令提示:
*****************************************
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:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
./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 . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
**************************************************
运行mysql:
bin/mysqld_safe --user=mysql &
(注意:运行时一定要Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
否则:
[m@localhost ~]$ /soft/server/mysql/bin/mysqld_safe --user=mysql &
[1] 3197
[m@localhost ~]$ /soft/server/mysql/bin/mysqld_safe: line 297: my_print_defaults: command not found
/soft/server/mysql/bin/mysqld_safe: line 303: my_print_defaults: command not found
090219 16:23:59 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
090219 16:23:59 mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable.
Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
/soft/server/mysql/bin/mysqld_safe: line 96: /usr/local/mysql/data/localhost.localdomain.err: No such file or directory
)
查看mysql是否运行:
ps aux |grep mysql
[m@localhost mysql]$ ps auf |grep mysql
m 3385 0.0 0.1 4456 1128 pts/0 S 16:39 0:00 \_ /bin/sh bin/mysqld_safe --user=mysql
m
3434 0.0 1.4 117756 15072 pts/0 Sl 16:39 0:00 | \_
/soft/server/mysql/bin/mysqld --basedir=/soft/server/mysql
--datadir=/soft/server/mysql/data
--log-error=/soft/server/mysql/data/localhost.localdomain.err
--pid-file=/soft/server/mysql/data/localhost.localdomain.pid
或是:
ps -ef |grep mysql
[m@localhost mysql]$ ps -ef |grep mysql
m 3385 2922 0 16:39 pts/0 00:00:00 /bin/sh bin/mysqld_safe --user=mysql
m
3434 3385 0 16:39 pts/0 00:00:00 /soft/server/mysql/bin/mysqld
--basedir=/soft/server/mysql --datadir=/soft/server/mysql/data
--log-error=/soft/server/mysql/data/localhost.localdomain.err
--pid-file=/soft/server/mysql/data/localhost.localdomain.pid
m 3512 2922 0 16:51 pts/0 00:00:00 grep mysql
关闭mysql命令:
bin/mysqladmin --user=root --password=123 shutdown
要用root用户哟!!!
只有mysql启动了才能运行bin/mysql,否则出现如下错误:
[m@localhost mysql]$ bin/mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
建个数据库命令:
[m@localhost mysql]$ bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.31 MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database zeng ;
这样就可在mysql>后执行sql语句了!!!!
bin/mysqlshow
可看到test和mysql两个数据库,说明安装成功(看网上说的)
[m@localhost mysql]$ bin/mysqlshow
+--------------------+
| Databases |
+--------------------+
| information_schema |
| test |
+--------------------+
哈哈,我只看到一个!!!
//////////////////////////////////////////////////////////////
装mysql-gui-tools:
下载地址:
http://dev.mysql.com/downloads/gui-tools/5.0.html
注意是:
Linux downloads
Individual RPM packages are supplied for the GUI Tools components and combined into a single TAR archive.
下面的:
Generic x86 Linux TAR (bundled dependencies) |
|
5.0r12 |
23.5M |
Pick a Mirror |
MD5: 0d4c584c5963e6f2ce085a3bc99f2e85 |
Generic x86/64 Linux TAR (bundled dependencies) |
|
5.0r12 |
24.8M |
Pick a Mirror |
要不从源码装我是不会的,在CU上发的贴子也没解决!!!!!!
tar -zxvf mysql-gui-tools-5.0r14.tar.gz
在运行之前运行一个:
./mysql-administrator --update-path
./mysql-query-browser --update-path
后就可以用
mysql-administrator和mysql-query-browser了
用gui-tools方便管理
//////////////////////////////////////////////////////
jdk的安装:
用根用户:
chmod 777 jdk-6u12-linux-i586.bin //要不会提示权限不足
./jdk-6u12-linux-i586.bin安装jdk
ln -s jdk-1.6.0_12 java
java环境变量的设置:
java.sh:
SERVER_HOME=/soft/server
JAVA_HOME=$SERVER_HOME/java
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$PATH:$JAVA_HOME/bin
复制java.sh到/etc/profile.d下:
source /etc/profile.d/java.sh
让java.sh生效
运行java和javac就可看到它们的用法,表明jdk安装成功,但lib是否成功还是要编个java程序测试一下
//////////////////////////////////////////////////////////////////
tomcat的安装:
tar -zxvf apache-tomcat-6.0.18.tar.gz(二进制包)
ln -s apache-tomcat-6.0.18 tomcat
在tomcat/conf/server.xml中:
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
下加入:
启动tomcat:
/soft/server/tomcat/bin/startup.sh
关闭tomcat:
/soft/server/tomcat/bin/shutdown.sh
可以输入:或
就可看到tomcat猫了!!!!
在是文档目录没改变之前
在/work/www下建立hello.jsp:
<%out.println("Hello, Welcome to http://blog.163.com/share_feelings");%>
输入网址:
127.0.0.1:8080/hello.jsp
会显示:
Hello, Welcome to http://blog.163.com/share_feelings
//////////////////////////////////////////////////////////////
jdbc的安装:
要jsp与mysql连接就要用到jdbc了:
下载地址:
http://dev.mysql.com/downloads/connector/j/5.1.html
mysql-connector-java-5.1.7.tar.gz
解压后:
tar -zxvf mysql-connector-java-5.1.7.tar.gz
在你的项目文件夹下新建WEB-INF,在WEB-INF下新建lib,把mysql-connector-java-5.1.7下的mysql-connector-java-5.1.7-bin.jar复制到该模块WEB-INF/lib下,好让tomcat识别
或把mysql-connector-java-5.1.7-bin.jar复制到tomcat/lib(tomcat是tomcat/common/lib)下
tomcat能识别classpath路径,tomcat/common/lib下和模块WEB-INF/lib下的java库!!!
测试tomcat通过jdbc与mysql的连接情况:
测试程序:
<%@page import="java.sql.*"
import ="java.io.*"
%>
Test JDBC For MySQL
<%
Connection odbcconn=null; //数据库的连接对象
%>
<%
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
out.println("驱动程序加载成功.
");
}
catch(Exception e) {
out.println("加载驱动程序出错:"+e);
}
try {
odbcconn=java.sql.DriverManager.getConnection("jdbc:mysql://localhost/mysql?"+"user=root&password=123");
out.println("已经建立到MySQL数据库的连接.
");
odbcconn.close();
}
catch(Exception e) {
out.println("连接数据库出错:"+e);
}
%>
////////////////////////////////////////////////////////////////////
apache安装:
tar -zxvf httpd-2.2.10.tar.gz
cd httpd-2.2.10
./configure --prefix=/soft/server/apache --enable-so
make
make install
启动apache:
/soft/server/apache/bin/apachectl start
输入127.0.0.1看是否运行
///////////////////////////////////////////////////////////////////
php的安装:
tar -vjxf php-5.2.8.tar.bz2
cd php-5.2.8
./configure --prefix=/soft/server/php --with-apxs2=/soft/server/apache/bin/apxs --with-mysql=/soft/server/mysql
make
make install
配置php+apache:
httpd.conf:
For PHP 4:
LoadModule php4_module modules/libphp4.so
For PHP 5:
LoadModule php5_module modules/libphp5.so
在 AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
下加:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
修改虚拟目录:
DocumentRoot "/work/www"
********
/////////////////////////////////////////////////////////////
mod_jk.so(根据文件扩展名转发jsp文件)的安装:
将编译得来的mod_jk.so复制在modules下:
在httpd.conf中最后加入:
Include conf/mod_jk.conf
mod_jk.conf内容:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkShmFile logs/mod_jk.shm
JkLogLevel info
JkLogStampFormat "[%a%b%d%H:%M:%S%Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w%V%T"
JkMount /servlet/* ajp13
JkMount /*.jsp ajp13
JkMount /*.do ajp13
workers.properties内容:
workers.tomcat_home=/soft/server/tomcat
workers.java_home=/soft/server/java
ps=/
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1