GithubHelp home page GithubHelp logo

NGINX setup 🆘 about fastsitephp HOT 4 CLOSED

fastsitephp avatar fastsitephp commented on May 18, 2024
NGINX setup 🆘

from fastsitephp.

Comments (4)

ConradSollitt avatar ConradSollitt commented on May 18, 2024

Greetings,

The .sh installer is intended only for new servers running Ubuntu.

Are you able to share the nginx config and setup here? If you cannot share it publicly and are still having issues you can contact me from one of the social sites I'm on - links on my main website: https://conradsollitt.com/

On the main server for FastSitePHP I am using nginx with 5 different domains (including sub-domains). You can see the config here:
https://github.com/fastsitephp/fastsitephp/blob/master/docs/server-setup/nginx-config.txt

Commands for setting up the server are located here:
https://github.com/fastsitephp/fastsitephp/blob/master/docs/server-setup/server-setup.sh

From the above link here is where I setup the nginx config:

# Define nginx Settings
nano nginx-config.txt
# Copy file contents from [nginx-config.txt] and save
# Save using (this applies to all `nano` commands):
#    {control+s} -> {control+x}
sudo cp nginx-config.txt /etc/nginx/sites-available/multi-site
sudo ln -s /etc/nginx/sites-available/multi-site /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
rm nginx-config.txt

Then later in the doc I describe using certbox to install HTTPS
https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal

For the .sh installer you can see the nginx config defined from the code here:
https://github.com/fastsitephp/fastsitephp/blob/master/scripts/shell/bash/create-fast-site.sh#L316

Without seeing your config file I would recommend looking to see if the file /etc/nginx/sites-available/fastsitephp exists. If it does it was installed by the installer and your previous config would likely exist in another file.

For the used config file look for lines starting with server_name and make sure they point to the domain you are setting up. For example, on the main FastSitePHP site I use server_name fastsitephp.com www.fastsitephp.com; so both www and non-www work the playground API service uses server_name playground.fastsitephp.com;.

from fastsitephp.

mrbeandev avatar mrbeandev commented on May 18, 2024

my doubt is that if i am setting the root directory as root /var/www/mysite.com/ and i have installed the fastsitephp with composer in that same direcotry /var/www/mysite.com/. what next should i do ??

i have a index.php file from your examples :

<?php

require 'vendor/autoload.php';

$app = new \FastSitePHP\Application();
$app->setup('UTC');

$app->get('/', function() {
    return 'Hello World!';
});

$app->get('/site', function() use ($app) {
    return [
        'rootUrl' => $app->rootUrl(),
        'rootDir' => $app->rootDir(),
        'requestedPath' => $app->requestedPath(),
    ];
});

$app->get('/cached-file', function() {
    $file_path = __FILE__;
    $res = new \FastSitePHP\Web\Response();
    return $res->file($file_path, 'text', 'etag:md5', 'private');
});

$app->get('/whats-my-ip', function() {
    $req = new \FastSitePHP\Web\Request();
    return [
        'ipAddress' => $req->clientIp('from proxy', 'trust local'),
    ];
})
->filter(function() use ($app) {
    $app
        ->noCache()
        ->cors('*');
});

$app->run();

i am using this code and when i visit mysite.com/whats-my-ip this is what i see
image

and its working fine when i visit /
image

so where is the problem ?

this is my nginx config for this domain

server {
    server_name domain.dev;
    root /var/www/domain.dev;

    access_log /var/log/nginx/access.log;
    error_log /var/www/domain.dev/error.log;

    index index.php  index.html;

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

    location / {
        try_files $uri $uri/ $uri.php?$args;
    }

    location ~ /\.ht {
		deny all;
	}

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/domain.dev/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain.dev/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

}

i am actually using a sub domain in the above config i didnt reveal what my real domain is or what my subdomain is.

from fastsitephp.

ConradSollitt avatar ConradSollitt commented on May 18, 2024

Hi @mrbeandev

I'm sorry for the delay in getting back to you. If you still need help I'll make sure to respond quickly this week and I can also help with detailed testing including modify the Framework code to help solve the issue.

At a glance here are several items to try:

Have you specified the sub-domain in the server_name property?:

    server_name sub.domain.dev;

In my successful server setups I see that I have always specified location / before location ~ \.php$; I currently do not recall nginx priority order for these rules but but it's a difference I noticed.

	location / {
		try_files $uri $uri/ /index.php$is_args$args;
	}            
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
	}

FastSitePHP is designed to handle many different scenarios for server setup (Linux Main Domain, Sub-domain, IIS Main Site, Sub-Directory, etc). If you are still working on this and have trouble please let me know the OS and nginx version so I can try to replicate the issue.

from fastsitephp.

ConradSollitt avatar ConradSollitt commented on May 18, 2024

Closing this out. If you need additional help please let me know.

from fastsitephp.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.