Php nginx control solution

Source: Internet
Author: User
Php has been manipulating nginx for a question... the current nginx. php script is used to manipulate nginx. Such as start, stop, restart, and so on. Php and nginx are not root permissions. Using the execsystem function, some basic lscp commands are okay. Kill-INT 'cat/usr/local/nginx/logs/nginx. Pi'; how to control nginx in php
I asked a question...

The current nginx. php script is used to manipulate nginx.
Such as start, stop, restart, and so on.

Php and nginx are not root permissions.
Use the exec system function,
Some basic ls cp commands are okay.

Kill-INT 'cat/usr/local/nginx/logs/nginx. Pi ';
No tests can be performed.
Cat/usr/local/nginx/logs/nginx. pid is okay, that is, the kill command cannot be executed,
It is estimated that the kill permission is incorrect.


We also assume that nginx can be stopped. Nginx. php cannot run on its own. it is up to the server to start nginx.
To ensure that nginx. php runs properly, how can this problem be solved?

Is a new port or process required?
If you have experience in this area, give me some advice.
Or you can give some materials to learn.




------ Solution --------------------
Http://www.osseye.com /? P = 295
I hope this article will be helpful.
------ Solution --------------------
It is also a permission issue, which deserves attention. wait for a while to solve it ~~
------ Solution --------------------
Try chmod 755
------ Solution --------------------
Is it feasible to write a shell and use php to call this shell?

I want to clean the bbon... I want my brother to clean up the Chinese text of 1500...
------ Solution --------------------
Of course, you cannot use the web interface --..

Write a php script and use ssh to remotely execute nginx restart and close on the server. Related interfaces:
Http://cn.php.net/ssh2,server sshdservice is opened.

In this way, the permission will be related to your ssh user, and you can use the appropriate user ssh to execute command.

SYNOPSIS
# Include

Int kill (pid_t pid, int sig );

For a process to have permission to send a signal to a process designated by pid, unless the sending process has appropriate privileges, the real or
Valid user ID of the sending process shall match the real or saved set-user-ID of the processing process.

This is a Kill permission issue. either you are the root, or you are the same as the real user ID of the nginx process, or you are the same as the user id set for saving the nginx process.

------ Solution --------------------
From the perspective of Nginx C source code implementation, the master process is started by root, and its actual user ID is the file owner. if the setuid after the master bind 80 is switched to another valid user ID, the savfed set-user-ID will be root.

Therefore, if you want to kill nginx, you can either use ssh as the root, or use ssh as the owner of the binary file Nginx, both of which can be kill.

None of the above. you do not have the right to read the working users and working groups written in your nginx configuration file. they are used by the nginx worker process setuid to reduce permissions.
------ Solution --------------------
Discussion

I have learned a little about this ssh2. do you want to log on remotely? The root password ..
I wrote it to someone else and asked someone else to provide the root password.

Reference:

Of course, you cannot use the web interface --..

Write a php script and use ssh to remotely execute nginx restart and close on the server. Related interfaces:
Http://cn.php.net/ssh2,server sshdservice is opened.

In this way, the permission will work with your ss ......

------ Solution --------------------
Discussion

-Rwxr-xr-x 1 root 3874792 Jul 5 :55/usr/local/nginx/sbin/nginx

Can you tell me the method mentioned on the # 1st floor?



Reference:

Reference:

I have learned a little about this ssh2. do you want to log on remotely? The root password ..
I wrote it to someone else and asked someone else to provide the root password.
......

------ Solution --------------------
I don't know what problems have you encountered?
Like other software that provides continuous services, nginx must be started by administrator-level users. Otherwise, the service will be stopped once the user logs out.

You say you use the nginx. php script to manipulate nginx
From the nginx. php file name, it should be run in web mode
But once nginx is stopped, how does nginx. php run?

If it is through shell, why should we do this?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.