# nginx help please [solved]

## cwc

I've installed nginx on a Raspberry Pi and I like the way it works.

As for my Gentoo box I've run Apache from day 1 along with php. I would like to try nginx and I got 403 Forbidden nginx/1.4.7 right out of the box and a file get downloaded.

I changed the root to /home/user/html

Still no luck.

Any ideas?

I did add the following to /etc/portage/package.keywords/package.keywords.txt 

www-servers/nginx ~x86 (or ~amd64, etc)

Here's my default nginx.conf

```

user nginx nginx;

worker_processes 1;

error_log /var/log/nginx/error_log info;

events {

   worker_connections 1024;

   use epoll;

}

http {

   include /etc/nginx/mime.types;

   default_type application/octet-stream;

   log_format main

      '$remote_addr - $remote_user [$time_local] '

      '"$request" $status $bytes_sent '

      '"$http_referer" "$http_user_agent" '

      '"$gzip_ratio"';

   client_header_timeout 10m;

   client_body_timeout 10m;

   send_timeout 10m;

   connection_pool_size 256;

   client_header_buffer_size 1k;

   large_client_header_buffers 4 2k;

   request_pool_size 4k;

   gzip on;

   gzip_min_length 1100;

   gzip_buffers 4 8k;

   gzip_types text/plain;

   output_buffers 1 32k;

   postpone_output 1460;

   sendfile on;

   tcp_nopush on;

   tcp_nodelay on;

   keepalive_timeout 75 20;

   ignore_invalid_headers on;

   index index.html;

   server {

      listen 127.0.0.1;

      server_name localhost;

      access_log /var/log/nginx/localhost.access_log main;

      error_log /var/log/nginx/localhost.error_log info;

      root /home/cwc/html;

   }

   # SSL example

   #server {

   #   listen 127.0.0.1:443;

   #   server_name localhost;

   #   ssl on;

   #   ssl_certificate /etc/ssl/nginx/nginx.pem;

   #   ssl_certificate_key /etc/ssl/nginx/nginx.key;

   #   access_log /var/log/nginx/localhost.ssl_access_log main;

   #   error_log /var/log/nginx/localhost.ssl_error_log info;

   #   root /var/www/localhost/htdocs;

   #}

}

```

error_log

```
2014/05/06 19:52:00 [notice] 25017#0: signal 15 (SIGTERM) received, exiting

2014/05/06 19:52:00 [notice] 25019#0: exiting

2014/05/06 19:52:00 [notice] 25019#0: exit

2014/05/06 19:52:00 [notice] 25017#0: signal 17 (SIGCHLD) received

2014/05/06 19:52:00 [notice] 25017#0: worker process 25019 exited with code 0

2014/05/06 19:52:00 [notice] 25017#0: exit

2014/05/06 19:52:00 [notice] 25112#0: using the "epoll" event method

2014/05/06 19:52:00 [notice] 25112#0: nginx/1.4.7

2014/05/06 19:52:00 [notice] 25112#0: OS: Linux 3.12.13-gentoo

2014/05/06 19:52:00 [notice] 25112#0: getrlimit(RLIMIT_NOFILE): 1024:4096

2014/05/06 19:52:00 [notice] 25113#0: start worker processes

2014/05/06 19:52:00 [notice] 25113#0: start worker process 25115

```

----------

## cboldt

In the "server" section of your nginx.conf file, the "listen" parameter should be is a port number.

I also notice that you have nginx configured to serve up pages from the /home/cwc/html directory.  Not sure if that is what you intend, but that is where nginx will look for the "index.html" home page.

This works for me ...

```
server {

   listen 80;

   server_name involute.curvate.net;

   access_log /var/www/log/nginx-localhost.access_log main;

   error_log /var/www/log/nginx-localhost.error_log info;

   root /var/www/localhost;

}
```

----------

## cwc

got *.html files to work now php does not work

I removed apache2 and tried to re-emerge php with errors

my php package.use text is:

dev-lang/php fpm pdo mysql mysqli -apache2  berkdb bzip2 cli crypt ctype exif fileinfo filter fpm gdbm hash iconv ipv6 json ldap mysql mysqli nls opcache pdo phar posix readline session simplexml spell sqlite ssl threads tokenizer truetype unicode xml zlib -apache2 

error for emerge

```

emerge php

Calculating dependencies -

!!! Problem resolving dependencies for dev-lang/php

... done!

!!! The ebuild selected to satisfy "php" has unmet requirements.

- dev-lang/php-5.5.10::gentoo USE="berkdb bzip2 cli crypt ctype exif fileinfo filter fpm gdbm hash iconv ipv6 json ldap mysql mysqli nls opcache pdo phar posix readline session simplexml spell sqlite ssl threads tokenizer truetype unicode xml zlib -apache2 -bcmath -calendar -cdb -cgi -cjk -curl -debug -embed -enchant -firebird -flatfile (-frontbase) -ftp -gd -gmp -imap -inifile -intl -iodbc -kerberos -ldap-sasl -libedit -libmysqlclient -mhash -mssql -oci8-instant-client -odbc -pcntl -postgres -qdbm -recode (-selinux) -sharedmem -snmp -soap -sockets (-sybase-ct) -systemd -sysvipc -tidy -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xslt -zip"

  The following REQUIRED_USE flag constraints are unsatisfied:

    truetype? ( gd ) exif? ( gd )

  The above constraints are a subset of the following complete expression:

    truetype? ( gd ) cjk? ( gd ) exif? ( gd ) xpm? ( gd ) gd? ( zlib ) simplexml? ( xml ) soap? ( xml ) wddx? ( xml ) xmlrpc? ( any-of ( xml iconv ) ) xmlreader? ( xml ) xslt? ( xml ) ldap-sasl? ( ldap ) mhash? ( hash ) phar? ( hash ) libmysqlclient? ( any-of ( mysql mysqli pdo ) ) qdbm? ( !gdbm ) readline? ( !libedit ) recode? ( !imap !mysql !mysqli ) sharedmem? ( !threads ) !cli? ( !cgi? ( !fpm? ( !apache2? ( !embed? ( cli ) ) ) ) )

```

nginx.conf

```

        server {

                 listen 80;

                server_name localhost azzerare;

                access_log /var/log/nginx/localhost.access_log main;

                error_log /var/log/nginx/localhost.error_log info;

                root /home/cwc/html;

                location ~ \.php$ {

                       # Test for non-existent scripts or throw a 404 error

                       # Without this line, nginx will blindly send any request ending in .php to php-fpm

                       try_files $uri =404;

                       include /etc/nginx/fastcgi.conf;

                       fastcgi_pass unix:/run/php-fpm.socket;

                }

        }

```

----------

## cwc

502 Bad Gateway

nginx/1.4.7

I get the above error when I hit the test.php page.

php is broken.

----------

