Nginx and Apache on same server

Discussion in 'Installation/Configuration' started by Wideyed93, Nov 14, 2023.

Tags:
  1. Wideyed93

    Wideyed93 New Member

    Hi all,
    New to ISPConfig, I have swapped over from CWP, I have set everything up and put my website back online and I have hit a couple of problems, I have installed ISPConfig with nginx using the auto installer, the website runs wordpress, heavy load as its pulls news feeds etc for a radio station, website went on fine but half of the plugin are not working as they should.

    It got me thinking why is this.....it then clicked that on CWP I was running Nginx, Apache & Varnish.

    I guess this is the issue, so my question is...can I install Apache alongside Nginx?

    Sorry for the long post.
     
  2. remkoh

    remkoh Active Member

    Sure you can. As long as Apache runs on different port(s) than Nginx.
    Only one can run on port 80 and/or 443.

    If you need Apache sites accessible on port 80 and/or 443 too then you would need Nginx to run as proxy in front of Apache.

    Or install a whole other proxy, like HAProxy, and run it on ports 80 and/or 443 and then run both Nginx and Apache on other ports.
     
    ahrasis likes this.
  3. Wideyed93

    Wideyed93 New Member

    Thank you, is there a specific way I would have to install Apache for it to work with the panel or would it know it's there?
     
  4. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Basically there is none supported for now.

    That said, there is however a pending approval code in ISPConfig git which you could try to use both apache2 and nginx in ISPConfig server but it is not advisable to be used in a production server. Do check it out at:
    https://git.ispconfig.org/ispconfig/ispconfig3/-/merge_requests/1703
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    WordPress runs fine on Nginx. There is no need to install Apache, it might just be that you have to add a few Nginx rewrite rules if some of your plugins require that. Plus, a pure Nginx setup is faster and is able to handle higher loads than an Apache + Nginx setup. That's why ISPConfig uses it.

    So, instead of asking to install Apache, a better and easier solution is to add the missing Nginx directives into the Nginx directives field of the website.

    Which Nginx directives have you added to the Nginx Directives field for WordPress at the moment?
     
    ahrasis likes this.
  6. Wideyed93

    Wideyed93 New Member

    Non, I haven't added any as I thought it would just work
     
  7. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    If you need more, read: https://wordpress.org/documentation/article/nginx/
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    WordPress ships with ready-made write rules for Apache web servers in a .htaccess file. But .htaccess files are used by Apache only. For other servers, you must add the equivalent rewrite rules in the right syntax yourself, and that's what @ahrasis pointed you to.
     
  9. Wideyed93

    Wideyed93 New Member

    How would I add the rewrite rules, I have had a look at the link @ahrasis provided but it doesn't say where the file locations would be as it says about "/etc/nginx/nginx.conf" but the file is compleaty different.

    And also the nginx global directory doesn't seem to be there in "/etc/nginx"
     
    Last edited: Nov 17, 2023
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    This is not about nginx.conf file and you do not have to edit any config files at all. Login to ISPConfig, go to the sites module, open the setting of that site, go to the options tab of the website, and paste this into the Nginx directives field:

    Code:
    location / {
                    try_files $uri $uri/ /index.php$is_args$args;
            }
    
            location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                    expires max;
                    access_log off;
                    log_not_found off;
            }
    Then press save.

    Btw. This info is really easy to find on the net, just google "ispconfig wordpress nginx" and you get all the relevant info in the first result.
     
    ahrasis likes this.
  11. Wideyed93

    Wideyed93 New Member

    I have already done that and nothing changed, I done that 3 weeks ago and still having the problems
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, so the normal website URL's all work after you added that, this should be the case. if not, you might have a typo in the rules or you added additional rules that are not valid. Have you checked that the rules were part of the vhost file of the website and there is no file with .err file ending in the nginx sites-available folder? if it's just some special plugins that fail and not normal pages, have you contacted the plugin authors and asked them which additional rewrite rules for Niginx their plugins require?
     
  13. Wideyed93

    Wideyed93 New Member

    The main page of the website works but when you click on any posts its comes up with a 404 error and looking into that it comes up saying about nginx and apache. I have checked the sites-avaliable folder and nothing in the there with .err. I havent checked the vhosts file as I cant find it.

    I got the webiste sat in maintainace mode i can always take it out so you have see what i mean with the 404 errors?
     
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    That you get 404 errors means that the config I posted in #10 is likely not in place yet. So that is most likely not a plugin-related issue. The vhost file is in the folder /etc/nginx/sites-available/, it has the name of the website domain. The config is enabled with a symlink in the folder /etc/nginx/sites-enabled/
     
  15. Wideyed93

    Wideyed93 New Member

    I have attached a screen on the code from the panel, I have restarted the whole server multiple times over the last couple of weeks and still nothing changed
     

    Attached Files:

  16. till

    till Super Moderator Staff Member ISPConfig Developer

    That's a snippet and not the nginx directives field. Please do what I suggested in post #10.
     
  17. till

    till Super Moderator Staff Member ISPConfig Developer

    This is how the options tab of the site looks like after you did what I described in post #10:

    2023-11-17 17_34_55-ISPConfig.png
     
  18. Wideyed93

    Wideyed93 New Member

    That has sorted that out, just got to sort out some plugins now, got there in the end
     

Share This Page