fix bug where user could not be nginx

This commit is contained in:
ducoterra
2018-09-13 20:49:09 -04:00
parent cee9975905
commit 5dbd63513e

View File

@@ -138,7 +138,7 @@ echo "Done."
echo "Starting Django project..." echo "Starting Django project..."
if [ ! -d "/home/$user" ] ; then if [ ! -d "/home/$user" ] ; then
mkdir /home/$user mkdir /home/$user
chown $user:$user /home/$user chown -R $user:$user /home/$user
fi fi
mkdir /home/$user/$projectname mkdir /home/$user/$projectname
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
@@ -199,7 +199,7 @@ deactivate
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "Failed to deactivate virtual environment, (this may not be an issue). $djamsg" echo "Failed to deactivate virtual environment, (this may not be an issue). $djamsg"
fi fi
chown -R centos:centos $projectname chown -R $user:$user $projectname
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "Failed to change permissions of $projectname. $djamsg" echo "Failed to change permissions of $projectname. $djamsg"
exit 1 exit 1
@@ -252,8 +252,11 @@ server {
proxy_pass http://unix:/home/$user/$projectname/$projectname.sock; proxy_pass http://unix:/home/$user/$projectname/$projectname.sock;
} }
}" > /etc/nginx/conf.d/mysite.conf }" > /etc/nginx/conf.d/mysite.conf
sed -i "s/user nginx/user $user nginx/" /etc/nginx/nginx.conf # set the nginx user
if [ ! $user = "nginx" ] ; then
sed -i "s/user nginx/user $user nginx/" /etc/nginx/nginx.conf
fi
systemctl restart nginx systemctl restart nginx
systemctl status nginxsetup systemctl status nginx
echo "Done. Logs can be found in /root/logs/" echo "Done. Logs can be found in /root/logs/"