{"id":13121,"date":"2024-09-25T16:39:06","date_gmt":"2024-09-25T11:09:06","guid":{"rendered":"https:\/\/www.skynats.com\/?p=13121"},"modified":"2025-10-28T12:12:46","modified_gmt":"2025-10-28T06:42:46","slug":"how-to-deploy-apache-in-openshift-environment","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/how-to-deploy-apache-in-openshift-environment\/","title":{"rendered":"How to Deploy Apache in an OpenShift Environment"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">OpenShift is a powerful container orchestration platform that simplifies the deployment and management of containerized applications. This blog will guide you through deploying an Apache HTTP server in an OpenShift environment, highlighting key benefits and steps.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-normal-font-size\" id=\"h-prerequisites\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>OpenShift Cluster: Access to an OpenShift cluster (local or cloud-based).<\/li>\n\n\n\n<li>oc CLI: Install the OpenShift CLI (oc) to interact with your cluster.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-normal-font-size\" id=\"h-setting-up-your-openshift-environment\"><strong>Setting Up Your OpenShift Environment<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Login to OpenShift: Use the following command to log in to your OpenShift cluster:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>oc login https:\/\/&lt;your-openshift-cluster-url&gt; --token=&lt;your-token&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Create a New Project:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>OC new-project apache-demo<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-normal-font-size\" id=\"h-creating-an-apache-deployment\"><strong>Creating an Apache Deployment<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a Deployment Configuration: Create a deployment configuration file, apache-deployment.yaml:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: apache\nspec:\n  replicas: 2\n  selector:\n    matchLabels:\n      app: apache\n  template:\n    metadata:\n      labels:\n        app: apache\n    spec:\n      containers:\n      name: apache\n        image: httpd:2.4\n        ports:\n        containerPort: 80\n        volumeMounts:\n        - name: apache-volume\n          mountPath: \/usr\/local\/apache2\/htdocs\/\n      volumes:\n      - name: apache-volume\n         emptyDir: {}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Deploy Apache: Run the following command to create the deployment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>oc apply -f apache-deployment.yaml<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-normal-font-size\"><strong>Expose the Apache Service<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a Service: To expose Apache, create a service configuration file, apache-service.yaml:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: v1\nkind: Service\nmetadata:\n  name: apache-service\nspec:\n  selector:\n    app: apache\n  ports:\n    - protocol: TCP\n      port: 80\n      targetPort: 80\n  type: LoadBalancer<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Apply the Service Configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>oc apply -f apache-service.yaml<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-normal-font-size\"><strong>Accessing Your Apache Server<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check the status of your service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>oc get services<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Note the external IP or URL provided for Apache service, and navigate to it in your browser to access the Apache server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-normal-font-size\"><strong>Scaling Apache Instances<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">OpenShift allows easy scaling of your application. To scale your Apache deployment, simply run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>oc scale deployment apache --replicas=5<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command adjusts the number of Apache instances running.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-normal-font-size\"><strong>Monitoring and Logs<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check Pod Status:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>oc get pods<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">View Logs: For any troubleshooting, view logs of the Apache pod:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>oc logs &lt;apache-pod-name&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-normal-font-size\"><strong>Conclusion<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Deploying Apache in OpenShift provides robust container management and scaling capabilities. With just a few commands, you can easily set up, expose, and manage your Apache server, leveraging the full power of container orchestration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Need help on how to deploy Apache in an OpenShift environment? Contact us for&nbsp;<a href=\"https:\/\/www.skynats.com\/server-management\/\">server support<\/a>&nbsp;and troubleshooting assistance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenShift is a powerful container orchestration platform that simplifies the deployment and management of containerized applications. This blog will guide you through deploying an Apache HTTP server in an OpenShift environment, highlighting key benefits and steps. Prerequisites Setting Up Your OpenShift Environment Login to OpenShift: Use the following command to log in to your OpenShift [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[42,905],"class_list":["post-13121","post","type-post","status-publish","format-standard","hentry","category-blog","tag-apache","tag-openshift"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/13121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=13121"}],"version-history":[{"count":2,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/13121\/revisions"}],"predecessor-version":[{"id":16413,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/13121\/revisions\/16413"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=13121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=13121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=13121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}