Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

nginx 1.4 on Red Hat Enterprise Linux 7

October 22, 2014
Joe Orton
Related topics:
Linux
Related products:
Red Hat Enterprise Linux

    In this post I'm going to talk about using the nginx web server on Red Hat Enterprise Linux 7.  nginx 1.4 was added as a "Tech Preview" in the v1.1 release of Red Hat Software Collections.

    nginx

    Starting from a freshly kickstarted RHEL7 VM, here's how to get going:

    [root@virt-el7scratch ~]# subscription-manager repos --enable rhel-server-rhscl-7-rpms
    Repo 'rhel-server-rhscl-7-rpms' is enabled for this system.

    This enables the Red Hat Software Collections repository in the yum configuration, which is available with most RHEL entitlements.

    [root@virt-el7scratch ~]# yum install nginx14
    ...
    Installed:
      nginx14.x86_64 0:1.1-3.el7
    Dependency Installed:
      gd.x86_64 0:2.0.35-26.el7 nginx14-nginx.x86_64 1:1.4.4-10.el7
      nginx14-runtime.x86_64 0:1.1-3.el7 scl-utils.x86_64 0:20130529-5.el7
    
    Complete!

    That has installed the nginx 1.4 software collection. Like all SCLs, nginx ends up in /opt/rh - specifically /opt/rh/nginx14, but we have a systemd unit file in the correct system location for integration:

    [root@virt-el7scratch ~]# systemctl start nginx14-nginx
    [root@virt-el7scratch ~]# systemctl status nginx14-nginx
    nginx14-nginx.service - The nginx HTTP and reverse proxy server
    Loaded: loaded (/usr/lib/systemd/system/nginx14-nginx.service; disabled)
    Active: active (running) since Thu 2014-10-09 12:28:39 BST; 47s ago
    Process: 10346 ExecStart=/opt/rh/nginx14/root/usr/sbin/nginx (code=exited, status=0/SUCCESS)
    Process: 10345 ExecStartPre=/opt/rh/nginx14/root/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
    Main PID: 10348 (nginx)
    CGroup: /system.slice/nginx14-nginx.service
            ├─10348 nginx: master process /opt/rh/nginx14/root/usr/sbin/nginx
            └─10350 nginx: worker process
    ...
    

    The nginx daemon is running out of the SCL like any other systemd service. Now, I could demo a static page load or a proxy configuration here... but dynamic languages are more fun! Instead I'll pull in another software collection and demo PHP:

    To use PHP from nginx we use FastCGI. So, I'll pull in the FastCGI Process Manager package, "FPM" from the PHP 5.5 software collection, and start that daemon:

    [root@virt-el7scratch ~]# yum install php55-php-fpm
    ...
    Installed:
      php55-php-fpm.x86_64 0:5.5.6-10.el7
    
    Dependency Installed:
      libzip.x86_64 0:0.10.1-8.el7 php55-php-cli.x86_64 0:5.5.6-10.el7
      php55-php-common.x86_64 0:5.5.6-10.el7 php55-php-pear.noarch 1:1.9.4-10.el7
      php55-php-pecl-jsonc.x86_64 0:1.3.5-1.el7 php55-php-process.x86_64 0:5.5.6-10.el7
      php55-php-xml.x86_64 0:5.5.6-10.el7 php55-runtime.x86_64 0:1.1-7.el7
    
    [root@virt-el7scratch ~]# systemctl start php55-php-fpm
    [root@virt-el7scratch ~]# systemctl status php55-php-fpm
    php55-php-fpm.service - The PHP FastCGI Process Manager
      Loaded: loaded (/usr/lib/systemd/system/php55-php-fpm.service; disabled)
      Active: active (running) since Thu 2014-10-09 12:45:00 BST; 1s ago
      Main PID: 10634 (php-fpm)
      Status: "Ready to handle connections"
      CGroup: /system.slice/php55-php-fpm.service
              ├─10634 php-fpm: master process (/opt/rh/php55/root/etc/php-fpm.conf)
              ├─10635 php-fpm: pool www
    ...

    To configure nginx to use FastCGI, we edit the /opt/rh/nginx14/root/etc/nginx/nginx.conf configuration file. There is already a commented-out example for use of FastCGI in the default "http" (port 80) server stanza. Uncomment it and change the SCRIPT_FILENAME parameter to pull straight out of the document root:

         location ~ .php$ {
                  root html;
                  fastcgi_pass 127.0.0.1:9000;
                  fastcgi_index index.php;
                  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                  include fastcgi_params;
              }

    And that's all the configuration that is required! Reload the daemon, and we're off:

    [root@virt-el7scratch ~]# systemctl reload nginx14-nginx
    [root@virt-el7scratch ~]# echo '<?php echo "Hello, worldn"; ?>' > /opt/rh/nginx14/root/usr/share/nginx/html/hello.php
    [root@virt-el7scratch ~]# curl http://localhost/hello.php
    Hello, world
    

    Note that the default document root for nginx is inside the SCL, though this can be changed by amending the "root" directive in nginx.conf.

    Last updated: November 2, 2023

    Recent Posts

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    • Introducing virtualization platform autopilot

    • Integrate zero trust workload identity manager with Red Hat OpenShift GitOps

    • Best Practice Configuration and Tuning for Linux and Windows VMs

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.