I am trying to configure nginx and have the following configuration in:
/etc/nginx/sites-enabled/default
server {
server_name firstproj.dev www.firstproj.dev;
root /var/www/firstProj/web;
location / {
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
where both app.php and app_dev.php are files in /var/www/firstProj/web/ folder created by symfony with no further modifications.
firstProj is a symfony project that I am currently working on and what I fail to understand here is:
Why when i access www.firstproj.dev I get
Oops! An Error Occurred The server returned a "500 Internal Server Error".
Why when I access www.firstproj.dev/app_dev.php everything is ok and I can also access my routes (eg: www.firstproj.dev/app_dev.php/homepage works perfectly fine and returns the expected response from the action in my controller)
Why when I access www.firstproj.dev/app.php I get 404 error.
I want it to work with www.firstproj.dev/homepage with no app_dev.php there but I cannot make it work that way.
Furthermore, if I access
http://localhost
I get:
Welcome to nginx!
If you see this page, the nginx web server is successfully installed
and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
I apologize if this is a rather dumb question but I'm a beginner as far server configuration is concerned.
Thank you!
So you're finding that your app_dev.php works but app.php does not work?
I've had this happen in the past and there are a few things worth checking.
Copy the contents of app_dev.php into app.php and see if www.firstproj.dev/app.php or www.firstproj.dev work. If it works then you know it's not a problem with NGINX but instead a problem with your Symfony Setup.
Have you created a cache or logs directory for prod or only for dev? Are they writable by www-data?
Have you checked /var/log/nginx/project_error.log to see if any error is showing up when trying to access app.php?
At the top of the app.php file add in the line error_reporting(E_ALL);. Now when you try to access the production version do you see any error?
Try clearing the cache for production. Depending how you have you server setup (Are you using ACL or CHOWN/CHMOD for your cache/log files?) You can run something like sudo su -u www-data php bin/console cache:clear --env prod
Related
I installed Cachethq to have a status page on a server (LAMP) by following this tutorial but I had to use another port (localhost:8080) because I have other services running.
On another server I use Nginx as a reverse proxy to redirect different server/services.
I succeeded to configure Nginx to access cachethq but all the layout does not appear, so I am looking into the fact that I need to redirect php requests to my install server.
I found here several articles and tested different config without success. In addition I would not want these redirects to impact those of my other servers / services.
I'm quite new to Nginx and Php so thanks a lot for your help.
My Nginx config:
location /redmine {
proxy_pass http://10.160.82.6/redmine;
}
location /MagicInfo {
proxy_pass http://10.160.82.16:7001;
}
location /status {
proxy_pass http://10.160.82.6:8080/index.php;
}
location ~ \.php$ {
fastcgi_pass 10.160.82.6:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
I'm new to FuelPHP and web development in general. I'm trying to redirect a user to a different controller but for some reason I can't get the page to display. The homepage displays fine and if I change the default homepage to the Blog page it displays fine.
Here is the link on the homepage:
<?php echo Html::anchor('blog', 'BLOG'); ?>
Then I have the controller it points too:
class Controller_Blog extends Controller_Template {
public function action_index() {
return Response::forge(View::forge('blog/index', $views,false)->render());
}
When I click the link it takes me to 'mywebsite.com/blog' but it says "Access denied."
Here is my nginx virtual host:
server {
listen 80;
server_name mywebsite.com
index index.php index.html index.html
root /home/me/fuelphp_project/public;
location / {
index index.php
try_files $uri $uri #php_index;
location ~ \.php$ {
deny all;
}
location #php_index {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param FUEL_ENV "production";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
I'm not sure if I haven't setup FuelPHP correctly or it's Nginx. Any help would be much appreciated, thank you.
I managed to get it working. I will post the answer in case anyone else comes along this problem.
For clarification this is on an Ubuntu 16.04 server running Nginx 1.10.0 and php7.0-fpm trying to setup for a Fuelphp project.
Using this page from ytsejam as a guide https://github.com/rajibmp/FuelPHP-Nginx/blob/master/nginx/sites-available/FuelPHP
I changed a few things to suit my situation:
Set the server_name to my server
Set the root folder to the public folder of my fuelphp project
I got rid of fastcgi_param SCRIPT_NAME $script and fastcgi_param PATH_INFO $path_info as they gave me errors complaining about undeclared variables.
the access and error log files are in /var/www/fuelphp/nginxlogs for me
set fastcgi_pass unix:/run/php/php7.0-fpm.sock
listen 80 not sure why it says to set it to port 57
Then I followed the tips given here about further setup for php7.0-fpm: How to find my php-fpm.sock?
I think that was everything. Thank you for your help ytsejam!
Trying to setup Magento2 on my LEMP stack. Was following the instructions here and here (did that after compiling from sources for multiple time since it was hard to fulfill composer requirements for Magento2)
Installed composer
Configured and run php, php-fpm
Did some trivial tests (success)
However, a blank screen is all I get. The nginx configuration
server {
listen 2000;
root /usr/share/nginx/html/magento2;
index index.php;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
The permission set is to -R 777 (test purpose only), user and group is www-data. Was able to run .php scripts, problem applies to Magento2.
Read also some related issues (without any positive results) :
Nginx configuration with Magento 1.8
ngix and php5-fpm blank page
The above query is incomplete the nginx configuration.
Please use the below link configuration of nginx.
http://gotechnies.com/magento2-lemp-nginx-ubuntu/
I try to run a simple Symfony2 application on a virtual machine. I have Nginx on this VM (generated with PuPHPet and Vagrant), but there's a problem.
When I try to access to the demo route /demo (local.dev/Symfony/web/app_dev.php/demo), Nginx force me to download a file. It seems it works the same way when I specify a random route.
I don't know how to solve this problem, I searched while 2 days for a specific configuration of Nginx but I found nothing. Here is my config file for this Symfony app :
server {
server_name test.dev;
root /var/www/local.dev/Symfony/web;
location / {
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
error_log /var/log/nginx/sf-error.log;
access_log /var/log/nginx/sf-access.log;
}
Thanks for your help.
I'm running nginx along with fastcgi-php to get php working for phpmyadmin. (I'm developing with Rails primarily.) I'm running everything from a local server on my network.
The rails app is functional. The login screen for phpmyadmin appears and phpinfo() works as well, but when attempting to login to phpmyadmin, I'm thrown back to the login screen with no visible errors.
I'm assuming I may have misconfigured something with the server or have yet to configure phpmyadmin properly.
Here's the relevant code block in nginx.cong=f
server {
listen 80;
server_name localhost;
root /home/dev/spindle/public;
rails_env development;
passenger_enabled on;`
access_log logs/host.access.log;
fastcgi_index index.php;
location /phpmyadmin{
root /usr/share;
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
set $php_root /home/dev/spindle/public;
if ($request_uri ~* /phpmyadmin) {
set $php_root /usr/share;
}
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
}
}
If all your configurations for phpMyAdmin are correct but the problem still persists, it could be due lack of disk space. If this is the case, you can use df -h to diagnose the space problem.
My scenario was that a cron was used to create mysqldump of a large database until the space ran out. After deleting the sql dumps, phpMyAdmin logged in as it should.
Hope it helps.