Warning: DocumentRoot error solution

Source: Internet
Author: User
For security considerations during installation, you are prepared to place DocumentRoot in a single partition. Therefore, you have created a directory for the logical partition: /Dmnr set/etc/fstab to: Code :... after the LABEL/Dmnr/Dmnrext3defaults12 directory is created

For security considerations during installation, you are prepared to place DocumentRoot in a single partition. Therefore, you have created a directory specifically for the logical partition:/Dmnr

To mount the partition, set/etc/fstab:

Code :...

LABEL =/Dmnr ext3 defaults 1 2

After the directory is created, upload the website content to www/html under the Directory, and modify/etc/httpd/conf/httpd. conf as follows:

[Php]

...

DocumentRoot "/Dmnr/www/html"

...

  

...

[/Php]

Restart Apache with the following error message:

Code: # service httpd restart

Starting httpd: Warning: DocumentRoot [/Dmnr/www/html] does not exist

[OK]

Of course, the server will not work normally. Apache thinks this is not a directory! However, it is okay to align DocumentRoot "with other directories, and the server can work normally.

Solution:

1. the configuration of SELinux (omitted...) can be referred:

Http://www.chinalinuxpub.com/read.php? Wid = 1010

Http://blog.josesun.org/archives/2004_08/2

2. modify html directory permissions:

1. check the website content directory

[Php]

# Ls-Z/Dmnr/www/html

[/Php]

Status:

[Php]

-Rwxr-xr-x someuser somegroup index. php

...

[/Php]

2. you obviously do not have the SELinux permission, so make the following changes:

[Php]

Chcon-R-t httpd_user_content_t/Dmnr/www/html

[/Php]

Let's look at it again:

[Php]

-Rwxr-xr-x someuser somegroup user_u: object_r: httpd_sys_content_t index. php

...

[/Php]

Restart httpd to run php normally.

III. Database

1. Mysql

However, when the database is read and written, SELinux rejects the request. The permission is as follows:/var/lib/mysql or/var/lib/pgsql:

[Php]

-Rw ---- mysql root: object_r: mysqld_db_t ibdata1

-Rw ---- mysql root: object_r: mysqld_db_t ib_logfile0

-Rw ---- mysql root: object_r: mysqld_db_t ib_logfile1

Drwx ------ mysql root: object_r: mysqld_db_t mysql

Srwxrwxrwx mysql root: object_r: mysqld_var_run_t mysql. sock

Drwx ------ mysql root: object_r: mysqld_db_t test

[/Php]

But under the test database where the data is stored, we can see that the self-built table still does not have the SELinux permission. it doesn't matter. just modify it:

[Php]

Chcon-R-t mysqld_db_t/var/lib/mysql

[/Php]

Note! The SELinux attribute here is mysqld_db_t

2. pgsql

I also opened the PostgreSQL library and failed to modify the attributes using this method. an error is returned:

[Php]

Chcon: cant apply partial context to unlabeled file pgsql/data/base/23456

Chcon: cant apply partial context to unlabeled file pgsql/data/base/12345

[/Php]

In/var/lib/pgsql/data/base, attributes cannot be applied in self-built databases 12345 and 23456. Looking for information is messy and I have no clue for a long time. forget it!

[Php]

# Su-postgres

$ Cd/var/lib/pgsql/data/base

$ Music 12345 12345_ B

$ Cp-r fig 12345

[/Php]

Let's look at it again:

[Php]

Drwx ------ s S postgres user_u: object_r: postgresql_db_t 12345

...

[/Php]

It indicates that the attribute has been added. refresh the page for reading the database. OK!

Finally, I would like to say a few more words. modifying SELinux attributes is annoying, but it is good for security, so it is worth the next time.

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.