It's tumbling today django When I was working on the project, I suddenly came across a bug, At first, it reported an internal server error :“Internal Server Error”, The status of the server is Nginx Open the 8000 port ,uWSGI The service is also starting , Then we start to check , First of all, from the Nginx Lay hands on , Line by line inspection Nginx After the configuration is OK , Restart again , The result is still such a problem , It seems to be the same Nginx It doesn't matter. ; And then I started looking uwsgi Configuration issues , Whether it's modification socket Ports are still increased module Parameters , Can't solve the problem , But if you close uwsgi Words , Will be submitted to the ”502 Bad Gateway“ Error of , And this error represents nginx Reverse proxy configuration succeeded , But the corresponding uWSGI Not activated , So also exclude uWSGI Configuration issues .......
At this time, I realized that checking uwsgi.log journal , therefore sudo vim uwsgi.log Walk up , Sure enough, I saw the error message :
no python application found, check your startup logs for errors
The translation is : Can't find python Applications , Please check the startup log for errors
Combine with the top “No module named django”, It seems that it should be python Environmental problems , Because I installed anaconda Version of python3, There is django Of these modules , And I started django The service should be provided by the server itself python2, So the next step is to modify python The environment variable of .
I started with sudo vim /etc/profile , Add a line at the end of the file :
export PATH=/home/xxx/anaconda3/bin:$PATH
And then update it :source /etc/profile
But it doesn't work
I also tried to delete python2 and Add soft connection , as follows :
sudo ln -sf /home/xxx/anaconda3/bin/python /usr/bin/python
However, it still failed to change the default of the server python Environmental Science
Then try another way to modify the environment variables :
vi ~/.bashrc
The last line you see is this :
‘export PATH=/home/xxx/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin’
And then we're going to get rid of anaconda3 Delete all other environment variables except , And modify it anaconda3 The content of :
‘export PATH=/home/xxx/anaconda3/bin:$PATH’
Finally save and exit , Update again :source ~/.bashrc
go back to django In the project file ,killall -s INT uwsgi Kill all the uwsgi process ,uwsgi --ini uwsgi.ini restart uwsgi,django The project can be accessed normally .
see python edition :python -V
Or enter directly python Console :
You can see that the environment of use has changed to anaconda 了 .
|
|
|
|
.