Centos7 system changes the default Web site apache directory (solve You do not have permission to access / on this server problems)

When we configure Apache in Centos7, found apache parsing the default directory is / var / www / html, that is to say when accessing local or server IP localhost,

Default to the directory where index.html or index.php file.
If you do not want to use the default directory, we will start work changed:

First, we want to create a directory, I chose to build a www directory under / home

#cd / home / - to enter the home folder
#mkdir www - Create a www folder

Second, modify the apache configuration file, navigate to the / home / www /

#vim /etc/httpd/conf/httpd.conf - open the configuration file with an editor (not installed vim students can use vi)

find DocumentRoot "/ var / www / html " This means #apache the root of the directory into / home / www can be.

To find #define apache / var / www / html this area, the / var / www / html into / home / www,

So we put apahce get rid of the default path.

then:

#systemctl restart httpd.service - restart apache server.

Once completed, access to the host IP, visit a success.

If you see, you do not have permission ... .. what, it is a permissions issue, because some versions of centos default when creating folder permissions are 750,

apache as a foreign user, there is no access, we need to give permission for:

#chmod -R 755 / home / www

At this point, you have successfully moved the apache default directory / home / www / down.

In particular, if your project is using thinkphp framework, but also because the apache add content to cache and logs Runtime folder inside,

Just 755 authority is not enough. So I want to give full access to this directory Runtime:

#chmod -R 777 / home / www / Runtime

will move your project to the directory.

==================================================================================

The reference article from http://blog.sina.com.cn/s/blog_a7cf995a0101azak.html
----------------
original article is CSDN blogger "LSGOZJ": The copyright notice article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/baidu_30000217/article/details/50317819

Guess you like

Origin www.cnblogs.com/hailun1987/p/11486691.html