Haven’t update your blog for a long time, also show their how to learn in this a few months, the main things really a lot of (forced) excuses, but although the technology did not increase too much, but there are still a lot of harvest, the concept of if there is not much for the New Year this year, but deeply felt this year after the past, so, want to seize the tail of the year, Smoke yourself hahaha.

Introduction and Purchase of Linux server

  • Linux Server Introduction

    I also know little about Linux server, as a front-end rookie thief like to toss me, their server expired, and then the renewal was, and then the continuation of a Linux, as for why to buy Linux system? Hahaha, I don’t know. Just listen to a friend, that’s all. However, the Linux command line seems to be more suitable for programmers than the visual interface of Windows server. After all, most programmers like to fly with you. Linux is supposed to operate through a series of command lines, and that’s how I look at it at the most superficial level.

    1. Most stable: It makes sense to use a Linux server because it is considered the most stable platform on the market today. You don’t have to worry about rebooting your system or constantly downloading updates.
    2. Good performance: Linux is also known for the best performance of any server currently available. With Linux, you can have a large number of users working on the same server without any problems. It is also an ideal server for networking purposes.
    3. Multitasking capability: You can also multitask when using a Linux server. Linux is known for its ability to handle many different programs running simultaneously. With other operating systems, they may put certain programs in “sleep mode” when you open other content.
    4. Flexibility: The Linux platform is known to be very flexible for many different situations. Because it comes from an open source program, programmers can customize it to your needs. With this flexibility, it also makes the platform more secure.
  • buy

    I am the purchase of Ali cloud server, other servers query to buy, directly into ali cloud official, directly choose cloud server ECS, see the need to buy, my CPU: two cores, MEMORY 4G, operating system: CentOS 7.7 64-bit, and then buy the end.

Deploy the Web site

  • The deployment of the FTP

    Do you feel overwhelmed with Linux servers and wonder what to do, stop and think, what do we need to do in our daily work when the website is running? It’s like thinking about what ingredients you’re going to need before you start cooking, even though my cooking is terrible (and I was told by someone that the food is ugly and dark and can’t see……..). Back to the question of whether MySQL, web services environment, FTP and other tools are needed.


    1. Centos7 FTP installation and deployment

      • Download and install the FTP installation package

        # installation
        yum install -y vsftpd
        
        Set boot up
        systemctl enable vsftpd.service
        
        # start
        systemctl start vsftpd.service
        
        # stop
        systemctl stop vsftpd.service
        
        # check status
        systemctl status vsftpd.service
        Copy the code
      • Configure FTP

        Open the configuration file
        vim /etc/vsftpd/vsftpd.conf
        
        # display line number
        :set number
        
        # Modify config line 12
        anonymous_enable=NO
        
        Change the configuration at line 33
        anon_mkdir_write_enable=YES
        
        # Modify config line 48
        chown_uploads=YES
        
        Modify configuration line 72
        async_abor_enable=YES
        
        # Change configuration on line 82
        ascii_upload_enable=YES
        
        Modify configuration on line 83
        ascii_download_enable=YES
        
        Change the configuration on line 86
        ftpd_banner=Welcome to blah FTP service.
        
        Modify configuration 100 lines
        chroot_local_user=YES
        
        Add the following to the end of vsftpd.conf
        use_localtime=YES
        listen_port=21
        idle_session_timeout=300
        guest_enable=YES
        guest_username=vsftpd
        user_config_dir=/etc/vsftpd/vconf
        data_connection_timeout=1
        virtual_use_local_privs=YES
        pasv_min_port=40000
        pasv_max_port=40010
        accept_timeout=5
        connect_timeout=1
        allow_writeable_chroot=YES
        Copy the code
      • Create user files

        Create edit user file
        vim /etc/vsftpd/virtusers
        The first action is the username, the second action is the password. You cannot use root as the user name
        
        admin
        123456
        Copy the code
      • Generate user data files

        db_load -T -t hash -f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db
        
        Set PAM authentication file and specify that the virtual user database file is read
        
        chmod 600 /etc/vsftpd/virtusers.db 
        Copy the code
      • Modify the /ect/pam.d/ VSFTPD file

        Back up data before changing it
        
        cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak
        
        vi /etc/pam.d/vsftpd
        Comment out all configuration lines of auth and account
        auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers 
        account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers 
        
        If the system is 32-bit, change the above to lib
        Copy the code
      • Create the VSFTPD user and set the user directory to /home/vsftpd

        Set user login terminal to /bin/false
        useradd vsftpd -d /home/vsftpd -s /bin/false
        chown -R vsftpd:vsftpd /home/vsftpd
        Copy the code
      • Create a virtual user profile

        mkdir /etc/vsftpd/vconf
        cd /etc/vsftpd/vconf
        
        Set up the virtual user Leo profile here
        touch admin
        
        # Edit the Leo user profile as follows, similar for other users
        vi admin
        
        local_root=/home/vsftpd/leo/
        write_enable=YES
        anon_world_readable_only=NO
        anon_upload_enable=YES
        anon_mkdir_write_enable=YES
        anon_other_write_enable=YES
        
        # Create Leo user root directory
        mkdir -p /home/vsftpd/leo/
        Copy the code
      • Firewall Settings

        To set IPtables, run the vi /etc/sysconfig/iptables command# Edit the iptables file and add the following to enable port 21-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 40000:40010 -j ACCEPT firewall Settings:  firewall-cmd --zone=public --add-service=ftp --permanent firewall-cmd --zone=public --add-port=21/tcp --permanent firewall-cmd --zone=public --add-port=40000-40010/tcp --permanentCopy the code
      • Restart the VSFTPD server

        systemctl restart vsftpd.service
        Copy the code
    2. Centos7 FTP connection

      • At this time, using FTP tool connection, we found that it can be connected. During file transfer, problems such as 500, 503, and 200 are found in file upload and download. At this point, you can perform the following three operations:

        • Close the SELINUX

          Open the SELINUX configuration file
          vim /etc/selinux/config
          
          # Modify configuration parameters
          # comments
          SELINUX=enforcing
          
          # increase
          SELINUX=disabled
          
          After modification, you need to restart!
          Copy the code
        • Modify the SELINUX

          setenforce 0 # temporarily put SELinux into Permissive mode
          
          # list ftP-related Settings
          getsebool -a|grep ftp
          
          The following is the display of the permissions, off is to close the permissions, on is to open the permissions. Different machines may display different things. I looked at my display and it was different from other tutorials on the Internetftp_home_dir --> off ftpd_anon_write --> off ftpd_connect_all_unreserved --> off ftpd_connect_db --> off ftpd_full_access --> off ftpd_use_cifs --> off ftpd_use_fusefs --> off ftpd_use_nfs --> off ftpd_use_passive_mode --> off httpd_can_connect_ftp --> off httpd_enable_ftp_server --> off sftpd_anon_write --> off sftpd_enable_homedirs --> off  sftpd_full_access --> off sftpd_write_ssh_home --> off tftp_anon_write --> off tftp_home_dir --> offSet ftp_home_dir and ftPD_full_access to 1
          
          setsebool -P ftp_home_dir 1
          setsebool -P allow_ftpd_anon_write 1
          setsebool -P ftp_home_dir 1
          
          setenforce 1 Enter Enforcing mode
          Copy the code
        • SELINUX makes no restrictions on VSFTP

          setsebool -P ftpd_connect_all_unreserved 1
          Copy the code
  • Node. Js installed

    1. Copy the installation package information from the official website

      [nodejs.cn/download/]:

    2. Use Xshell (recommended) or putty to connect to your Linux and CD to the installation directory in Xshell

      cd /usr/local/
      Copy the code
    3. Enter the command connect to start downloading the Node.js installation package

      Wget HTTP: / / https://npm.taobao.org/mirrors/node/v12.14.1/node-v12.14.1-linux-x64.tar.xzCopy the code
    4. Decompress the installation package

      Xz -d node-v10.16.0-linux-x64.tar.xz tar - XVF node-v10.16.0-linux-x64.tarCopy the code
    5. Rename the decompressed folder to nodejs

      Node - mv v10.16.0 - Linux - x64 nodejsCopy the code
    6. Go to the decompressed directory

      cd nodejs
      Copy the code
    7. Creating a Soft connection

      ln -s  /usr/local/nodejs/bin/node /usr/local/bin/node
      ln -s  /usr/local/nodejs/bin/npm /usr/local/bin/npm
      Copy the code
    8. Test whether the Node is successfully installed

      node -v
      npm -v
      Copy the code
    9. Install CNPM Taobao image and create soft connection

      npm config set registry https://registry.npm.taobao.org
      Check whether the installation succeeds
      npm config get registry
      Copy the code
  • Using Express or KOA or Egg to build a Web service environment see Introduction to Linux ii