So after conducting a long research and not being able to find an answer to my problems, i’ve decided to ask for help.
I recently joined DigitalOcean as a client and created my first droplet, with the intention of migrating from another service.
It runs on Ubuntu 18.04, it has Nginx and PHP 7.2 installed.
I’ve been knocking my head trying to figure out why wouldn’t it run any php files in the /var/www/html folder, instead i get the “This site can’t be reached” for a simple phpinfo().
It runs html files just fine so it must have something to do with the php setup.
It almost always is something simple, this time however i cannot seem to find out what it is, would someone be able to help?
Here is my default config for nginx:
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
And PHP seems to be running fine:
php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-12-09 13:26:59 UTC; 30min ago
Docs: man:php-fpm7.2(8)
Main PID: 14842 (php-fpm7.2)
Status: "Processes active: 0, idle: 2, Requests: 2, slow: 0, Traffic: 0req/sec"
Tasks: 3 (limit: 4704)
CGroup: /system.slice/php7.2-fpm.service
├─14842 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
├─14866 php-fpm: pool www
└─14867 php-fpm: pool www
Dec 09 13:26:59 ubuntu-s-2vcpu-4gb-fra1-01 systemd[1]: Starting The PHP 7.2 FastCGI Process Manager...
Dec 09 13:26:59 ubuntu-s-2vcpu-4gb-fra1-01 systemd[1]: Started The PHP 7.2 FastCGI Process Manager.
Related
I seem to have hit a problem. I had a live website, and decided to change the domain name, this involved removing the old SSL and adding a new one in.
Server settings:
Ubuntu 20.4
Nginx(Latest version)
MariaDb
php-fpm
Wordpress
So the steps I taken to remove the ssl were the following:
cp -r /etc/letsencrypt/ /etc/letsencrypt.backup
certbot revoke --cert-path /etc/letsencypt/archive/healthwellnesssynergy.com/cert1.pem
certbot delete
sudo apt purge nginx nginx-common nginx-core
Then I re-installed Nginx, ran certbot installation, installed the ssl, restarted nginx, but when I go to my new domain, it is just a blank white page. I tried to debug it, but there is nothing in the logs.
When i enable WP debug, nothing happens. And wappalizer plugin does not even show Wordpress present in the list.
I am not really sure what I am missing, I checked all the statuses, and it is all running, mariadb and nginx are functioning as intended.
Are there any other steps I need to take when I switch SSL?
Here is my nginx config
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php;
server_name hwscenter.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$args;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/hwscenter.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/hwscenter.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
server {
if ($host = hwscenter.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name hwscenter.com;
return 404; # managed by Certbot
}
Silly me.. forgot to uncomment a line for the NginX Config.
include snippets/fastcgi-php.conf;
i tried to open https://isin.ir/wp-admin/theme-editor.php and customize my theme
i get error
Request Timeout
This request takes too long to process, it is timed out by the server. If it should not be timed out, please contact administrator of this web site to increase 'Connection Timeout'.
the thing i did
increase max_execution_time in php.ini
add define( 'DISALLOW_FILE_EDIT', false ); to wp-config.php
when i chang theme this problem was solved
hi in my opinion if you use this code your problem fix
server {
listen 4050;
listen [::]:4050;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/deltatechco.ir;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name deltatechco.ir www.deltatechco.ir;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
I install my webserver as Debian 10 with Nginx and installed the PHP7.3 with MariaDB.
The info.php is not loading on the browser and the browser shows a blank screen. I've checked error log and there is below lines there:
The Error is:
- 2020/08/14 05:28:31 [info] 2782#2782: Using 32768KiB of shared memory for nchan in
/etc/nginx/nginx.conf:63
- 2020/08/14 05:45:38 [info] 14940#14940: Using 32768KiB of shared memory for nchan in
/etc/nginx/nginx.conf:63
- 2020/08/14 05:45:51 [info] 14949#14949: Using 32768KiB of shared memory for nchan in
/etc/nginx/nginx.conf:63
- 2020/08/14 06:01:27 [info] 15179#15179: Using 32768KiB of shared memory for nchan in
/etc/nginx/nginx.conf:63
- 2020/08/14 06:01:35 [info] 15188#15188: Using 32768KiB of shared memory for nchan in
/etc/nginx/nginx.conf:63
- 2020/08/14 06:11:10 [info] 15370#15370: Using 32768KiB of shared memory for nchan in
/etc/nginx/nginx.conf:63
========================================================================
can someone please help me to resolve the issue? Here is the default configuration for server block too:
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/rs/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
}
I have a digitalocean droplet and I want to run a laravel project. I used this tutorial https://www.digitalocean.com/community/tutorials/how-to-deploy-a-laravel-application-with-nginx-on-ubuntu-16-04
The thing is that it displays a 403. I saw on other questions that they missed the public directory or they had the path wrong, but in my case I got a 403 when I have the public dir correct, and a 500 when I have it wrong.
My nginx error log says
2017/09/29 13:58:16 [error] 15176#15176: *2 directory index of "/var/www/laravel/public/" is forbidden
My nginx sites-available/my-site.com
server {
listen 80;
listen [::]:80;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/laravel/public;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name my-site.com www.my-site.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
}
The answer is right there in your nginx config. It is also shown in the tutorial you link to.
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
You have not added index.php.
I have the same problem with VestaCp, but, the only real solution that i did, was to disable the nginx server, and just let the apache2 like default, and put off the nginx firewall in the config,
I've successfully installed nginx that uses PHP-FPM but unfortunately I'm having some trouble when loading my php files from a different directory. All my files are located in subdirectories in /var/www/html (e.g. all css-files are located in /var/www/html/css, all javascript-files are located in /var/www/html/js, all php-files are located in /var/www/html/php).
According to this, I changed the root directory path for my php files to /var/www/html/php:
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php home.php;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www/html/php;
include snippets/fastcgi-php.conf;
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
Unfortunately, when accessing my nginx server using my web browser, I'm getting error 403 (Forbidden). When accessing my index.php (http://192.168.2.109/index.php) directly, everything works fine. So, I think it means that the file permissions are correct but nginx isn't able to index the /var/www/html/php directory. Furthermore, /var/log/nginx/error.log includes:
2017/05/28 07:49:56 [error] 13678#13678: *1 directory index of "/var/www/html/" is forbidden, client: 192.168.2.101, server: _, request: "GET / HTTP/1.1", host: "192.168.2.109"
I already tried to enable autoindex and add the index specifier in the "location ~ .php$ {" section without success. The result is the same :(
Does anyone has an idea what I'm doing wrong/missing here? All suggestions in Nginx 403 error: directory index of [folder] is forbidden didn't solve my problem.
The problem are easy:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www/html/php;
include snippets/fastcgi-php.conf;
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
As I can read, when you request a *.php file, you change the root address. But, when you request "default index", you are requesting /, not a .php
You need a new location, for change root path on / request. Try to use this:
location = / {
root /var/www/html/php;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
Maybe, on this config, you need to put a "rewrite index.php;", but I didn't know because I've never test this configuration.
Don't think my new location order (location = /) is the same as yours (location /), because my order, with the equal sign, only apply when you request exactly the "main" location without any parameter.