Apache running as root instead of user specified in httpd.conf

625

Apache always needs to start as root, then it uses setuid to switch to user context of specified user in httpd.conf.

Without root (uid = 0) you can not create listening socket on privileged ports (below 1024)

For details read this documents:

From first link:

# ps -ef | grep -i http | awk '{print $1}'
root
apache
apache
apache
apache
apache
Share:
625

Related videos on Youtube

Olga
Author by

Olga

Updated on September 18, 2022

Comments

  • Olga
    Olga over 1 year

    I'm trying to render simple bootstrap components using react.

    This is index.html:

    <!doctype html>
    <html>
     <head>
      <script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
      <script src="js/bootstrap.js"></script> 
      <script src="js/react/react.js"></script>
      <script src="js/react/react-dom.js"></script>
      <script src="js/browser.min.js"></script>
      <meta charset="utf-8">
      <title>To Do List</title>
      <link href="css/bootstrap.css" rel="stylesheet">
     </head>
     
     <body>
        <div class="container" id="headContainer">
          <div class="row">
              <div class="col-sm-1">
                  <img src="Panter.jpg" class="img-responsive">
    	      </div>
              <div class="col-sm-8">
                   <h1 style="color:Pink">To do, to do, to doooo</h1>
              </div>
           </div> 
    	   <div id="list">
    	      
    	   </div>
        </div>	
    	<script type="text/babel" src="js/app.js" ></script>
     </body>
    </html>

    This is app.js:

    var ListOfActionsRendering=React.createClass({
       render: function() {
    	   return (	 	    
    	    <div class="accordion" id="listOfActions">
    		   <div class="accordion-group">
    		      <div class="row">
    			     <div class="col-sm-2">
    				    <a class="accordion-toggle" data-toggle="collapse" data-parent="#listOfActions" href="#defaultList">
    		               <h4 id="nameOfGroup"> Основной список </h4>
    		            </a>
    				 </div>
    				 
    				 <div class="col-sm-2">
    				    <div class="btn-group">
    		               <button class="btn" onclick="onEditListOfActionClick()"><i class="glyphicon glyphicon-pencil"></i></button>
    		               <button class="btn"><i class="glyphicon glyphicon-remove"></i></button>
    		            </div>
    				 </div>
    			  </div>
    		   </div>
    		   
    		    <div class="accordion-body collapse in" id="defaultList">
    	            <div class="accordion-inner">
    	                <a href="#defaultList">
    		                <h5>  </h5>
    	                </a> 
    		        </div>
    	        </div>
    		</div>
    		       
            );
       }
    });
    
    ReactDOM.render (
       <ListOfActionsRendering />,
       document.getElementById("list")
    );

    I dont have any errors in chrome console, but components are not shown.

    In snipper I have an Error:

    message: Uncaught SyntaxError: Unexpected token <, filename: http://stacksnippets.net/js, lineno: 16, colno: 6

    • Colin 't Hart
      Colin 't Hart over 11 years
      You're running the check as root and it's showing the command "grep apache" as the process root is running! Try ps -ef | grep apache instead.
    • Windows Ninja
      Windows Ninja over 11 years
      Bah...too early in the morning for stupid mistakes like that. So the user it is running as it "apache" listed at the end?
    • Colin 't Hart
      Colin 't Hart over 11 years
      First column is user.
    • Windows Ninja
      Windows Ninja over 11 years
      So what am I missing here? If httpd.conf specifies apache should run as xxx, why don't I see that when I run this?
    • janneb
      janneb over 11 years
      What you're missing is that apache is not running at all. As mentioned by Colin, the process you're seeing is the grep command you're just executing.
    • Windows Ninja
      Windows Ninja over 11 years
      Sorry, I see what I've done now. Going to update the question to ask things more accurately.
  • Windows Ninja
    Windows Ninja over 11 years
    So am I supposed to let it run as root and then change it on a per site basis to a different user rather than universally? It doesn't really seem secure to let httpd run as root.
  • Windows Ninja
    Windows Ninja over 11 years
    Having read through the link, I've already got this setup correctly. However, I still can't upload to wp-content from WP even with the permissions set to 755. If WP (and httpd) are running as UID 513, as it says it is, shouldn't it be able to upload files without issue?
  • Ken S.
    Ken S. over 11 years
    @CrabbyAdmin which users is the owner for the wp-content/ directory? It should be the apache user (513 in your case). <code>chown -R 513 wp-content/ </code> should do it for you.
  • mig81
    mig81 over 11 years
    @CrabbyAdmin please post ls -ld wp-content
  • Windows Ninja
    Windows Ninja over 11 years
    <pre>ls -l wp-content</pre> shows that the user and group are set to the same as what the httpd user uses...the only difference is that is shows the actual user name here instead of the UID (513).
  • Windows Ninja
    Windows Ninja over 11 years
    ls -ld wp-content output: drwxr-xr-x 9 xxx yyy 4096
  • mig81
    mig81 over 11 years
    @CrabbyAdmin : is xxx equals to 513/httpd?
  • Windows Ninja
    Windows Ninja over 11 years
    Sorry to waste your time, but I just figured out what is going on. The initial permissions are fine but for some reason, WP is changing the permissions of files after they are uploaded (to 533) so files can't be overwritten with the new permissions. I'm not sure why it is doing that, but it is a different question. I'll award the answer to you though as it would have solved things had this been the true issue.
  • thinhvo0108
    thinhvo0108 almost 7 years
    You're welcome, if you think my answer is useful, please consider an up-vote, too, thanks! If you have further issues with reactjs, you can let me know, I will try to help if I can!