Nginx was serving a index.html fine from /var/www/test/html/ from within the server and also when I curl'd the ip and port like some-ip:8889. Then I installed php because I was going to try serving a php file. After this point I could not curl some-ip:8889 and it was also serving a apache help file instead of the default nginx file when I went to http://some-ip. Here is the /etc/nginx/sites-available/test file:

server {
    listen 8889;
    listen [::]:8889;

    root /var/www/test/html;
    index index.html;

    server_name test.com www.test.com;

    location / {
            try_files $uri $uri/ =404;

Also I linked sites-available/test to sites-enabled/test. I am also using AWS ubuntu image for the server. Any ideas how I can serve the index again on port 8889?

  • Are you sure that Nginx is running? Try using nginx -t to test the configuration. In your question you mention Apache and PHP, but you don't say how they relate to Nginx or port 8889. Nov 8 '18 at 9:27
  • I am pretty sure its up, sudo systemctl status nginx shows it is active. I also did sudo nginx -t and it shows test is successful. I can still curl the default page and test page on port 8889 from within the server. Apache did not exist until I installed php on ubuntu 18.04 as I thought I needed php installed to be able to server php apps via nginx?
    – nealous3
    Nov 8 '18 at 23:08
  • 1
    Well, yes, you need PHP, but not Apache. Nov 8 '18 at 23:19

The major problem was I didn't add the port to the security group. The next thing I needed to do to serve php files was install php-fpm then add to /etc/nginx/sites-available/test:

server {
  location ~ \.php$ {
      include fastcgi_params;
      fastcgi_pass unix:/run/php/php7.2-fpm.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

I restart nginx and php-fpm and that allows php to be served by nginx.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.