CentOS 7 Install note

基本安裝環境

  • 安裝centos 最小安裝, 開發環境, 網路設定好, ROOT 密碼設定好
  • 使用uanme看到的是Kernel的版本以及32 or 64bits版本
  • uname -a
  • 想看CentOS的版本得要使用  #cat /etc/redhat-release

CentOS 7 換最新內核

  • rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
  • rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
  • yum --enablerepo=elrepo-kernel -y install kernel-ml kernel-ml-devel
  • 查看内核是否安装成功   rpm -qa | grep kernel
  • vi /etc/default/grub 設置 GRUB_DEFAULT=0。將GRUB初始化頁面的第一個內核將為預設內核。
  • grub2-mkconfig -o /boot/grub2/grub.cfg
  • reboot

開啟BBR

  • echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
  • echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
  • sysctl -p
  • sysctl net.ipv4.tcp_available_congestion_control ((看內核是否有BBR))
  • lsmod | grep bbr ((檢查BBR是否啟動))

CentOS 安装 更新 Tools

  • yum update -y
  • yum install epel-release -y
  • yum install wget -y
  • yum install git -y
  • yum -y install nano

SSH

  • 檢查目前的hostname hostnamectl
  • 修改hostname hostnamectl set-hostname 主機名稱
  • 禁止 root 使用 ssh 登入
    • nano /etc/ssh/sshd_config
    • #PermitEmptyPasswords no > PermitEmptyPasswords no (禁止空白密碼)
    • #PermitRootLogin yes  > PermitRootLogin no (禁止ROOT登入)
    • systemctl restart sshd.service

測試速度

  • wget https://lax-ca-us-ping.vultr.com/vultr.com.100MB.bin
  • wget http://chi.testfiles.ubiquityservers.com/1000mb.txt
  • wget -qO- bench.sh | bash

LEMP 參照 https://www.hostinger.com/tutorials/how-to-install-lemp-centos7

Nginx https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7

  • yum install epel-release -y
  • yum install nginx -y
  • systemctl start nginx
  • systemctl enable nginx
  • If you are running a firewall,run the following commands to allow HTTP and HTTPS traffic:
    • firewall-cmd --permanent --zone=public --add-service=http
    • firewall-cmd --permanent --zone=public --add-service=https
    • firewall-cmd --reload
  • http://server_domain_name_or_IP/

MariaDB

  • yum install mariadb-server mariadb -y
  • systemctl enable mariadb
  • mysql_secure_installation
  • systemctl start mariadb

PHP

  • rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  • yum install yum-utils -y
  • yum-config-manager --enable remi-php71
  • yum --enablerepo=remi,remi-php71 install php-fpm php-common

Configuring Nginx to work with PHP 7

  • nano /etc/nginx/conf.d/default.conf
    • server {
          listen 80;
          server_name xxx.xxx.xxx.xxx your_server_ip;
      
          # note that these lines are originally from the "location /" block
          root /usr/share/nginx/html;
          index index.php index.html index.htm;
      
          location / {
              try_files $uri $uri/ =404;
          }
          error_page 404 /404.html;
          error_page 500 502 503 504 /50x.html;
          location = /50x.html {
              root /usr/share/nginx/html;
          }
      
          location ~ \.php$ {
              try_files $uri =404;
              fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              include fastcgi_params;
          }
      }
      
  • systemctl restart nginx
  • nano /etc/php-fpm.d/www.conf
    • user = apache to user = nginx
      group = apache to group = nginx
      listen.owner = nobody to listen.owner = nginx
      listen.group = nobody to listen.group = nginx
      And, lastly, under ;listen = 127.0.0.1:9000 add this line:
      listen = /var/run/php-fpm/php-fpm.sock
      
  • systemctl start php-fpm.service
  • systemctl enable php-fpm.service
  • vi /usr/share/html/index.php
    • <?php
      phpinfo();
      ?>
      

留言

這個網誌中的熱門文章

Identity Server WebAPI