I have project which uses nginx and php-fpm container.
In docker-compose, I can use this nginx setting fastcgi_pass php:9000;
(php is container name of php-fpm)
in nginx.conf
server {
listen 80;
server_name xxx.example.com;
index index.php index.html index.htm;
root /var/www/public;
client_max_body_size 200M; # 413 Request Entity Too Large
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
#fastcgi_pass 0.0.0.0:9000;
#fastcgi_pass unix:/var/run/php-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
However now I want to use set(nginx, php-fpm in ECS.
In Ecs there is not container name.
And php-fpm container accept only
netstat -an|grep LISTEN
tcp6 0 0 :::9000 :::* LISTEN
Now, I tried few patterns in nginx.conf
fastcgi_pass php:9000;
#fastcgi_pass 0.0.0.0:9000;
#fastcgi_pass unix:/var/run/php-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
but either one doesn't work.
How can I set?
Related
My domain is on AWS server with Bitnami Nginx installation. My goal is to create a subdomain for the test laravel application. Is this the correct bitnami.conf setting?
domain with certificates https://example.com
subdomain without certificates http://dev.example.com
/opt/bitnami/nginx/conf/bitnami/bitnami.conf:
#Rewrite any http requests for (www)example.com to https version.
server {
server_name www.example.com example.com;
return 301 https://example.com$request_uri;
}
#redirect block
server {
listen 443;
ssl_certificate "/etc/lego/certificates/example.com.crt";
ssl_certificate_key "/etc/lego/certificates/example.com.key";
server_name www.example.com;
return 301 https://example.com$request_uri;
}
#The example.com SSL website, main processing block
server {
listen 443 ssl;
ssl_certificate "/etc/lego/certificates/example.com.crt";
ssl_certificate_key "/etc/lego/certificates/example.com.key";
server_name example.com;
root /opt/bitnami/nginx/html/example.com/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_read_timeout 300;
fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
server {
listen 80;
server_name dev.example.com
root /opt/bitnami/nginx/html/dev.example.com/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_read_timeout 300;
fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
What I am working with :
Instance - amazon EC2,
OS - linux AMI,
Web-server - nginx
I have installed phpmyadmin according to what is mentioned in the AWS documentation here
I have mysql up and running, as well as php-fpm and nginx. I also created a symlink between the directory where phpMyAdmin i.e /var/www/html/phpMyAdmin -> /usr/share/nginx/www/html
below is what I have in my nginx.conf file
server{
listen 80;
server_name localhost;
root /var/www/html/phpMyAdmin;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
#location ^~ /phpMyAdmin/ {
# root /var/www/html/phpMyAdmin;
# index index.php;
# include fastcgi_params;
# fastcgi_pass unix:/var/run/php-fpm.sock;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME script/$fastcgi_script_name;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www/html/phpMyAdmin;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
But none of this seems to work. I am trying from hours but unable to figure out what may be the problem due to which its not working. any help would be really great. Thanks !
You can try with below vhost config file. Error page redirection handling appears a problem with your config file.
server {
listen 80;
root /var/www/html/phpMyAdmin; # Change the PHPMyAdmin location
index index.php;
server_name default_server;# Set server name based on sub-domain
access_log /var/log/nginx/phpMyAdmin-access.log;
error_log /var/log/nginx/phpMyAdmin-error.log notice;
charset utf-8;
error_page 404 403 500 502 503 504 /index.php;
location / {
try_files $uri $uri/ /index.php?$args;
access_log off;
expires max;
}
location ~* .(jpg|jpeg|png|gif|ico|css|js|ico|swf)$ { expires 365d; access_log off; log_not_found off;}
location = /favicon.ico { log_not_found off; access_log off; allow all; }
location = /robots.txt { access_log off; log_not_found off; allow all; }
location ~ \.php$ {
expires off;
fastcgi_read_timeout 600;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/phpmyadmin.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
I managed to make my index.php script to run properly when I get a url like:
http://myserver.com/?something.m3u8
Still, I need to remove the ? from it.
Any ideas?
My Nginx config looks like:
server {
listen 6868 default_server;
root /var/tmp/mfl;
index index.php;
# Make site accessible from http://localhost/
server_name localhost;
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;
}
Apparently is was an one line solution
location / {
try_files $uri $uri/ /index.php?$args; #appended this line
}
I have a django running on example.com, i need add a Wordpress to my server, would be example.com/blog, perhaps doesnt work (404 error):
listen 80;
server_name www.example.com;
location ^~ /blog/ {
root /www/blog;
index index.html index.htm index.php;
try_files $uri =404;
location ~ \.php {
root /www/blog;
fastcgi_split_path_info ^(.*\.php)(.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
}
}
location / {
uwsgi_pass unix:/tmp/myapp.sock;
include /www/webapp/system/uwsgi_params; # the uwsgi_params file you installed
uwsgi_read_timeout 300;
}
I ran in this problem too. Here, you can check my location config.
location /blog {
root /var/www/html;
try_files $uri $uri/ /blog/index.php?$args;
index index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
Adapted for your config:
location /blog {
root /www/blog;
try_files $uri $uri/ index.php?$args;
index index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
#Levi configuration give me some light, i need to modify because i'm getting 404 error or No input file especified.
location /blog {
alias /www/blog;
try_files $uri $uri/ index.php?$args;
index index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /www/blog$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
I recently had a server copied over from the previous host to an AWS server. The server is Ubuntu 14.04 and the project that I am trying to run is a Laravel 5 project. I have installed nginx as the web server, here is the default file in sites available and sites enabled:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root web/project/public;
index index.php index.html index.htm;
server_name server_domain_or_IP;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =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;
}
}
I have set cgi.fix_pathinfo = 0; in my php.ini file, as I was instructed to do.
There is a directory called "web" in which the project lives, and inside of the project folder lies the "public" directory.
When I try to go to the server's IP I get a 404 Not Found Error.
Any thoughts as to what may be going wrong?