Solve the Problem of LNMP environment 7.1 File not found on CentOS 404.

Source: Internet
Author: User
Tags php website

Solve the Problem of LNMP environment 7.1 File not found on CentOS 404.

Set the LNMP runtime environment built on CentOS 7 and 7.1 to/srv/www/default in the root directory of the PHP website.

When you start php-fpm with systemctl, the browser reports a 404 error.

File not found.

However, using the root permission to manually start with the php-fpm-D command is normal.

After careful troubleshooting several times, it turns out that SELinux is playing a strange role. Let's take a look at the introduction of SELinux:

Security Enhanced Security-Enhanced Linux (SELinux) is a force Access Control (MAC) Security mechanism in the kernel. SELinux first appeared in CentOS 4 and made significant improvements in subsequent CentOS releases. These improvements mean that the way to solve the problem with SELinux also changes over time. SELinux is more compliant with the minimum permission concept. In the default enforcing case, everything is rejected, followed by a series of exceptional policies that allow access required for each element (Service, program, user) of the system to operate. When a service, program, or user attempts to access or modify a file or resource that it does not need, its request is rejected and this action is recorded. Because SELinux is used in the kernel, SELinux can be used for applications without special writing or rewriting. Of course, if a program pays special attention to the SELinux Error Code mentioned later, its operation may be smoother. If SELinux blocks an action, it reports a standard (at least regular) "Access Denied" error to the application. However, many applications do not test the error codes returned by system functions, so they may not output messages to explain the problem or output error messages.

SELinux has three basic operation modes, in which Enforcing is the default mode. In addition, it has a targeted or mls modifier. The SELinux rule is widely used, with targeted being loose.

Enforcing: This default mode enables and implements SELinux security policies on the system, and denies access and records actions.

Permissive: in Permissive mode, SELinux is enabled but security policies are not implemented. Instead, SELinux only sends warnings and records actions. Permissive mode is useful in troubleshooting SELinux problems.

Disabled: SELinux has been Disabled

Run the sestatus command on CentOS 7.1 to view the current running status of SELinux.

SELinux status: enabled
SELinuxfs mount:/sys/fs/selinux
SELinux root directory:/etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28

We can see that the current Enforcing mode is running.

View the SELinux configuration file

$ Cat/etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX = can take one of these three values:
# Enforcing-SELinux security policy is enforced.
# Permissive-SELinux prints warnings instead of enforcing.
# Disabled-No SELinux policy is loaded.
SELINUX = enforcing
# SELINUXTYPE = can take one of these two values:
# Targeted-Targeted processes are protected,
# Minimum-Modification of targeted policy. Only selected processes are protected.
# Mls-Multi Level Security protection.
SELINUXTYPE = targeted

You can see that the Enforcing mode is also running when the instance is started. Use the setenforce command to switch to the Permissive mode.

$ Sudo setenforce 0
$ Sestatus
SELinux status: enabled
SELinuxfs mount:/sys/fs/selinux
SELinux root directory:/etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28

Reuse

Sudo systemctl start php-fpm.service

Start the php-fpm service so that the LNMP service is normal.

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04

Build and install the LNMP production environment in CentOS 6.4

Practical Production Environment-LNMP architecture compilation and installation + SSL encryption implementation

LNMP full-featured compilation and installation for CentOS 6.3 notes

Install LNMP in CentOS 6.3 (PHP 5.4, MyySQL5.6)

Nginx startup failure occurs during LNMP deployment.

Ubuntu install Nginx php5-fpm MySQL (LNMP environment setup)

Related Article

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.