首先,在CentOS中建立用户www。
代码如下 |
复制代码 |
groupadd www
useradd --shell /sbin/nologin -g www www
|
其次,在Apache配置文件httpd.conf中设置User,Group。
代码如下 |
复制代码 |
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User www
Group www
|
最后,设置网站文件的用户和用户组为www。
代码如下 |
复制代码 |
#假设网站部署在/home/www下
cd /home/www/
chown -R www:www .
|