当前位置:Gxlcms > 数据库问题 > Linux中LAMP实现、SQL语句及FTP与Samba服务配置

Linux中LAMP实现、SQL语句及FTP与Samba服务配置

时间:2021-07-01 10:21:17 帮助过:4人阅读

  • 1、 搭建php-fpm工作方式的LAMP环境,实现wordpress正常访问

    Mysql服务的搭建

    1. <code>[root@xiaochen ~]# yum -y install mariadb-server.x86_64
    2. [root@xiaochen ~]# cat /etc/my.cnf.d/server.cnf
    3. #
    4. # These groups are read by MariaDB server.
    5. # Use it for options that only the server (but not clients) should see
    6. #
    7. # See the examples of server my.cnf files in /usr/share/mysql/
    8. #
    9. # this is read by the standalone daemon and embedded servers
    10. [server]
    11. # this is only for the mysqld standalone daemon
    12. [mysqld]
    13. # this is only for embedded server
    14. [embedded]
    15. skip_name_resove=NO
    16. innodb_file_per_table=NO
    17. # This group is only read by MariaDB-5.5 servers.
    18. # If you use the same .cnf file for MariaDB of different versions,
    19. # use this group for options that older servers don‘t understand
    20. [mysqld-5.5]
    21. # These two groups are only read by MariaDB servers, not by MySQL.
    22. # If you use the same .cnf file for MySQL and MariaDB,
    23. # you can put MariaDB-only options here
    24. [mariadb]
    25. [mariadb-5.5]
    26. [root@xiaochen ~]# systemctl start mariadb.service
    27. [root@xiaochen ~]# ss -tnl
    28. State Recv-Q Send-Q Local Address:Port Peer Address:Port
    29. LISTEN 0 128 *:22 *:*
    30. LISTEN 0 100 127.0.0.1:25 *:*
    31. LISTEN 0 128 192.168.10.10:9000 *:*
    32. LISTEN 0 50 *:3306 *:*
    33. LISTEN 0 128 :::8080 :::*
    34. LISTEN 0 128 :::80 :::*
    35. LISTEN 0 128 :::22 :::*
    36. LISTEN 0 100 ::1:25
    37. [root@xiaochen ~]# mysql_secure_installation
    38. [root@xiaochen ~]# mysql -uroot -p123456
    39. MariaDB [(none)]> create database wordpress;
    40. MariaDB [(none)]> GRANT ALL ON *.* to ‘wordpress‘@‘192.168.10.10‘ IDENTIFIED BY ‘123456‘;
    41. MariaDB [(none)]> GRANT ALL ON wordpress.* TO ‘wpuser‘@‘192.168.10.10‘ IDENTIFIED BY ‘123456‘;
    42. MariaDB [(none)]> FLUSH PRIVILEGES;</code>

    Php-fpm服务器的搭建

    1. <code>[root@xiaochen ~]# yum install -y php-mysql.x86_64 php-fpm php-mbstring
    2. [root@xiaochen ~]# vi /etc/php-fpm.d/www.conf #修改相关参数
    3. [root@xiaochen ~]# mkdir -pv /var/lib/php/session
    4. [root@xiaochen ~]# chown apache:apache /var/lib/php/session/
    5. [root@xiaochen ~]# systemctl start php-fpm.service
    6. [root@xiaochen ~]# ss -tnl
    7. State Recv-Q Send-Q Local Address:Port Peer Address:Port
    8. LISTEN 0 128 *:22 *:*
    9. LISTEN 0 100 127.0.0.1:25 *:*
    10. LISTEN 0 128 192.168.10.10:9000 *:*
    11. LISTEN 0 50 *:3306 *:*
    12. LISTEN 0 128 :::8080 :::*
    13. LISTEN 0 128 :::80 :::*
    14. LISTEN 0 128 :::22 :::*
    15. LISTEN 0 100 ::1:25 </code>

    搭建httpd服务

    1. <code>[root@xiaochen ~]# yum -y install httpd
    2. [root@xiaochen ~]# httpd -M | grep fcgi
    3. proxy_fcgi_module (shared)
    4. [root@xiaochen ~]# cat /etc/httpd/conf.d/fcgi.conf
    5. Listen 8080
    6. <VirtualHost *:8080>
    7. DirectoryIndex index.php
    8. ServerName www.xiaochen.com
    9. DocumentRoot /var/www/html
    10. ProxyRequests off
    11. ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.10.10:9000/var/www/html/$1
    12. ProxyPassMatch ^/(ping|pmstatus)$ fcgi://192.168.10.10:9000/$1
    13. <Directory "/var/www/html">
    14. options none
    15. Allowoverride None
    16. Require all granted
    17. </Directory>
    18. </VirtualHost></code>

    创建测试文件

    1. <code>[root@xiaochen ~]# cat /var/www/html/index.php
    2. <?php
    3. phpinfo();
    4. ?>
    5. [root@xiaochen ~]# cat /var/www/html/mysql.php
    6. <?php
    7. $conn = mysql_connect(‘192.168.10.10‘,‘wordpress‘,‘123456‘);
    8. if ($conn)
    9. echo "Connected to mysql.";
    10. else
    11. echo "Fail";
    12. ?></code>

    测试访问页面
    技术分享图片

    搭建wordpress

    1. <code>[root@xiaochen ~]# unzip wordpress-4.9.4-zh_CN.zip -d /var/www/html/</code>

    访问页面
    技术分享图片
    技术分享图片
    技术分享图片
    技术分享图片
    技术分享图片
    技术分享图片

    • 2、什么是DML?常用SQL举例,每个命令至少1个例子,最多不超过3个例子

      DDL(Data Definition Language)是mysql数据库服务器端命令的一种语言类型,表示数据定义语言,主要用于管理数据库组件,例如数据库,表,索引,视图,用户,存储过程等;常用命令有CREATE,ALTER,DROP等;

    • CREATE(创建)
      CREATE DATABASE 创建数据库
      CREATE TABLE 创建表
      CREATE USER 创建用户
    1. <code>MariaDB [(none)]> CREATE DATABASE test;
    2. Query OK, 1 row affected (0.01 sec)
    3. MariaDB [(none)]> use test;
    4. Database changed
    5. MariaDB [test]> CREATE TABLE users (id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(60) NOT NULL);
    6. Query OK, 0 rows affected (0.11 sec)</code>
    • SHOW(查看)
      SHOW CREATE DATABASE 查看创建的数据库
      SHOW CREATE TABLE 查看创建的表
      1. <code>MariaDB [(none)]> show databases;
      2. +--------------------+
      3. | Database |
      4. +--------------------+
      5. | information_schema |
      6. | mysql |
      7. | performance_schema |
      8. | test |
      9. | wordpress |
      10. +--------------------+
      11. 5 rows in set (0.00 sec)
      12. MariaDB [wordpress]> show tables;
      13. +-----------------------+
      14. | Tables_in_wordpress |
      15. +-----------------------+
      16. | wp_commentmeta |
      17. | wp_comments |
      18. | wp_links |
      19. | wp_options |
      20. | wp_postmeta |
      21. | wp_posts |
      22. | wp_term_relationships |
      23. | wp_term_taxonomy |
      24. | wp_termmeta |
      25. | wp_terms |
      26. | wp_usermeta |
      27. | wp_users |
      28. +-----------------------+
      29. 12 rows in set (0.00 sec)</code>
    • ALTER(修改)
      ALTER DATABASE 修改数据库
      ALTER TABLE 修改表
      1. <code>MariaDB [(none)]> ALTER DATABASE test CHARACTER SET ‘utf8‘;
      2. Query OK, 1 row affected (0.00 sec)
      3. MariaDB [test]> DESC users;
      4. +-------+---------------------+------+-----+---------+----------------+
      5. | Field | Type | Null | Key | Default | Extra |
      6. +-------+---------------------+------+-----+---------+----------------+
      7. | id | tinyint(3) unsigned | NO | PRI | NULL | auto_increment |
      8. | name | varchar(60) | NO | | NULL | |
      9. +-------+---------------------+------+-----+---------+----------------+
      10. 2 rows in set (0.00 sec)</code>
    • DROP(删除)
      DROP DATABASE 删除数据库
      DROP TABLE 删除表
      DROP USER 删除用户

      1. <code>MariaDB [(none)]> DROP DATABASE test;
      2. Query OK, 1 row affected (0.01 sec)
      3. MariaDB [(none)]> show databases;
      4. +--------------------+
      5. | Database |
      6. +--------------------+
      7. | information_schema |
      8. | mysql |
      9. | performance_schema |
      10. | wordpress |
      11. +--------------------+
      12. 4 rows in set (0.00 sec)</code>

      DML(Data Manipulation Language)是mysql数据库服务器端命令的一种语言类型,表示数据操纵语言,主要用于管理表中的数据,实现数据的增删改查等功能,常用命令有INSERT,DELETE,UPDATE,SELECT等;

    • INSERT(增)
      INSERT INTO
      INSERT [INTO] tbl_name[(col1,..)]{VALUES|VALUE}(val1,..),(...),..
    1. <code>MariaDB [TEST]> INSERT INTO tbl1(name,gender) VALUES(‘xiaohua‘,‘M‘),(‘Ding Dian‘,‘F‘);
    2. Query OK, 2 rows affected (0.01 sec)
    3. Records: 2 Duplicates: 0 Warnings: 0
    4. MariaDB [TEST]> select * from tbl1;
    5. +----+--------+-----------+
    6. | id | gender | name |
    7. +----+--------+-----------+
    8. | 1 | M | xiaohua |
    9. | 2 | F | Ding Dian |
    10. +----+--------+-----------+
    11. 2 rows in set (0.00 sec)</code>
    • SELECT(查)
      SELECT * FROM table_name
      1. <code>MariaDB [TEST]> select * from tbl1;
      2. +----+--------+-----------+
      3. | id | gender | name |
      4. +----+--------+-----------+
      5. | 1 | M | xiaohua |
      6. | 2 | F | Ding Dian |
      7. +----+--------+-----------+
      8. 2 rows in set (0.00 sec)</code>
    • DELETE(删)
      DELETE FROM table_name [WHERE where_condition]{ORDER BY ...}[LIMIT ROW_COUNT]
      1. <code>MariaDB [TEST]> DELETE FROM tbl1 WHERE id=2
      2. -> ;
      3. Query OK, 1 row affected (0.00 sec)</code>
    • UPDATE(改)
      UPDATE [LOW_PRIORITY] [IGNORE] table_reference SET col_name1=value1 [, col_name2=value2] ... [WHERE where_condition] [ORDER BY ...] [LIMIT row_count]
      1. <code>MariaDB [TEST]> UPDATE tbl1 SET gender=‘F‘ WHERE id=3;
      2. Query OK, 1 row affected (0.00 sec)
      3. Rows matched: 1 Changed: 1 Warnings: 0</code>
    • 3、简述ftp的主动和被动模式,并实现基于pam认证的vsftpd

    主动模式
    数据传输连接由服务器主动创建,客户端先随机一个端口N,用这端口连接服务器的21端口来完成命令的连接的建立,之后服务器以TCP的20端口主动连接客户端的N+1端口来进行数据传输连接,如下图所示:
    技术分享图片

    被动模式:
    数据传输连接由客户端的某个随机端口去连接服务器的某个端口,命令连接的方式与主动连接方式一致,完成连接之后服务器会告诉客户端连接的端口M,于是客户端的N+1端口连接服务器的M端口来进行数据传输的连接,如下图所示:
    技术分享图片

    Pam认证配置:

    1. <code>[root@xiaochen ~]# yum -y install vsftpd
    2. [root@xiaochen ~]# rpm -ql pam | grep so
    3. /etc/security/console.apps
    4. /etc/security/console.handlers
    5. /etc/security/console.perms
    6. /etc/security/console.perms.d
    7. /usr/lib64/libpam.so.0
    8. /usr/lib64/libpam.so.0.83.1
    9. /usr/lib64/libpam_misc.so.0
    10. /usr/lib64/libpam_misc.so.0.82.0
    11. /usr/lib64/libpamc.so.0
    12. /usr/lib64/libpamc.so.0.82.1
    13. /usr/lib64/security/pam_access.so
    14. /usr/lib64/security/pam_chroot.so
    15. /usr/lib64/security/pam_console.so
    16. /usr/lib64/security/pam_cracklib.so
    17. /usr/lib64/security/pam_debug.so
    18. /usr/lib64/security/pam_deny.so
    19. /usr/lib64/security/pam_echo.so
    20. /usr/lib64/security/pam_env.so
    21. /usr/lib64/security/pam_exec.so
    22. /usr/lib64/security/pam_faildelay.so
    23. /usr/lib64/security/pam_faillock.so
    24. /usr/lib64/security/pam_filter.so
    25. /usr/lib64/security/pam_ftp.so
    26. /usr/lib64/security/pam_group.so
    27. /usr/lib64/security/pam_issue.so
    28. /usr/lib64/security/pam_keyinit.so
    29. /usr/lib64/security/pam_lastlog.so
    30. /usr/lib64/security/pam_limits.so
    31. /usr/lib64/security/pam_listfile.so
    32. /usr/lib64/security/pam_localuser.so
    33. /usr/lib64/security/pam_loginuid.so
    34. /usr/lib64/security/pam_mail.so
    35. /usr/lib64/security/pam_mkhomedir.so
    36. /usr/lib64/security/pam_motd.so
    37. /usr/lib64/security/pam_namespace.so
    38. /usr/lib64/security/pam_nologin.so
    39. /usr/lib64/security/pam_permit.so
    40. /usr/lib64/security/pam_postgresok.so
    41. /usr/lib64/security/pam_pwhistory.so
    42. /usr/lib64/security/pam_rhosts.so
    43. /usr/lib64/security/pam_rootok.so
    44. /usr/lib64/security/pam_securetty.so
    45. /usr/lib64/security/pam_selinux.so
    46. /usr/lib64/security/pam_selinux_permit.so
    47. /usr/lib64/security/pam_sepermit.so
    48. /usr/lib64/security/pam_shells.so
    49. /usr/lib64/security/pam_stress.so
    50. /usr/lib64/security/pam_succeed_if.so
    51. /usr/lib64/security/pam_tally2.so
    52. /usr/lib64/security/pam_time.so
    53. /usr/lib64/security/pam_timestamp.so
    54. /usr/lib64/security/pam_tty_audit.so
    55. /usr/lib64/security/pam_umask.so
    56. /usr/lib64/security/pam_unix.so
    57. /usr/lib64/security/pam_unix_acct.so
    58. /usr/lib64/security/pam_unix_auth.so
    59. /usr/lib64/security/pam_unix_passwd.so
    60. /usr/lib64/security/pam_unix_session.so
    61. /usr/lib64/security/pam_userdb.so
    62. /usr/lib64/security/pam_warn.so
    63. /usr/lib64/security/pam_wheel.so
    64. /usr/lib64/security/pam_xauth.so
    65. /usr/sbin/pam_console_apply
    66. /usr/share/doc/pam-1.1.8/html/sag-see-also.html
    67. /usr/share/doc/pam-1.1.8/txts/README.pam_console
    68. /usr/share/doc/pam-1.1.8/txts/README.pam_postgresok
    69. /usr/share/man/man5/console.apps.5.gz
    70. /usr/share/man/man5/console.handlers.5.gz
    71. /usr/share/man/man5/console.perms.5.gz
    72. /usr/share/man/man8/pam_console.8.gz
    73. /usr/share/man/man8/pam_console_apply.8.gz
    74. /usr/share/man/man8/pam_postgresok.8.gz
    75. /var/run/console
    76. [root@xiaochen ~]# ls /etc/pam.d/
    77. chfn fingerprint-auth passwd postlogin runuser-l smtp.postfix sudo-i systemd-user
    78. chsh fingerprint-auth-ac password-auth postlogin-ac smartcard-auth sshd su-l vlock
    79. config-util login password-auth-ac remote smartcard-auth-ac su system-auth vmtoolsd
    80. crond other polkit-1 runuser smtp sudo system-auth-ac vsftpd
    81. [root@xiaochen ~]# vi /etc/vsftpd/vuser.list
    82. magedu1
    83. 123456
    84. magedu2
    85. 987654
    86. [root@xiaochen ~]# db_load -T -t hash -f /etc/vsftpd/vuser.list /etc/vsftpd/vuser.list.db
    87. [root@xiaochen ~]# chmod 600 /etc/vsftpd/vuser.*
    88. [root@xiaochen ~]# ll /etc/vsftpd/vuser.*
    89. -rw-------. 1 root root 30 Dec 4 13:08 /etc/vsftpd/vuser.list
    90. -rw-------. 1 root root 12288 Dec 4 13:09 /etc/vsftpd/vuser.list.db
    91. [root@xiaochen ~]# mkdir /var/ftproot
    92. [root@xiaochen ~]# useradd -d /var/ftproot/ -s /sbin/nologin virtual
    93. useradd: warning: the home directory already exists.
    94. Not copying any file from skel directory into it.
    95. [root@xiaochen ~]# chmod 755 /var/ftproot/
    96. [root@xiaochen ~]# vi /etc/pam.d/vsftpd
    97. #%PAM-1.0
    98. session optional pam_keyinit.so force revoke
    99. auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
    100. auth required pam_shells.so
    101. auth include password-auth
    102. account include password-auth
    103. session required pam_loginuid.so
    104. session include password-auth
    105. auth required pam_userdb.so db=/etc/vsftpd/vuser
    106. account required pam_userdb.so db=/etc/vsftpd/vuser
    107. [root@xiaochen ~]# vi /etc/vsftpd/vsftpd.conf
    108. anonymous_enable=NO
    109. pam_service_name=vsftpd
    110. userlist_enable=YES
    111. tcp_wrappers=YES
    112. guest_enable=YES
    113. guest_username=virtual
    114. pam_service_name=vsftpd
    115. virtual_use_local_privs=YES
    116. user_config_dir=/etc/vsftpd/vusers_dir
    117. tcp_wrappers=YES
    118. [root@xiaochen ~]# mkdir /etc/vsftpd/vusers_dir
    119. [root@xiaochen ~]# cd /etc/vsftpd/vusers_dir
    120. [root@xiaochen vusers_dir]# touch magedu1 magedu2
    121. [root@xiaochen vusers_dir]# vi magedu2
    122. anon_upload_enable=YES
    123. anon_mkdir_enable=YES
    124. [root@xiaochen vusers_dir]# systemctl restart vsftpd
    125. [root@xiaochen vusers_dir]# vi /etc/sysconfig/selinux
    126. [root@xiaochen vusers_dir]# setenforce 0
    127. [root@xiaochen vusers_dir]# getenforce
    128. Permissive
    129. [root@xiaochen vusers_dir]# systemctl stop firewalld
    130. ##最后测试
    131. [root@localhost ~]# lftp -u virtual 192.168.10.10
    132. Password:
    133. lftp virtual@192.168.10.10:~> </code>
    • 4、简述NFS服务原理及配置

      NFS (Network File System)即网络文件系统,它允许网络中的计算机通过TCP/IP网络共享资源。在NFS中,客户端可以透明读写服务器端上的文件,就像访问本地文件一样,通过挂载的方式将服务器的文件挂载到本地,如同本地磁盘一样。
      下图是NFS工作原理图
      技术分享图片
      NFS服务的配置:
      服务器端:

    1. <code>[root@xiaochen ~]# yum -y install nfs-utils.x86_64
    2. [root@xiaochen ~]# yum -y install rpcbind
    3. [root@xiaochen ~]# mkdir /tmp/test
    4. [root@xiaochen ~]# vi /etc/exports
    5. /tmp/test 192.168.10.20(rw,sync,no_root_squash) ##192.168.10.20是客户端地址
    6. [root@xiaochen ~]# systemctl start nfs rpcbind
    7. [root@xiaochen ~]# systemctl status nfs rpcbind
    8. ● nfs-server.service - NFS server and services
    9. Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
    10. Active: active (exited) since Tue 2018-12-04 13:49:34 CST; 8s ago
    11. Process: 4388 ExecStartPost=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl restart gssproxy ; fi (code=exited, status=0/SUCCESS)
    12. Process: 4371 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
    13. Process: 4370 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
    14. Main PID: 4371 (code=exited, status=0/SUCCESS)
    15. CGroup: /system.slice/nfs-server.service
    16. Dec 04 13:49:34 xiaochen systemd[1]: Starting NFS server and services...
    17. Dec 04 13:49:34 xiaochen systemd[1]: Started NFS server and services.
    18. ● rpcbind.service - RPC bind service
    19. Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; enabled; vendor preset: enabled)
    20. Active: active (running) since Tue 2018-12-04 13:49:33 CST; 9s ago
    21. Process: 4340 ExecStart=/sbin/rpcbind -w $RPCBIND_ARGS (code=exited, status=0/SUCCESS)
    22. Main PID: 4344 (rpcbind)
    23. CGroup: /system.slice/rpcbind.service
    24. └─4344 /sbin/rpcbind -w
    25. Dec 04 13:49:33 xiaochen systemd[1]: Starting RPC bind service...
    26. Dec 04 13:49:33 xiaochen systemd[1]: Started RPC bind service.
    27. 客户端:
    28. [root@localhost ~]# showmount -e 192.168.10.10
    29. Export list for 192.168.10.10:
    30. /tmp/test 192.168.10.20
    31. [root@localhost ~]# mkdir /tmp/test
    32. [root@localhost ~]# mount -t nfs 192.168.10.10:/tmp/test /tmp/test
    33. [root@localhost ~]# mount
    34. sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
    35. proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
    36. devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=490476k,nr_inodes=122619,mode=755)
    37. securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
    38. tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
    39. devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
    40. tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
    41. tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755)
    42. cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
    43. pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
    44. cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
    45. cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
    46. cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
    47. cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
    48. cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
    49. cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
    50. cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
    51. cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
    52. cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
    53. configfs on /sys/kernel/config type configfs (rw,relatime)
    54. /dev/mapper/centos-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
    55. selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
    56. mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
    57. hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
    58. debugfs on /sys/kernel/debug type debugfs (rw,relatime)
    59. /dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
    60. tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=100136k,mode=700)
    61. systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=29,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
    62. 192.168.10.10:/tmp/test on /tmp/test type nfs4 (rw,relatime,vers=4.1,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.10.20,local_lock=none,addr=192.168.10.10)
    63. [root@localhost ~]# cd /tmp/test
    64. [root@localhost test]# ls
    65. [root@localhost test]# vi nfs.txt
    66. this is a client nfs file
    67. ##在服务器端进行验证
    68. [root@xiaochen ~]# cd /tmp/test/
    69. [root@xiaochen test]# ls
    70. nfs.txt
    71. [root@xiaochen test]# cat nfs.txt
    72. this is a client nfs file</code>
    • 5、简述samba服务,并实现samba配置

      SMB(Server Messages Block)即服务信息块,是一种在局域网上共享文件和打印机的一种通信协议,它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务。SMB协议是客户机/服务器型协议,客户机通过该协议可以访问服务器上的共享文件系统、打印机及其他资源,例如在window和linux,windows和unix之间,可以使用samba服务器来解决二者传输问题

    Samba 配置

    1. <code>[root@xiaochen ~]# yum -y install samba
    2. [root@xiaochen ~]# vi /etc/samba/smb.conf
    3. [homes]
    4. comment = samba test dir
    5. path = /tmp/sambatest
    6. writeable = Yes
    7. create mask = 0600
    8. public = Yes
    9. browseable = No
    10. [root@xiaochen ~]# systemctl stop firewalld
    11. [root@xiaochen ~]# systemctl disable firewalld
    12. Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
    13. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
    14. [root@xiaochen ~]# vi /etc/sysconfig/selinux
    15. # This file controls the state of SELinux on the system.
    16. # SELINUX= can take one of these three values:
    17. # enforcing - SELinux security policy is enforced.
    18. # permissive - SELinux prints warnings instead of enforcing.
    19. # disabled - No SELinux policy is loaded.
    20. SELINUX=disabled
    21. # SELINUXTYPE= can take one of three two values:
    22. # targeted - Targeted processes are protected,
    23. # minimum - Modification of targeted policy. Only selected processes are protected.
    24. # mls - Multi Level Security protection.
    25. SELINUXTYPE=targeted
    26. [root@xiaochen ~]# setenforce 0
    27. [root@xiaochen ~]# mkdir /tmp/sambatest
    28. [root@xiaochen ~]# useradd smbtest
    29. [root@xiaochen ~]# smbpasswd -a smbtest
    30. New SMB password:
    31. Retype new SMB password:
    32. [root@xiaochen ~]# groupadd samba
    33. [root@xiaochen ~]# gpasswd -a smbtest samba
    34. Adding user smbtest to group samba
    35. [root@xiaochen ~]# chown :samba /tmp/sambatest/
    36. [root@xiaochen ~]# chmod g+w /tmp/sambatest/
    37. [root@xiaochen ~]# ll -d /tmp/sambatest/
    38. drwxrwxr-x. 2 root samba 6 Dec 4 23:06 /tmp/sambatest/
    39. [root@xiaochen ~]# systemctl start smb nmb</code>

    最后Windows访问:
    技术分享图片
    技术分享图片

    Linux中LAMP实现、SQL语句及FTP与Samba服务配置

    标签:blog   服务   hand   one   lis   dir   man   ide   数据库   

    人气教程排行