nginxのインストール
#vi /etc/yum.repos.d/nginx.repo [nginx] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key #yum install --enablerepo=nginx nginx nginxのインストール #firewall-cmd --zone=public --add-port=80/tcp --permanent firewallのポート開放 #firewall-cmd --reload firewallのリロード #firewall-cmd --list-all ポート開放の確認 #systemctl start nginx #systemctl enable nginx
php-fpmの初期設定
#vi /etc/php-fpm.d/www.conf -user = apache +user = nginx -group = apache +group = nginx #systemctl start php-fpm #systemctl enable php-fpm #systemctl status php-fpm
ブラウザで「Welcome to nginx!」の表示確認
PHPの動作確認
「default.conf」の修正
#vi /etc/nginx/conf.d/default.conf -#location ~ \.php$ { +location ~ \.php$ { - # root html; + root /usr/share/nginx/html; - # fastcgi_pass 127.0.0.1:9000; + fastcgi_pass 127.0.0.1:9000; - # fastcgi_index index.php; + fastcgi_index index.php; - # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - # include fastcgi_params; + include fastcgi_params; - #} + }
修正後の「default.conf」
location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
vi /usr/share/nginx/html/index.php <?php phpinfo(); ?> 追記
systemctl restart nginx nginxの再起動
ブラウザで「http://000.000.000.000/index.php」にアクセスしてphpinfoが表示されるか確認