Laravel5 and PhpMyadmin on Digital Ocean LEMP stack - nginx

I tried to install phpMyadmin on my LEMP server using following tutorial
https://www.digitalocean.com/community/tutorials/how-to-install-phpmyadmin-on-a-lemp-server
but when I try to access myip/phpmyadmin I get page cannot be found
before this I installed laravel5 so anything i am typing after ip/anystring its being accessed by my laravel route page ,
So can you tell me how I can access the phpMyadmin
my ip is http://xxxxxxxx//phpmyadmin .
and my default page for nginx looks like this
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/laravel/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name xxxxxxx;
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;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
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_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Please hlp me out
Thanks

I am also stuck in the same kind of situation. Paste this code before location ~ .php$ function and it's work perfectly fine.
Source : Laravel routes overwriting phpmyadmin path with nginx
location /phpmyadmin {
root /usr/share/nginx/html;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/nginx/html;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/nginx/html;
}
}

Related

Custom error page nginx ubuntu 18.04 not working. How to fix?

I added the code in /etc/nginx/sites-available/default for custom error page
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
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;
}
location ~ \.php$ {
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
error_page 404 /custom_error_404.html;
location = /custom_error_404.html {
root /usr/share/nginx/html;
internal;
}
error_page 500 502 503 504 /custom_error_50x.html;
location = /custom_error_50x.html {
root /usr/share/nginx/html;
internal;
}
location /display505error {
fastcgi_pass unix:/path/does/not/exist;
}
}
and file 50x and 404 in here /usr/share/nginx/html
but the error page is not working
and it still shows up
404 Not Found
nginx/1.14.0 (Ubuntu)
how to fix this code?

nginx configuration for multiple sites one ip address and one server

nginx multiple websites on same port and one ip address
for example my ip 192.167.10.2
and we want to run site on same ip
nginx/html contain two project like below
1: project1
2: project2
we run default project1 on ip :192.167.10.2
and second project run like 192.167.10.2/project2
how do configuration in nginx config file
Here is a simple example.You could try
First config :
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/mywebsite1;
index index.php index.html index.htm;
server_name mywebsite1.de www.mywebsite1.de;
location / {
try_files $uri/ /index.php?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/mywebsite1;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Second config:
server {
listen 80;
listen [::]:80 //#here Be carefull , only one default
root /var/www/mywebsite2;
index index.php index.html index.htm;
server_name mywebsite1.de www.mywebsite1.de;
location / {
try_files $uri/ /index.php?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/mywebsite1;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Don't forget to restart server.

NGINX 404 all pages

So I have two issues that I am trying to do. First I am trying to understand NGINX and use it for redirects and everything as well; however, if I try to remove the extensions from the php / html files it just downloads the file. If I use another thing to just try (without the file extension try) it just gives me 404s. I am not sure what the issue is nor what I am doing wrong.
First I'll show my remove php file extension issue:
server {
listen 443;
server_name XXX.XX.XX.XX;
root /var/www/html;
location / {
try_files $uri $uri.html $uri/ #extensionless-php;
index index.html index.htm index.php;
}
location ~ \.php$ {
try_files $uri =404;
}
location #extensionless-php {
rewrite ^(.*)$ $1.php last;
}
}
Here is my other code to fix the problem above (but just gives me 404s)
server {
listen 443;
server_name XXX.XX.XX.XX;
root /var/www/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 /var/www/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
XXX.XX.XX.XX is my the servers ip.
PS: I have read that I need the bottom section first to get the top section working.
Sources include:
How to remove both .php and .html extensions from url using NGINX?
https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04
Ty for your help.
UPDATES:
Kuldeep KD - 770 /var/www/html (not solution but thanks)
Jignesh Joisar - Trying port 80 (failed but per usual thanks)
Check for necessary permissions on /var/www/html
you can change the permissions using
chmod -R 770 /var/www/html/
also check for the owner of directory you may have to change that as well, depends on user your nginx is using.
chown -R user:group /var/www/html
try to this one in 80 port
server {
listen 80 default_server;
root /var/www/html/;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm;
server_name localhost;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php$is_args$args;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}

nginx - DNS works for www. but not for http://

I have a server that is using ngnix and I have a configuration file:
server {
listen 80;
server_name http://mycoolwebsite.com/;
return 301 http://www.mycoolwebsite.com$request_uri;
}
server {
listen 80;
root /var/www/website/front/public;
index index.php index.html index.htm;
server_name www.mycoolwebsite.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
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_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Now when I enter http://www.mycoolwebsite.com the website shows just fine. Whenever I enter http://mycoolwebsite.com I get:
This site can’t be reached | server DNS address could not be found.
What could be the issue here?
Your server name in the first server block should be:
server_name mycoolwebsite.com;
Also, make sure that there is a DNS entry for mycoolwebsite.com that points to your servers IP. This may be separate to the entry for www.mycoolwebsite.com.

Nginx and Jekyll: serving in a subdomain

I'm currently stuck in configuring Jekyll and nginx to work together on a VPS.
Essentially, I set up everything and a git hook from my local machine to the VPS.
Here is my nginx config file:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www;
index index.php index.html index.htm;
server_name server_ip;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80;
server_name server_ip/blog;
location / {
root /var/www/blog;
index index.html index.htm;
}
}
Ideally, what I'd like is to serve what is in /var/www/blog at blog.domain.example, or blog.server_ip at the moment.
However, when jekyll build runs, the URLs are all wrong. I can see index.html at server_ip/blog, but the /blog/ bit in the URL is not replicated in the links on the Jekyll page.
For example, a post should live at server_ip/blog/2015/04/07/title, but the URL I'm given is server_ip/2015/04/07/title. Same goes for the CSS files, and images as well.
Thanks very much for your help.
You have to set baseurl: "/blog"
And link to posts like this <a href="{{site.baseurl}}{{post.url}}>....
And generaly use {{site.baseurl}} to built any url.

Resources