LoginSignup
2
1

More than 5 years have passed since last update.

CentOS7にapacheを導入する過程

Last updated at Posted at 2017-12-31
  1. コンソールからサーバー起動
  2. サーバーにログインしてみる

    ssh IPアドレス
    
  3. 作業用ユーザーを追加する

    useradd ユーザーネーム
    
  4. 作業用ユーザーにパスワードを設定する

    passwd ユーザーネーム
    
  5. ユーザーのグループを確認

    groups ユーザーネーム
    
  6. sudoを使えるように、ユーザーのグループを変更する

    usermod -G wheel ユーザーネーム
    
  7. sudoが使えるか試してみる

    su - ユーザーネーム
    sudo pwd
    # -> /home/ユーザーネームとか出る
    
  8. サーバーから一旦ログアウトして、作成したユーザーでログインできるか確認する

    exit 
    ssh ユーザーネーム@IPアドレス
    
  9. 鍵認証でログインできるようにする

    mkdir .ssh
    chmod 700
    touch .ssh/authorized_keys
    chmod 600 .ssh/authorized_keys
    vi .ssh/authorized_keys # ローカルの公開鍵をコピペする
    
  10. ルートログイン、パスワードログインを禁止する

    sudo vi /etc/ssh/sshd_config
    # PermitRootLogin no / PasswordAuthentication no 左記の該当箇所を設定
    
  11. 設定を反映させるためにsshdをリスタートする

    sudo service sshd restart
    
  12. yumを最新にする

    sudo yum -y update
    
  13. apacheのインストール

    sudo yum -y install httpd
    
  14. apacheの起動

    sudo systemctl start httpd.service  
    sudo systemctl status httpd.service # 起動チェック
    
  15. apacheの自動起動設定

    sudo systemctl enable httpd.service
    sudo systemctl is-enabled httpd # 設定されたかチェック
    
  16. ファイアウォールでhttp通信を許可するよう設定

    sudo firewall-cmd --permanent --zone=public --add-service=http
    sudo firewall-cmd --reload
    sudo firewall-cmd --zone=public --list-all
    
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1