Linux – Instalando Nginx (Engine X) + PHP
Eae bora instalar o Nginx com PHP? Documentação: https://nginx.org/en/linux_packages.html 1 – Adicionar o repositório e instalar o pacote
1 2 3 4 5 6 7 |
[root@centos tmp]# vim /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1 |
1 |
[root@centos tmp]# yum install nginx php php-common php-fpm |
1 2 3 4 |
[root@centos tmp]# systemctl stop httpd [root@centos tmp]# systemctl disable httpd [root@centos tmp]# systemctl enable nginx [root@centos tmp]# systemctl start nginx |
2 – Editar os arquivos de conf
1 2 3 |
[root@centos tmp]# vim /etc/php.ini cgi.fix_pathinfo=0 |
1 2 3 4 5 6 7 8 9 10 |
[root@centos tmp]# vim /etc/php-fpm.d/www.conf ;listen = 127.0.0.1:9000 listen = /var/run/php-fpm/php-fpm.sock listen.owner = nobody listen.group = nobody user = nginx group = nginx [root@centos tmp]# systemctl restart php-fpm |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
[root@centos tmp]# cp /etc/nginx/conf.d/default.conf /mnt/ [root@centos tmp]# vim /etc/nginx/conf.d/default.conf server { listen 80; server_name 192.168.1.39; # 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; } } [root@centos tmp]# systemctl restart nginx |
3 – Criar phpinfo.php e validar
1 2 3 4 5 6 7 |
[root@centos tmp]# vim /usr/share/nginx/html/phpinfo.php <?php phpinfo(); ?> http://seu_ipaddress/phpinfo.php |
Referências: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7 https://www.tecmint.com/install-nginx-mariadb-php-rhel-centos-fedora/
Continue reading →