Problem Description:
When installing the software on the Liunx system, a large privilege is required, and the general user cannot install it casually. For the sake of convenience, when installing the lamp environment, the whole process is to install various software as root.
Finally the entire environment is installed successfully, but a server such as Apache, if run as root user, there is a large risk, the entire system also has a large security implications.
So decided to add a system user to run the Apache server, added a user named www to the system.
Next, modify the Apache configuration file to change the running user to WWW, as shown in
The Htdocs and logs directories under Apache are then changed to WWW because the Apache server accesses Htdocs and writes log records to the logs directory at run time, so it gives the WWW the rwx permissions for both directories, as shown in
This thought did the above configuration and changes, the use of WWW user identity can normally start the Apache server, did not expect or error, as shown in
Some explanations for the error shown in the above picture:
The previous two lines of information can be used without a tube, the main hint server does not have a qualified domain name, because this is a test environment can be regardless. Through the third row and the fourth row can obviously see is the problem of permissions, probably means that the server started to bind 80 port failed,
Started to find no reason, think it is firewall and selinux problems, but shut down the firewall and selinux problem has not been resolved. Later on-line to find information, see the article, he encountered the problem and my similar, but he is through a normal user call script
Start httpd server, is also reported similar errors, the article mentions that httpd execution requires root permission, that is the phrase inspired me. Because either through the Apachectl or the script to call httpd startup, and ultimately all is to execute httpd this executable file, so
This is the time to see the execution of the script or start apachectl the normal user to httpd this file has no execution rights.
So just go into the/usr/local/apache2/bin/directory and modify the httpd permissions, execute the command
chmod u+s httpd
Modified file permissions as shown
Here is a description of the permissions of the owner of the permission bit in the picture, RWS this means that when an ordinary user without permission to manipulate the file (just like the WWW user in the instance) executes the file or performs other restricted operations on the file, the identity is temporarily switched to the owner of the file.
Identity switch to the owner after the identity of what you want to do, not restricted by the file permissions, note that the identity switch is only temporary, only in the process of execution, and once the execution of the script or process is finished, the identity has switched to a normal user.
After the above permissions are modified, the WWW user can start the Apache server normally.
Record Apache server startup error and workaround