how to change index directory of my laravel website - laravel

I want to create a website using Laravel Framework in my localhost laragon server
I uploaded the website files in a Web Hosting. and when I enter the url http://www.mywebsite.com. then I just get the files like
But when I enter the url http://www.mywebsite.com/public then it is working perfectly.
Can anyone suggest me that what's I'm doing wrong.

You need to point your domain to public folder of laravel not root since laravel has index.php inside project folder/public/index.php so you need to point project folder/public/

Let suppose you uploaded your application to /var/www/html directory. and your public folder path looks like this /var/www/html/public.
Then your site-available file code should be like this
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name www.mywebsite.com;
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$ {
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.2-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
You just need to change root path. Then your site will work properly as expected.

i moved all files from public folder (project_folder/public/ )
into project folder
in index.php i changed this lines:
require DIR.'/../vendor/autoload.php';
$app = require_once DIR.'/../bootstrap/app.php';
INTO:
require DIR.'/./vendor/autoload.php';
$app = require_once DIR.'/./bootstrap/app.php';
and works fine ...
Thank you to everyone :)

Related

Deployment of Laravel project on Debian 9 using nginx

I try to deploy my Laravel project from localhost to Debian server using nginx. First of all, i followed this tutorial LINK. Ended at the end of 5. chapter. I did not get any errors. Also I successfully connect Laravel project with server DB. I use Laravel version 6, so when i was modifying newly created config file on /etc/nginx/sites-available/myFile I used laravel's deployment tutorial LINK. As my server does not have any domain, I've got only IP available. Screenshot of my config file:
Config file
When I try to open server page using IP, i got error "This page isn't working". It's because i deleted nginx's default file from sites-enabled. Before, i deleted the default file, i got only default home page of nginx.
I tried to change server_name like server_name _;, server_name "";, server_name IP. After all changes i restarted nginx server.
Any help how to run my Laravel project please? Thank you!!
EDIT: route to project: /var/www/html/OciNaCeste/BP_final
Please use the following configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /var/www/html/OciNaCeste/BP_final/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Then restart nginx

Codeigniter on Nginx not loading all resource

I've setup nginx and imported codeigniter into my projects and I'm unable to resolve the following error.My server is running Ubuntu 16 and php7 I've tried giving the files permission but still no solution. Anyone know where the problem could be? Thanks
My default config file for my server in nginx.
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/observum/site;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm;
server_name 45.79.4.55;
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;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.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;
}
# 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
#
Screenshot
you css/js path is incorrect,its include from 'site' directory
its getting include in your document is
http://45.79.4.55/site/libreriasJS/boceto/css/modern-business.css
but its should be like
http://45.79.4.55/libreriasJS/boceto/css/modern-business.css

My css and javascript files not running

I installed Nginx server for my laravel project. But css and javascript file not working. Css and javascript file downloadable on server. For example http://myipaddress/css/bootstrap.css download the bootstrap.css file. I call the css file like <link href="{{ URL::asset('css/bootstrap.css') }}" rel="stylesheet"> like this.
My source code
My public folder permissions
/etc/nginx/sites-available/default looks like the following
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# 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/english4-u.com/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm;
server_name english4-u.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
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;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
access_log /var/log/nginx/english4-u.com-access.log;
error_log /var/log/nginx/english4-u.com-error.log error;
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { access_log off; log_not_found off; }
charset utf-8;
error_page 404 /index.php;}
Can you help me with this?
Thank You.
Have you seen the movie Hidden Figures? There's a scene where a main character can see censored information by holding up redacted papers to a lamp. The relevance you may ask? Your censoring in the question wasn't very hard circumvent.
When I visit your server and check the Console I get ...
The stylesheet http://###/css/bootstrap.css was not loaded because its MIME type, "application/octet-stream", is not "text/css".
The stylesheet http://###/css/font-awesome.min.css was not loaded because its MIME type, "application/octet-stream", is not "text/css".
The stylesheet http://###/css/style.css was not loaded because its MIME type, "application/octet-stream", is not "text/css".
Fix the mime-types of the stylesheets and they should load properly. I would start looking in /etc/nginx/mime.types and verify that you've mapped the css extension to text/css.
I dont know homestead and I would have posted this as comment but I don't have enough rep for that but maybe changing also the user ownership to www-data would work?
sudo chown www-data:www-data -R projectfolder
Then if it works you may have to change ownership for the storage folder if you are allowing file uploads.

Don't think I have php setup right in nginx virtual host configs

I'm trying to install magento php ecommerce on a virtual server that previously did not have php. When I put simple php pages into a directory they run (for example I have index.php run phpinfo). But when I try to run the magento setup scripts they bomb out without outputting an error. I have two other virtual servers through a different service (running apache) and when I drop the magento files into them the setup pages light up right away and start checking requirements. On my nginx server the only output is a small grey box, but no error output.
My best guess is that I have not configured nginx virtual hosts properly for php.
I am on php5.5 using fpm on Ubuntu 12.04. I don't run a default file in sites-enabled, just two vhost files. Here's the vhost in question (the other site is working fine, but it's python):
server {
listen 80;
listen [::]:80;
#
server_name magento.mydomain.com;
#
root /var/www/magento.mydomain.com/public_html;
index index.php index.html index.htm;
#
# location / {
# try_files $uri $uri/ /index.php =404;
# }
# location / {
# /index.php;
# }
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:8070;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/magento.mydomain.com/public_html/$fastcgi_script_name;
}
}
You can see my commented out location / directives. I have tried those is various fashion. My hunch was that magento was calling php with directory names only (instead of somedir/index.php) so I was messing with those, but it seems like that would be handled by the index directive before the locations.
I'm pretty green with nginx. Does anyone see anything obvious?

nginx, Magento & Cloudfront

I have inherited a website that is running Magento & nginx. I know virtually nothing about nginx and know a fair amount about Magento. The site is configured to use the Amazon Cloudfront CDN however all of the images, js & css are returning a 301 redirect to the origin site. I have a development site running Apache with the same Magento, MySQL & Cloudfront setup that is functioning correctly with this setup so I am pretty sure it is a problem with the config file for nginx. There have been some rewrites written in to the file and my assumption is that when the request for an asset at skin.mydomain.com is made it is redirecting to www.mydomain.com instead of serving the file from the CDN. I have CNAME records setup for js.mydomain.com, skin.mydomain.com and cloud.mydomain.com that all point to the same Cloudfront CDN. Here is the portion of the nginx config file that would seem to be applicable:
server {
listen 80;
##127.0.0.1:8080
server_name mydomain.com;
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
}
server {
listen 80;
##127.0.0.1:8080 default
## SSL directives might go here
listen 443 default ssl;
ssl_certificate /etc/nginx/
ssl_certificate_key /etc/nginx/
server_name www.mydomain.com;
## *.mydomain.com; Domain is here twice so server_name_in_redirect will favour the www
root /var/www/magento;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ #handler; ## If missing pass the URI to Magento's front handler
expires 30d;
if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)$") {
access_log off;
expires max;
}
port_in_redirect off;
}
Any help would be appreciated as I have been working on this pretty much all day and would like to stop working on it at some point.
Thanks!
It appears the first server directive is forcing a rewrite of the www.
server {
. . .
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
. . .
}

Resources