Conoha VPS CentOS7 nginxでwebサーバ

CentOS7でwebサーバを馴染みのapacheからnginxへ変更したメモです。
ふつーにテンプレート用意されてますのでそちら使ったほうが楽です。
 
 
手順
 
1.apacheを止める
 
sudo systemctl stop httpd.service 
sudo systemctl disable httpd.service
 
 
2.色々入れる。(wordpress動かつつもりでmariadbも入れてます。
 

yum -y install nginx php-fpm  mariadb mariadb-server php-mysql php-gd php-mbstring
 
3.設定する
 
phpを動くようにする 


/etc/php-fpm.d/www.confを編集
user = apache を user = nginx へ

group = apache を group = nginx へ


ドキュメントルートを調整
そのままだと、welcomeページがでてくるので。。。
・設定ファイルの確認は、 sudo nginx -t 


/etc/nginx/nginx.confの編集
root         /usr/share/nginx/html/def;
を
root         /usr/share/nginx/html;


ドメインに合わせて仮想サーバ設定する。

/etc/nginx/conf.d/<ドメイン名>.confを作成して編集
・複数ドメインを使わないならたぶん。nginx.confを調整すればいいかと。

server {
    listen       80;
    listen       [::]:80;
    server_name  .<ドメイン名>;
    index        index.html;
    root         <ドキュメントルートのフォルダ名>;
 
    location / {
    }

    error_page 404 /404.html;
    location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}

4.実行する
sudo systemctl start nginx.service
sudo systemctl start php-fpm.service
sudo systemctl start mariadb.service 
 
 
5.自動起動設定
sudo systemctl enable nginx.service
sudo systemctl enable php-fpm.service
sudo systemctl enable mariadb.service

このブログの人気の投稿

laragonのphpmyadminでエラーが出た。

Conoha VPS Centos7へTeamspeak3の導入

IPv6の実行速度