Welcome! Log In Create A New Profile

Advanced

PHP pages not loading

Posted by hexhaxtron 
PHP pages not loading
July 16, 2017 10:18AM
Hi!

I'm trying to make PHP pages work with nginx. It works perfectly like http://www.thunix.org/index.php
but when I try to do http://www.thunix.org/~hexhaxtron/index.php it asks me to Open/Save it instead of loading it.

I need to get it working with for example:

/home/h/hexhaxtron/www/index.php
or
/home/u/username/www/index.php

and also inside other directories like:

/home/h/hexhaxtron/www/abc/foo/bar/index.php

I hope to get this sorted soon.

My /etc/nginx/nginx.conf file is:

user www-data;
worker_processes 1;

error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;


events {
worker_connections 1024;
use epoll;
}


http {
include mime.types;
default_type application/octet-stream;

#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 on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

include conf.d/*.conf;

server {
listen 80;
server_name localhost;
root /srv/www/htdocs/;

#charset koi8-r;

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

location / {
index index.html index.htm index.php;
}

location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

# UserDir with PHP
location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*\.php) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
}

location ~ \.cgi$ {
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /srv/www/htdocs/;
}

listen 443 ssl;
server_name thunix.org;


ssl_certificate /etc/letsencrypt/live/thunix.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/thunix.org/privkey.pem;
}

server {
listen 80;
server_name localhost;
root /srv/www/htdocs/;

#charset koi8-r;

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

# UserDir with PHP
location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*\.php) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
}

location / {
index index.html index.htm index.php;
}

location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

# UserDir with PHP
location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*\.php) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
}

location ~ \.cgi$ {
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /srv/www/htdocs/;
}

listen 443 ssl default_server;
server_name www.thunix.org;


ssl_certificate /etc/letsencrypt/live/www.thunix.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.thunix.org/privkey.pem;
}


include vhosts.d/*.conf;



###Config for Round Cube
server {
listen 80;
server_name www.thunix.org thunix.org;
root /srv/www/htdocs/webmail;

if ($http_host != "www.thunix.org") {
rewrite ^ http://www.thunix.org$request_uri permanent;
}

index index.php index.html;

location ~ ^/favicon.ico$ {
root /srv/www/htdocs/webmail/skins/default/images;
log_not_found off;
access_log off;
expires max;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
deny all;
}
location ~ ^/(bin|SQL)/ {
deny all;
}

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}

location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
}
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 204
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready