Lamp:linux + apache + mysql + php
The root cause of the problem with Linux+php+apache calling Python scripts in the previous essay is that Apache user permissions are not sufficient to use Apache runtime;
The solution is to change Apache to the root user to execute, modify/etc/httpd/conf/httpd.conf, but the result is that Apache does not run up, preliminary
The judgment is that Apache is not allowed to run with the root user for security reasons (this is the correct judgment to be verified).
Specific solutions (verified through):
In sudo settings, the specified user may be set to the root equivalent of the permissions, as follows:
1.sudo Introduction
Sudo is a commonly used Linux tool that allows ordinary users to use superuser privileges, allowing the system administrator to let ordinary users perform some or all of the root commands,
such as Halt,reboot,su and so on. This not only reduces the login and administration time of the root user, but also improves security. sudo is not a substitute for the shell,
It is for each command. There are several main features of this:
§sudo can restrict users from running certain commands on a single host.
§sudo provides a rich log of what each user has done in detail. It can upload logs to a central host or log server.
§sudo uses a timestamp file to perform a similar "ticket-check" system. When the user calls sudo and enters its password, the user obtains a
The lifetime is a 5-minute ticket (this value can be changed at compile time).
The §sudo configuration file is a sudoers file that allows system administrators to centrally administer user permissions and use the host. The location it is stored by default is
In/etc/sudoers, the attribute must be?.
2. configuration file/etc/sudoers
Its main configuration file is under Sudoers,linux usually in the/etc directory, if it is Solaris, the default does not install sudo, compiled after installation usually in the installation directory of the ETC directory,
but no matter where the sudoers file is, sudo provides a command to edit the file: Visudo to modify the file. It is highly recommended to use this command to modify Sudoers,
Because it will help you verify that the file configuration is correct, if it is not correct, you will be prompted to save the exit when the configuration error.
To get to the bottom, here's how to configure Sudoers
First write the default configuration for sudoers:
#############################################################
# sudoers file.
#
# This file must is edited with the ' Visudo ' command as root.
#
# See the Sudoers Mans page for the details about how to write a sudoers file.
#
# Host alias specification
# User alias specification
# CMND alias specification
# Defaults Specification
# User Privilege Specification
root all= (all) all
# Uncomment to allow people in group wheel to run all commands
#%wheel all= (All) all
# same thing without a password
#%wheel all= (All) Nopasswd:all
# Samples
#%users All=/sbin/mount/cdrom,/sbin/umount/cdrom
#%users Localhost=/sbin/shutdown-h Now
##################################################################
1. The simplest configuration, so that ordinary user support has all the root permissions
After executing Visudo, you can see that there is only one configuration by default:
Root all= (All) all
Then you'll add one more configuration to the bottom:
Apache All= (All) all
In this way, the normal user Apache will be able to perform all the commands of root authority
2. Call in PHP, such as: Echo psasswd | Sudo-s python *.py
To enter a password, you need to modify the configuration (/etc/sudoers):
Note #defaults Requiretty
If you do not comment on the line, Sudo:sorry will appear, and you must has a TTY to run sudo print error.
This means: sudo requires a TTY terminal by default, and PHP does not open the terminal when it executes sudo, and commenting out is performed in the background.
Linux+php+apache Web invoke Python script permissions problem solution