1

I am trying to establish an Nginx + Apache-with-PHP-module configuration. It worked on Debian 6 with such configuration:

<VirtualHost 127.0.0.1:9002 >
  ServerName mysite.com
  AddDefaultCharset UTF-8
  AssignUserID username username
  CustomLog /var/www/httpd-logs/mysite.com.access.log combined
  DocumentRoot /var/www/username/data/www/mysite.com
  ErrorLog /var/www/httpd-logs/mysite.com.error.log
  AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
  AddType application/x-httpd-php-source .phps
  php_admin_value open_basedir "/var/www/username/data:."
  php_admin_value upload_tmp_dir "/var/www/username/data/mod-tmp"
  php_admin_value session.save_path "/var/www/username/data/mod-tmp"
</VirtualHost>
NameVirtualHost 127.0.0.1:9002
<Directory /var/www/username/data/www/mysite.com>
  Options -ExecCGI -Includes
  php_admin_value open_basedir "/var/www/username/data:."
  php_admin_flag engine on
</Directory>

On a new server I am running Ubuntu 16. When I restart apache2 service and run netstat there is nothing on 127.0.0.1:9002 (even though apache is running). Nginx, as expected, gives connect() failed (111: Connection refused) while connecting to upstream error. I've tried:

  • Changing the port (9002) to any other port
  • Commenting out NameVirtualHost directive and changing VirtualHost 127.0.0.1:9002 to VirtualHost *:9002
  • Disabling firewalld — it was disabled from the beginning
  • Checking if apache does load the .conf file — it does (apache2ctl -S)
Juribiyan
  • 113
  • 3

1 Answers1

2

You should add Listen directive to Apache config. You could find Listen directives in httpd.conf and add there Listen 9002.

More information you could find in Apache documentation.

The Listen directive does not implement Virtual Hosts - it only tells the main server what addresses and ports to listen on. If no directives are used, the server will behave in the same way for all accepted requests. However, can be used to specify a different behavior for one or more of the addresses or ports. To implement a VirtualHost, the server must first be told to listen to the address and port to be used. Then a section should be created for the specified address and port to set the behavior of this virtual host. Note that if the is set for an address and port that the server is not listening to, it cannot be accessed.

Alexander Tolkachev
  • 4,513
  • 3
  • 14
  • 23