一次LINUX测验
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一次LINUX测验相关的知识,希望对你有一定的参考价值。
一次LINUX测验
首次写linux文章,如有不足,还望读者不吝赐教!
一、1.在安装好的Linux系统中新建一个逻辑卷,mail原始大小为500M ,然后为其扩容100M 。
[[email protected] ~]#pvcreate /dev/sdb2
[[email protected] ~]#fdisk /dev/sdb2
[[email protected] ~]mkfs.ext3 /dev/sdb2
[[email protected] ~]#pvcreate /dev/sdb2
[[email protected] ~]#vgcreate vg0 /dev/sdb2
[[email protected] ~]#lvcreate -L 500M -n mail vg0
创建lvm大小为500M,名称为mail,从vg0中调容量
[[email protected] ~]# lvextend -L +100M /dev/vg0/mail
Size of logical volume vg0/lv0 changed from 100M (20480 extents) to 600M (28160 extents). 添加成功
Logical volume lv0 successfully resized.## 创建成功
二、在安装好的Linux系统中安装apache服务器,硬且搭建基于域名的虚拟主机服务,提供两个站点。
安装apache
卸载httpd软件及相关软件包
[[email protected] ~]#rpm -e httpd httpd-manual webalizer subversion mod_python mod_ssl mod_perl system-config-httpd php php-cli php-ldap php-common mysql dovecot --nodeps
解压软件包
[[email protected] ~]#tar zxvf httpd-2.4.25.tar.gz -C /opt/
[[email protected] ~]# tar -zxvf apr-1.5.2.tar.gz -C /opt/
[[email protected] ~]#tar -zxvf apr-util-1.5.4.tar.gz -C /opt/
[[email protected] ~]#cp -r apr-1.5.2/ httpd-2.4.25/srclib/apr
[[email protected] ~]#cp -r apr-util-1.5.4/ httpd-2.4.25/srclib/apr-util
源码编译安装Apache
[[email protected] ~]# cd /opt/httpd-2.4.25/
[[email protected] ~]# ./configure \
--prefix=/usr/local/apache \
--enable-so \
--enable-rewrite \
--enable-mods-shared=most \
--with-mpm=worker \
--disable-cgid \
--disable-cgi
[[email protected]linuxidc 63 httpd-2.4.25]# make -j 4
编译,将编译程序变为可执行程序
[[email protected]linuxidc 63 httpd-2.4.25]# make install 安装
[[email protected]linuxidc63 httpd-2.4.25]# vim /etc/init.d/httpd
#!/bin/sh
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server.
[[email protected]linuxidc63 httpd-2.4.25]# chmod +x /etc/init.d/httpd
-s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
[[email protected]linuxidc63 httpd-2.4.25]# service iptables stop
基于域名的虚拟主机
[[email protected]linuxidc63 conf.d]# mkdir /opt/accp [[email protected]linuxidc63 conf.d]# mkdir /opt/benet
[[email protected]linuxidc63 conf.d]# echo "<h1>welcome accp<h1>" > /opt/accp/index.html
[[email protected]linuxidc63 conf.d]# echo "<h1>welcome benet<h1>" > /opt/benet/index.html
[[email protected]linuxidc63 conf.d]# service httpd restart
[[email protected]linuxidc63 conf.d]# service iptables stop 关闭防火墙
[[email protected]linuxidc63 conf.d]# vim vhost.conf
Listen 192.168.80.193:8080
<VirtualHost 192.168.80.193:8080>
DocumentRoot /opt/accp/
ServerName www.accp.com
ErrorLog logs/accp.com-error_log
CustomLog logs/accp.com-access_log common
</VirtualHost>
<Directory "/opt/accp">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
<VirtualHost 192.168.80.193:80>
ServerAdmin [email protected]
DocumentRoot /opt/benet/
ServerName www.benet.com
ErrorLog logs/benet.com-error_log
CustomLog logs/benet.com-access_log common
</VirtualHost>
<Directory "/opt/benet">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
三、配置FTP虚拟用户功能,使TOM用户可以上传下载,下载速度限制为500K,而JACK用户只能下载,速度为300K。
安装
[[email protected] ~]# rpm -ivh /mnt/Packages/vsftpd-2.2.2-6.el6_0.1.x86_64.rpm
[[email protected] ~]# rpm -ivh /mnt/Packages/lftp-4.0.9-1.el6.x86_64.rpm3
[[email protected] ~]# service vsftpd restart
[[email protected] ~]#chkconfig vsftpd on
[[email protected] ~]# netstat -antup | grep ftp
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 11725/vsftpd
[[email protected]]#vim /etc/vsftpd/vsftpd_virtualuser.txt
Tom
888888
Jack
888888
此文件格式要示奇数行用户名、偶数行密码
[[email protected]linuxidc63 ~]# rpm -ivh /mnt/Packages/db4-utils-4.7.25-18.el6_4.x86_64.rpm
[[email protected]linuxidc63 ~]# db_load -T -t hash -f /etc/vsftpd/vsftpd_virtualuser.txt /etc/vsftpd/vsftpd_virtualuser.db
[[email protected] ~]# vim /etc/pam.d/vsftpd
auth required/lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_virtualuser
accountrequired/lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_virtualuser
[[email protected] vsftpd]# useradd -d /var/ftp/jack ftpuser
[[email protected] vsftpd]# useradd -d /var/ftp/tom ftpvip
[[email protected] vsftpd]# chmod -R 300 /var/ftp/jack/ 只允许下载
[[email protected] vsftpd]# chmod -R 500 /var/ftp/tom/ 允许上传和下载
建立虚拟配置
[[email protected]~]# grep vuserconfig /etc/vsftpd/vsftpd.conf
user_config_dir=/etc/vsftpd/vuserconfig
[[email protected] ~]# mkdir /etc/vsftpd/vuserconfig
[[email protected] ~]# touch /etc/vsftpd/vuserconfig/tom
[[email protected] ~]# touch /etc/vsftpd/vuserconfig/jack
[[email protected] ~]#vim /etc/vsftpd/vuserconfig/jack
guest_enable=yes 开启虚拟帐号登录
anon_max_rate=300000 限定传输速率为300k/s
#对于虚拟用户默认就是可以下载的默认是不能上传的
[[email protected] ~]#vim /etc/vsftpd/vuserconfig/tom
write_enable=yes
anon_mkdir_write_enable=yes
anon_upload_enable=yes 允许虚拟用户上传
anon_max_rate=500000
anon_other_write_enable=YES
重启vsftpd 使配置生效
[[email protected] ~]# service vsftpd restart
[
本文出自 “若★影” 博客,请务必保留此出处http://denglu.blog.51cto.com/10144045/1933881
以上是关于一次LINUX测验的主要内容,如果未能解决你的问题,请参考以下文章
ruby 这是测验1。我只通过哈希部分制作了它。也不能让我的数组只打印一次。