1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

centosstream8 に nginx1.20 , php8.1 をインストール

Last updated at Posted at 2021-12-19

centosstream9 だと snapdが入らずSSL化できない。
ということで 8 に落として再インストール

yum が dnf になった
以下、すべてrootで。

まずはバージョンを最新にしてselinuxをオフ


dnf update
sudo timedatectl set-timezone Asia/Tokyo
grubby --update-kernel ALL --args selinux=0
shutdown -r now

#epel 的なのを一気にインスコ


dnf -y install epel-release
dnf -y install elrepo-release
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf config-manager --set-enabled powertools
dnf install epel-release epel-next-release

#最新の nginx をインスコ
参考
https://www.kdkwakaba.com/archives/1258

/etc/yum.repos.d/nginx.repo

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ 
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

コマンド実行


yum install nginx
nginx -v
//nginx version: nginx/1.20.1 ok

phpの最新版を入れる


dnf module list php
dnf module list reset php -y
dnf module enable php:remi-8.1

dnf install php php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imap php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml

php -v

#www.conf 書き換え

/etc/php-fpm.d/www.conf

#user = apache 
user = nginx

#group = apache
group = nginx

#firewallをオープン


firewall-cmd --add-service=https --zone=public --permanent
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --reload


#nginx設定ファイル

/etc/nginx/nginx.conf

user  nginx;
worker_processes  auto;
worker_rlimit_nofile 100000;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  2048;
    multi_accept on;
    use epoll;
}


http {

    server_tokens off;
    include       /etc/nginx/mime.types;
    default_type  text/html;
    charset UTF-8;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile       off;
    tcp_nopush     on;
    tcp_nodelay    on;


    keepalive_timeout 10;
    client_header_timeout 10;
    client_body_timeout 10;
    reset_timedout_connection on;
    send_timeout 10;

    limit_conn_zone $binary_remote_addr zone=addr:5m;
    limit_conn addr 100;

    gzip on;
    gzip_http_version 1.0;
    gzip_disable "msie6";
    gzip_proxied any;
    gzip_min_length 1024;
    gzip_comp_level 6;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/json;
    open_file_cache off;

    client_max_body_size 20m;
    server_names_hash_bucket_size 64;
    include /etc/nginx/conf.d/*.conf;
}


/etc/nginx/conf.d/default.conf

server {
    listen 80;
    server_name yourdomain.net;
    root   /var/www/html/yamada/;
    index index.php index.html index.htm;



         location ~ \.php$ {

       fastcgi_pass   unix:/var/run/php-fpm/www.sock;

       fastcgi_index  index.php;

       fastcgi_param  SCRIPT_FILENAME /var/www/html/yamada$fastcgi_script_name;
        include        fastcgi_params;

 }



}


#phpinfo用ファイル作成


mkdir /var/www/html/yamada/
vim /var/www/html/yamada/index.php

index.php

<?php
    phpinfo();
?>

#自動起動設定


sudo systemctl restart nginx
sudo systemctl restart php-fpm

//ついでに自動起動設定も
sudo systemctl enable nginx
sudo systemctl enable php-fpm


これで、あなたのIPにアクセスしたときにphpinfoが表示されればOK!

必要に応じphp.iniも変更
https://qiita.com/ucan-lab/items/0d74378e1b9ba81699a9

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?