Review the personal homepage of Apache server configuration

Source: Internet
Author: User

Apache server configuration personal homepage

If you are interested in providing server-hosted websites, you will find that these websites provide personal homepage

Between services. Maybe you envy them and think it's a great technology. In fact, you can complete this project as long as you study it.

Next, we will begin to learn how to implement the www Service function. To put it bluntly, you can enable a hard disk space for a network user to upload a webpage and access it. For apache, You need to enable the following parameters and related personal directory blocks:

# UserDir public_html

Find this line and remove the annotator "#", which enables the user directory. Of course, this is only the switch of the personal directory. You also need to open the personal directory. Find the following lines and remove the annotator.

<Directory/home/*/public_html>

AllowOverride FileInfo AuthConfig Limit

Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

<Limit get post options>

Order allow, deny

Allow from all

</Limit>

<Limitaskt get post options>

Order deny, allow

Deny from all

</Limit10000t>

</Directory>

Next, you need to create a user and add the public_html directory and webpage for testing.

[Root @ localhost ~] # Useradd u1

[Root @ localhost ~] # Cd/home/u1

[Root @ localhost u1] # mkdir public_html

[Root @ localhost u1] # cd public_html

[Root @ localhost public_html] # vi index.html

Hello, this is u1!

Save and exit to test.

[Root @ localhost u1] # links www.centos.org /~ U1/

You don't have permission to access /~ U1 /......

Why? Error? No, it is a permission issue. Check the permissions.

[Root @ localhost public_html] # ls-l

-Rwx ------ root 18 Nov 18 08:15 index.html

In the past, the owner and owner group of index.html were incorrect, and the permissions were not enough. Please modify them as soon as possible.

[Root @ localhost public_html] # chown u1: u1 index.html

[Root @ localhost public_html] # chmod 755 index.html

Now the modification is complete. You can test it. No, not yet. You still have the upper-level directory permission.

[Root @ localhost public_html] # cd

[Root @ localhost home] # chown u1: u1-R u1

[Root @ localhost home] # chmod 755-R u1

The permission has been modified. Now let's test it.

[Root @ localhost home] # links www.centos.org /~ U1/

You don't have permission to access /~ U1 /......

Permission or permission issues. But have you modified it? All are open to 755. Don't worry. SELinux is still available. You also need to modify the SELinux permission.

[Root @ localhost home] # ls-Z | grep u1

Drwsr-xr-x u1: u1 18 Nov 18 08:20 user_u: object_r: user_home_dir_t u1

Above is the security context of SELinux In the u1 directory. But how can I modify it? Don't worry. Let's take a look at the SEContext of the httpd default directory.

[Root @ localhost home] # cd/var/www

[Root @ localhost www] # ls-Z | grep html

Drwxr-xr-x root system_u: object_r: httpd_sys_content_t html

Do you understand? Modify the SEContext of the u1 directory. Use the chcon command to modify the SEContext. If you want to modify the user, add the-u parameter. If you want to modify the type, add the-t parameter. If you modify the role, add the-r parameter. Here, you need to modify the user and type types.

[Root @ localhost home] # chcon-u system_u-t httpd_sys_content_t-R u1

Here, the-R parameter is added for Recursive modification, and u1 and the following directories and files are modified at a time. Next, let's test it again.

[Root @ localhost home] # links www.centos.org /~ U1/

Hello, this is u1!

OK. Our page is displayed. The test is successful!

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.