Linux基本命令+环境搭建(FTP、lamp、wordpress)(20190617)

(一)基本操作题

1、在系统中以自己名字首字母创建账号,该账号密码为123456,该账号所属组为hehe;创建hehecici账号,该账号密码为123456。

2、在/root/hehe/haha目录下创建文件a和b,a文件内容为aaaaa,b文件内容为bbbbb,其中a的所有者和所属组为root:hehe,b的所有者和所属组为自己名字首字母账号:hehe;

3、a文件所有者可读、可写、不可执行,所属组不可读、可写、可执行,其他人不可读、不可写、可执行

4、b文件所有人不可读、不可写、不可执行。

5、复制b文件,复制后的文件名为c。

------------------------------
useradd fhl
echo "123456" |passwd --stdin fhl
groupadd hehe
usermod -g hehe fhl
useradd hehecici
echo "123456" |passwd --stdin hehecici
mkdir -p /root/hehe/haha
cd /root/hehe/haha/
echo aaaaa > a
echo bbbbb > b
chown root:hehe a
chown fhl:hehe b
chmod u=rw,g=wx,o= a
chmod 000 b
cp b c
----------------



(二)环境搭建
systemctl stop firewalld.service
setenforce 0
先关闭防火墙

1、安装ftp,设置共享目录为/root/hehe/haha,要求hehecici账号能够上传下载文件,自己名字首字母账号只能上传,不能下载。

-----------------------------
(先得搞定本地账户)
systemctl stop firewalld.service
setenforce 0
yum -y install vsftpd
service vsftpd start
useradd  -s /sbin/nologin -d /root/hehe/haha uftp

passwd uftp (123456)//手动改密码
vim /etc/pam.d/vsftpd    //修改后本地用户就不能访问了
//先注释原来的,然后添加后边两行
auth       required    /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_passwd
account    required    /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_passwd

echo hehecici >> /etc/vsftpd/vuser_passwd.txt
echo 123456 >> /etc/vsftpd/vuser_passwd.txt
echo fhl >> /etc/vsftpd/vuser_passwd.txt
echo 123456 >> /etc/vsftpd/vuser_passwd.txt
cd /etc/vsftpd/
db_load -T -t hash -f vuser_passwd.txt vuser_passwd.db
mkdir vuser_conf
cd vuser_conf/

vim fhl
local_root=/root/hehe/haha
anon_umask=022
write_enable=YES
anon_upload_enable=YES
anon_world_readable_only=NO
download_enable=NO

vim hehecici
local_root=/root/hehe/haha
write_enable=YES
anon_umask=022
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES

vim /etc/vsftpd/vsftpd.conf
guest_enable=YES
guest_username=uftp
user_config_dir=/etc/vsftpd/vuser_conf
allow_writeable_chroot=YES

cd /root/hehe/
chown -R uftp:uftp haha/
chmod -R 775 haha/
service vsftpd restart

//使用centos的ftp工具演示
ftp IP.~~~~
put
get

-----------------------------

2、安装lamp环境,安装discuz、ecshop、wordpress,并能够通过IP进行访问
yum -y install httpd

#安装mysql
vim /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.1/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1


rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
yum -y install MariaDB-server MariaDB-client
systemctl start mariadb
mysql_secure_installation    #命令进行配置(先退出数据库),设置完root密码,一路回车
mysql -uroot -proot
use mysql;
grant all privileges on *.* to 'root'@'%' identified by 'root';
flush privileges;

#可以先删除原来的mysql
rpm -qa | grep MariaDB
rpm -e --nodeps MariaDB-*
rpm -qa | grep mysql
yum remove mysql mysql-server mysql-libs compat-mysql51

----------------------------
下边是另一种方法,网速可能不好
----------------------------
wget mirrors.ustc.edu.cn/mysql-repo/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum makecache
yum -y install mysql-community-client.x86_64 mysql-community-common.x86_64 mysql-community-devel.x86_64 mysql-community-libs.x86_64 mysql-community-server.x86_64
service mysqld start
mysqladmin -u root password "root"
mysql -uroot -p root
use mysql;
grant all privileges on *.* to 'root'@'%' identified by 'root';
flush privileges;
-------------------------------
源码安装php7

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum makecache
yum -y install php70w* --skip-broken
service httpd restart
php -v

-----------------------
安装wordpress,或者其它两个类似,最好先下载好安装包
wget https://wordpress.org/latest.tar.gz

直接解压访问安装就行(有个坑,要先创建那个数据库)


------------------
smb 权限设置 (配置文件位置:/etc/samba/smb.conf)
安装samba,设置共享目录为/root/hehe/haha,要求hehecici账号能够上传下载文件,自己名字首字母账号只能上传,不能下载

yum -y install samba
systemctl start smb

vim /etc/samba/smb.conf #配置文件

[haha]
  path = /root/hehe/haha
  valid users=hehecici,fhl
  writable=yes
  write list =hehecici,fhl



#为系统用户添加为smb用户
#Samba用户的密码与系统用户的密码没有任何关系
smbpasswd -a lc
smbpasswd -a hehecici
pdbedit -L     #显示目前系统中已经存在的所有Samba用户

cd /root/hehe/
chown -R hehecici haha/
chmod -R 755 /root

systemctl restart smb

smb访问测试
yum -y install samba-client
smbclient -L IP //列出所有共享目录
smbclient //127.0.0.1/haha -U hehecici%123456

get

put

转载于:https://www.cnblogs.com/wintrysec/p/11039539.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值