Ubuntu 16.04 has problems installing the latest stable version of Nginx 1.6.0 and deploying the vue project

Ubuntu 16.04 installs nginx 1.14.0 by default

#Default installation method: apt-get install nginx

1. Check whether nginx is installed, if it is already installed, please uninstall it first

#View the installed version

dpkg -l | grep nginx

#View the installed version

nginx -v

# Uninstall
sudo apt-get remove nginx

2. Check the version code of ubuntu, the output of this command will have a line such as Codename: xxxx, remember this version code, it will be used in the next step

lsb_release -a

3. Use vim to open source.list, add two lines at the end, remember to replace it with your own version code

deb http://nginx.org/packages/ubuntu/ ubuntu上面查到的版本代码 nginx
deb-src http://nginx.org/packages/ubuntu/ ubuntu上面查到的版本代码 nginx

4. Download and import the key

wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key

 

5. Update the apt source and install nginx

sudo apt update
sudo apt install nginx

6. Verification   

nginx -v first start command: nginx

 

The above has successfully installed the latest stable version of nginx through apt. Its configuration file is in the /etc/nginx directory, and the default domain configuration file is in /etc/nginx/conf.d/default.conf.

The vue project is deployed under nginx, access 403, the reason is that nginx does not have permission to access

Open the nginx configuration file and add user root at the beginning

Page style loading failed: the error is: Resource interpreted as Stylesheet but transferred with MIME type text/plain

The solution is to delete the <!DOCTYPE html> declaration on the home page html page

Guess you like

Origin blog.csdn.net/weixin_47385625/article/details/114092175