`

小型网站上线全纪录

阅读更多

一个小网站用java开发,struts2+jdbc结构,数据库为mysql。

服务器为4cpu,4G内存,500G硬盘,redhat5.4,64位操作系统,yum的源是服务器提供商配置好的。

首先,要安装securecrt,远程访问服务器,6.5破解版最好找。

在根目录下建一个文件夹,作为工作目录。

目前采用nginx+多resin搭建服务器环境,缓存服务varnish以后再说。

1,下载并安装nginx,需要先装好gcc,openssl-devel,pcre-devel,zlib-devel,我发现这些软件在光盘里都有。直接安装

    现在http://nginx.org/en/download.html这个页面里下载RHEL包,它的用途是设置yum软件源,然后yum install nginx就安装好了,安装好后的启动命令/usr/sbin/nginx,停止命令:killall -9 resin

2,安装jdk,这个服务器上的jdk版本太低1.4,而且不是oracle的,所以去oracle下载jdk

http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u31-download-1501634.html

下载rmp.bin的版本,直接./***.bin就可以安装,装好之后find / -name "jdk"看一下安装目录,然后配置java环境变量:

 

export JAVA_HOME=/usr/java/jdk1.6.0_31

export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

装好之后,java -version查看是否安装成功。

3,安装mysql,光盘里有mysql,mysql-server等一些包,安装命令:yum install mysql-server,它会自动解析包之间的依赖关系,然后把其他几个包也安装好,(卸载包得命令rpm -e mysql --allmatches)

    mysql装好之后登录会报错:

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

参考(http://lectery.iteye.com/blog/279061

查看 /etc/rc.d/init.d/mysqld status 看看mysql是否已经启动.

其结果可能是mysqld 已死,但是 subsys 被锁

那么需要做下面的步骤:

(参考http://hi.baidu.com/ttop100/blog/item/7765233ee6f8e53871cf6c0d.html

 

 写道
1. Obviously the 'ole check the log file for anything nasty

cat /var/log/mysqld.log

2. Stop the service

service mysqld stop

3. Check to see if the service stopped, it might be calling the wrong pid.

ps aux | grep mysql

4. Kill any mysql process that might still be running.

kill -9 ??? ???

5. (*CAREFUL*) Remove/move/backup any databases from the data directory, only do this step if you need to.

rm -Rf /var/lib/mysql/*

6. Check your global options configuration file, should be similar to stevanbt's initial post.

cat /etc/my.cnf

7. Copy over one of the preconfigured 'sample' server-specific options file. Global (/etc/my.cnf) file has priority over server-specific file, but these have more options in them and have been tuned for a certain role.

cp /usr/share/doc/mysql-server-?.??.??/my-small.cnf /var/lib/mysql

8. Recreate the initial databases, this step is optional as the initscripts will do this anyway.

mysql_install_db

9. Check and set the runlevels for the service.

chkconfig --level 345 mysqld on
chkconfig --list mysqld

10. Start the service.

service mysqld start

11. Check the log file (step 1)

Thats just a basic step through check, most of you have probably already done this.

其实做到step 9问题都已经解决了
 

然后,可以mysql无密码登录了,设置root密码:

(参考http://www.west263.com/info/html/caozuoxitong/FreeBSD/20090513/132914.html

mysqladmin -u root password "123456"

设置允许root远程登录:

(参考http://www.cnblogs.com/cnblogsfans/archive/2009/09/21/1570942.html

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

4,安装resin,下载Resin 3.1.12  tgx,pro版本好像不是免费的,pro版本自带多进程负载均衡功能

http://www.caucho.com/download/

把它放在工作目录下,解压,进到resin目录,./configure make make install,就装好了,停止启动命令sh bin/httpd.sh stop/start,在bin/httpd.sh文件中设置resin和java目录:

 

export JAVA_HOME=/usr/java/jdk1.6.0_31

export RESIN_HOME=/ck/bak/resin-3.1.12

停止resin,还可以killall -9 perl; killall -9 java;

设置resin中web程序的默认根目录,默认为webapps/ROOT,可以修改ROOT为想要的值;将已经编译好的程序(我用的tomcat在本地机上开发,所以直接将tomcat下webapps目录下的文件夹打包上传到服务器即可)放在webapps目录下,并把文件夹名字修改为设置好的值即可用默认根目录访问,http://127.0.0.1:8080/。

5,设置nginx+resin负载均衡设置

(参考

http://blog.chinaunix.net/uid-8504518-id-2030651.html

http://hi.baidu.com/apparitor/blog/item/6a25f339bf11d531b8998f02.html

http://blog.csdn.net/wangwenhui11/article/details/3594160

http://visonguo.blog.51cto.com/510379/457599

http://www.codesky.net/article/200911/118600.html

http://blog.163.com/windy_dcm/blog/static/199893462010112411270190/

 

)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics