Apache2.4 server personal homepage settings

Source: Internet
Author: User
When configuring the personal homepage of the server, I found that most of the information on the Internet is from the previous version 2.4, which is somewhat different from the apache configuration of the new version. Therefore, I wrote this article. Prepare to view apache version httpd-v my version is 2.4.6, personal homepage related configuration files in etchttpdconf. modules. d00-base.conf and etchttpd

When configuring the personal homepage of the server, I found that most of the information on the Internet is from the previous version 2.4, which is somewhat different from the apache configuration of the new version. Therefore, I wrote this article. Prepare to view the apache version httpd-v. My version is 2.4.6. The configuration files related to the personal homepage are in/etc/httpd/conf. modules. d/00-base.conf and etc/httpd/

When configuring the personal homepage of the server, I found that most of the information on the Internet is from the previous version 2.4, which is somewhat different from the apache configuration of the new version. Therefore, I wrote this article.

Preparations
  • View apache version

    httpd -v

    My version is 2.4.6.
    /etc/httpd/conf.modules.d/00-base.conf
    Andetc/httpd/conf.d/userdir.conf
  • View/etc/httpd/conf.modules.d/00-base.conf, Must haveuserdir_moduleModule, such:

    $ cat /etc/httpd/conf.modules.d/00-base.conf | grep userdirLoadModule userdir_module modules/mod_userdir.so

Modify the apache configuration file
  • Enter/etc/httpd/conf.d/userdir.confSetUserDir disabledAdd comments and cancel 24 rowsUserDir public(You can change the name of the folder after UserDir, for exampleUserDir www)

  • Add the following code/etc/httpd/conf/httpd.confFile

    # Replace name and username as needed
       
        
    AllowOverride NoneOptions Indexes FollowSymLinksRequire all granted
       

    Note that apache2.4 has been canceled.

    Order Deny,AllowAllow from All

    And use

    Require all granted

    To set access to the directory.

  • Set alias

    Alias /name/ "/home/usename/www/" 

Create File root directory
  • Go to the home directory and create a folder www and test page.

    mkdir ~/wwwcd ~/wwwecho "Test home dir" >> index.html

Disable selinux to check whether it can be accessed.

Modify permissions and selinux settings

Enable selinux Service
To allow access to apache Software, you must set the readable and executable permissions for the home directory and www directory, such

$ chmod 755 /home/username$ chmod 755 ~/www -R

In addition, you need to modify selinux settings. OtherwisePermission denied.

$ Ll-Z ~ /# View the context of each directory in the Home Directory

The www directory must haveuser_home_tContent. If no content exists, execute

# chcon -t user_home_t /home/username/www -R

Then, enable the personal homepage permission of the server.

# setsebool httpd_enable_homedirs on

This personal directory can be used to place the code in ~ /^_^ Under the www directory.

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.