今天开始用源码安装mysql,首先需要下载mysql的源码文件,然后解压,进入到解压后的目录
安装MySQL源码分发版的基本命令是:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &
mysql安装是依赖包ncurses,所以安装mysql前必须要要安装这个,否则会报错,大概信息是:
configure: error: No curses/termcap library found
解决的办法就是到如下地址http://ftp.gnu.org/pub/gnu/ncurses/,选择最新源码,然后解压执行./configure, make , make install安装完毕,安装ncurses不要设置prefix参数,否则可能出现不能正确查找到的情况。
注意:在make时,需要很长的时间,我用了大概半个小时
以下命令的工作目录都是基于/usr/local/mysql,请注意。
启动命令:
sudo bin/mysqld_safe --user=mysql &
停止命令:
sudo bin/mysqladmin shutdown
查看mysql版本:
sudo bin/mysqladmin version
查看mysql的状态:
sudo bin/mysqladmin pin
今天晚上安装了ftp服务程序,我们选择proftp,首先源码下载到windows,网站http://www.proftpd.org/, 我下载的软件包为proftpd-1.3.3c.tar.gz,接下来通过昨天的方法,利用xshell把windows的源码包传到linux上,源码安装需要gcc支持,请确认系统已经安装gcc编译器,接下来具体操作步骤:
$sftp username@ip
$>put local_file remote_dir #(> put D:proftpd-1.3.3c.tar.gz /home/software/)
$>quit
$ssh username@ip
$cd /home/software
$tar -xzvf /home/software/proftpd-1.3.3c.tar.gz -C /home/lib
$cd /home/lib/proftpd-1.3.3c
$sudo ./configure --prefix=/usr/local/proftp
$sudo make
$sudo make install
接下来修改/usr/local/proftp/etc/proftpd.conf
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "ProFTPD Default Installation"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Don't use IPv6 support by default.
UseIPv6 off
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30
# Set the user and group under which the server will run.
User nobody
Group nogroup
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~
# Normally, we want files to be overwriteable.
AllowOverwrite on
SystemLog /usr/local/proftp/log/proftpd.log
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
DenyAll
</Limit>
# A basic anonymous configuration, no upload directories. If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
<Anonymous ~ftp>
User ftp
Group ftp
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
# Limit the maximum number of anonymous logins
MaxClients 10
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayChdir .message
# Limit WRITE everywhere in the anonymous chroot
<Limit WRITE>
DenyAll
</Limit>
</Anonymous>
# user access config file path
AuthUserFile /usr/local/lib/proftp/etc/passwd
# change the auth file order
AuthOrder mod_auth_file.c mod_auth_unix.c
配置文件中我们已经配置权限验证通过文件方式。接下来我们参照http://www.proftpd.org/docs/contrib/ftpasswd.html来配置添加ftp用户。我们用到也就是
ftpasswd --passwd --name=bob--uid=1001 --file=/usr/local/lib/proftp/etc/passwd --home=/home/bob --shell=/bin/false
会提示你输入密码,输入密码后就会生成一个用户密码配置文件,路径如下: /usr/local/lib/proftp/etc/passwd,如果你不知道怎么获取uid,那么请用下面的命令查看,那个显示的数字就是了
id nobody
现在如果你启动proftp可能出现总是登录不上的情况,解决办法就是在/etc/shells 添加一行 /bin/false
最后启动你的proftp,
$sudo /usr/local/lib/proftp/sbin/proftpd
那么整个ftp就成功了,如果发生错误请查看日志文件,路径我们配置文件中也配置了 /usr/local/proftp/log/proftpd.log
如果是端口占用,请用下面命令查看是什么进程占用了
$sudo netstat -pant
查到占用21端口的进程,你可以kill,还可以更改配置文件的端口来解决这个问题。
如果你的proftp不是系统service,怎么停掉呢,方法很简单
$ps aux|grep "proftpd"
$kill id
那个/usr/local/proftp/sbin/ftpshut 命令是不能完全停止进程的,会一直占用21端口,这种停止只能让ftp用户没有办法登录。
以前搞过Linux server,但是因为工作开发比较忙,有很长一段时间没有练习了,很多东西开始淡忘,温故而知新,所以决定重新操作一边,随便做一下笔记,以便以后使用。
下载好iso文件,在windows下使用虚拟化软件virtualbox(免费开源)安装Ubuntu Server.安装时到最后的软件选择时,因为要从头做起,不用系统做好的LAMP,Tomcat server软件包,如果用系统软件包,那就达不到练习的目的了。我只选择了OpenSSH server,因为要其他的机器传输文件到服务器上,必须有一个连接方式能够支持,那么ssh就是最好的方法。Ftp server 我们后面搭建,现在系统就只有ssh了。如果你通过网络的话也可以通过wdget来做,但是我不喜欢用server去下载东西。
接下来介绍一下SSH怎么传输文件,我的是从windows xp到Ubuntu server传输文件。windows下可以使用Xshell命令终端软件,命令使用sftp.
> sftp username@ip port
> help
bye finish your SFTP session
cd change your remote working directory
clear clear screen
exit finish your SFTP session
explore explore your local directory
get download a file from the server to your local machine
help give help
lcd change and/or print local working directory
lls list contents of a local directory
lpwd print your local working directory
ls list contents of a remote directory
mkdir create a directory on the remote server
mv move or rename a file on the remote server
put upload a file from your local machine to the server
pwd print your remote working directory
quit finish your SFTP session
rename move or rename a file on the remote server
rm delete a file
rmdir remove a directory on the remote server
当然你也可以选择SCP命令作为你的传输命令:scp 命令是 SSH 中非常有用的命令,在两台服务器之间直接传送文件,仅仅用 scp 一个命令就完全解决了。 你可以在一台服务器上 以 root 身份运行 #scp servername:/home/ftp/pub/file1 . 这样就把另一台服务器上的文件 /home/ftp/pub/file1 直接传到本机器的当前目录下,当然你也可以用 #scp /tmp/file2 servername:/boot 把本机上的文件 /tmp/file2 送到另一台机器的 /boot 目录下。而且整个传送过程仍然是用 SSH 加密的。在windows下需要安装一个软件Winscp就可以了。
通过sftp传输文件到服务器上,是一个非常好的windows和linux通信的方法。当然你也可以用scp,如果是linux到linux推荐scp方法传输。
天很晚了。呵呵,困死了,睡觉了,今晚收工了。^_^