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
Modify the apache configuration file
Enter/etc/httpd/conf.d/userdir.conf
SetUserDir disabled
Add 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.conf
File
# 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
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_t
Content. 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.