index.php not loading from ubuntu server VM (nginx & sftp) - php

I'll try to be short as it can get bloated.
I set up an ubuntu server 20.04 VM on an Oracle vbox.
I installed nginx, php7.4, Xdebug 3.
I configured everything properly for remote debugging and sftp ( I use PHPstorm), I forwarded the ports and customized my local hosts file.Everything works except...
when loading HTTP://127.0.0.2 it loads the default nginx landing page.My index.php file is uploaded in the root /var/www/my_domain folder through sftp. I created the server block for my_domain.
Still won't work. I am new to this so I am missing something.
If you need more info please request.
Any help appreciated!
Vhost config ( server block in nginx) - php-projects being my current domain and containing index.php:
server {
listen 80;
listen [::]:80 ipv6only=on;
root /var/www/php-projects;
server_name php-projects www.php-projects;
location / {
try_files $uri $uri/ =404;
}
error_log /var/log/nginx/debug.log debug;
}
Network settings from Vbox:
PS. I have tried :
How to set index.html as root file in Nginx?
and
Rewrite rule for the root file in nginx?
with no success.

"I configured everything properly for remote debugging and sftp"
Please post your xdebug configuration.
"when loading HTTP://127.0.0.2"
From where ? Host machine or VM?
"My index.php file is uploaded in the root /var/www/my_domain folder
through sftp."
Please post your nginx vhost configuration
"I created the server block for my_domain"
Where? Post the path to the file where you have done this

Related

AWS Elastic Beanstalk Apply configuration file on nginx server

I am trying to migrated my application in ebs because it was deprecated, my previous platform was:
PHP 5.6 running on 64bit Amazon Linux / 2.9.8
now i'm migrating to:
PHP 7.4 running on 64bit Amazon Linux 2 / 3.0.3
This platform uses the Nginx server instead of Apache.
I was able to deploy my application but the problem is that my .htaccess configuration file was deprecated as was my .ebextensions configuration file. so I have lost the settings I had for example to get clean urls and redirects from http to https.
I have tried to transform the apache configurations to Nginx by putting the respective configuration file but apparently they have no effect.
I have tried many test configurations and I have come to the conclusion that the platform is not reading the configurations that I put.
I have tried to try for example with this little configuration, which should allow me to list the "views" directory:
cleanurl.config
server {
location / views / {
autoindex on;
}
}
I have tried putting it in the following folders.
".ebextensions / cleanurl.config"
files:
"/etc/nginx/conf.d/cleanurl.conf":
mode: "000644"
owner: root
group: root
content: |
server {
location / views / {
autoindex on;
}
}
".platform / nginx / conf.d / cleanurl.config"
server {
location / views / {
autoindex on;
}
}
But I don't get results. I always get 403 Forbidden when I point to a folder. Please help.
Thanks in advance
After trying and trying I was able to solve it in the following way:
I put the file in this location
.platform/nginx/conf.d/elasticbeanstalk/cleanurl.conf
change my config file like this
location/views/ {
autoindex on;
}
and now everything works.
I have tried many test configurations and I have come to the conclusion that the platform is not reading the configurations that I put.
In the first case this is because the configuration files that you use are for Amazon Linux 1 (AL1). However, you environment is PHP 7.4 running on 64bit Amazon Linux 2 (AL2).
In your second attempt, you are using the config files in .platform/nginx/conf.d/ as you should. However, you are using *.config extension. This wrong extension and it should be:
cleanurl.conf
You still may have other issues, but the wrong extension could explain why the files are being ignored.

PHP debug environment not working

I am at the end of my tail here and could really use some help!
Here's my setup -
NGINX, PHP-FPM on CentOS
Nginx conf file has the following:
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;
}
PHP-FPM conf file at /etc/php-fpm.d/www.conf has the following
listen=127.0.0.1:9000
With the above configuration, NGINX can properly display PHP pages.
Now, I want to setup Xdebug. So I added the following to the /etc/php.d/xdebug.ini file
<code>
zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=x.x.x.x
xdebug.remote_port=9009
xdebug.remote_autostart=1
</code>
Note remote port is set to 9009 to not conflict with the PHP-FPM port 9000.
On the x.x.x.x machine, I have XDebugClient running listening for incoming connections on port 9009.
Next, I launch a browser from the host x.x.x.x and request URL http://y.y.y.y?XDEBUG_SESSION_START=1 (where y.y.y.y) is the server with the NGINX, PHP-FPM and XDebug setup.
The issue - nothing happens. XDebugClient never gets a connection!
What am I missing?
Things to check
Pull up a phpinfo() page to make sure your php.ini file is configured correctly. If you don't see a long xdebug section, then the problem is in your configuration.
Try running a trace or profile with xdebug. If they work, then the xdebug module itself is okay.
Try setting xdebug.remote_connect_back=1 in your php.ini file. This will override the remote_host setting and can be helpful if the problem is related to network configuration.
Make sure your IDE is set to listen for the connection on port 9009. In PHPStorm, for example, you must configure the IDE to listen on the custom port, and then you have to push a button to activate the debugging tool before you load the page being debugged.
Those are the basic steps I've had to go through quite a few times. Hopefully one of them will help.

No input file specified while using Nginx

I just create a server recently, and use Nginx as my web server.
I did : service nginx force-reload
Reloading nginx configuration nginx [ OK ]
Then I do service nginx status
nginx is running
Knowing that my site is running, but when I go to it. I see No input file specified. Wired ???
Here is what I have in my /etc/nginx/sites-available/default
server {
listen 80 default_server;
server_name default;
root /default/public;
Can someone please help me fix this ?
I fix this problem by assign my document root to the correct path :
root /home/forge/default/public;
If you see No input file specified., make sure you set your root to the correct path.

Nginx + phpmyadmin + gitlab on one server

I'm not so good with nginx but i try to make somthing with that and fresh installed gitlab.
So i intall on digitalocean Gitlab. One click installer (ubuntu 13.10). But now i try to install php and phpmyadmin and after that i want to make somthing ridiculous. I want move main repository map from /home/gitlab/gitlab-satellites to main root of my dev (same server).
So gitlab need to be on my_domain.com/gitlab, and main dev server location will be my_domain.com.
Is this possible or?
you can find the nginx conf files in the gitlab installation: gitlab/nginx/etc
which will be '/var/opt/gitlab/nginx/etc' in the default install
you can then edit the .conf files as necessary
Example on the 'gitlab-http.conf' file you will find:
server {
listen *:80;
server_name git.your-domain-name.com;
you will have to create similar virtual hosts on NGINX for
server {
listen *:80;
server_name your-domain-name.com;
OR
server {
listen *:80;
server_name *.your-domain-name.com;

nginx doesn't parse php request

env:
ubuntu 9.10 /
use gotdeb source /
php version 5.3.1 /
php5-fpm installed /
php5-fpm is running , and listening 9000 port test by 2 commands below
pgrep php5-fpm
telnet localhost 9000
however if I visit from anthor computer in LAN ,using this address
http://192.168.1.103/index.php
the browser ask me to save this index.php , but if visit index.php , everything goes well
sites-enabled/default file content
env:
ubuntu 9.10 /
use gotdeb source /
php version 5.3.1 /
php5-fpm installed /
php5-fpm is running , and listening 9000 port test by 2 commands below
pgrep php5-fpm
telnet localhost 9000
however if I visit from anthor computer in LAN ,using this address
http://192.168.1.103/index.php
the browser ask me to save this index.php , but if visit index.html , everything goes well
sites-enabled/default file content
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000
fastcgi_index index.php
fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name
include fastcgi_params
}
A common pitfall is when your code is using short open tags <? instead of <?php and it's not enabled in php.ini on a fresh install so it won't get parsed.
To enable it set short_open_tag=On
It seems you need to set your website's index.
You can see a full example on nginx's official wiki, but here's the relevant part:
location / {
index index.html index.htm index.php;
}
As you see, the virtual host needs to know it's supposed to process index.php when accessing the website via it's root dir (i.e. http://domain.com/ or http://domain.com/site/), with no file specified.
I do have an index:
location / {
index index.php;
}
I am not using <? PHP tags.

Categories