preface
NodeJs is a quick way for the front end to get a better understanding of the back end, and the configuration tutorials on the web are scattered, so they’ve been reorganized.
Configure Nginx
- Install Nginx
sudo apt-get install nginx
Copy the code
- Configure Nginx
sudo vim /etc/nginx/sites-available/default
Copy the code
Go to the installation directory of nginx and configure it. The installation directory of nginx may vary from version to version, but it is probably in the same place. If you configure the default directory in the site-available directory, you will find two similar directories: site-available and site-enabled. So why configure in the site-available directory? That’s because site-Enabled is only a soft link directory, similar to the window shortcut, so you can’t change the shortcut.
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
If you want to support HTTPS, change here
You can use the free SSL certificate at https://letsencrypt.org
#listen 443 ssl;
#ssl_certificate www.example.com.crt;
#ssl_certificate_key www.example.com.key;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#ssl_ciphers HIGH:! aNULL:! MD5;
# redirect all HTTP to HTTPS
# rewrite ^(.*)$ https://$host$1 permanent;
# site root directory, modify as needed
root /usr/share/nginx/html;
# increase index. PHP
index index.php index.html index.htm;
# assuming the domain name is www.brandf.cn
server_name www.brandf.cn; # bind domain name
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Copy the code
- You can then follow the command to check whether Nginx starts properly
Run the following command to query the Apache status: sudo service apache2 status Run the apache sudo service apache2 stop Command to query the Apache status: sudo service apache2 Nginx sudo service nginx start sudo service nginx status nginx sudo service nginx statusCopy the code
Ps: If Apache2 is running, ngniX cannot run
- A guy with the same problem found that the reason why Nginx failed to start for half a day was…
- Website optimization configuration
vim /usr/local/nginx/conf/nginx.conf
Copy the code
Gzip
gzip on; // Enable gzip compression gzip_min_length 1k; // Files smaller than 1k do not compress gzip_buffers 4 16k;# gzip_http_version 1.0; // Comment this outgzip_comp_level 5; // The compression level ranges from 1 to 10. The higher the compression level, the smaller the file size. Gzip_types text/plain Application /x-javascript text/ CSS application/ XML text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary off; // Gzip_disable is related to the cache service"MSIE [1-6]\."; // Disable the browser version of the gzip serviceCopy the code
Configuration nodeJs
- Install NodeJs
- Most of the Internet is apt-get this way to download and install
- Apt-get, I don’t know how many years ago I installed NPM version 1.1, nodeJS version 0.1. An interesting episode has been found in the 0.1 version using nodejs instead of Nodejs. A community split in NodeJS may be the main cause of the problem.
- www.infoq.com/cn/articles…
- This directly causes the nodeJS version to be too low and NPM cannot install the package
npm install -g npm
It’s embarrassing that you can’t update yourself.
After unremitting efforts, a universal method was finally found.
- Download the compiled node from the Node website
Wget https://nodejs.org/dist/v4.6.0/node-v4.6.0-linux-x64.tar.xz tar XVF - node - v4.6.0 - Linux - x64. Tar. XzcdThe node - v4.6.0 - Linux - x64. Tar. XzCopy the code
- Copy the installation
sudo cp -r bin include lib share /usr/local/
Copy the code
- Test installation
node -v
Copy the code
- Update the NPM
npm install -g npm
Copy the code
- Install nodeJS version management tool n
npm install -g n
Copy the code
- Update nodeJS to a stable version
n stable
Copy the code
OK, everything is ready, mysql is missing
Configure the Mysql
- Mysql installation
sudo apt-get install mysql-server mysql-client
Copy the code
- Check whether the installation is successful
sudo netstat -tap | grep mysql
Copy the code
- Mysql > select * from navicat; select * from navicat; select * from navicat;
- find
vim /etc/mysql/mysql.conf.d/mysqld.cnf
Configuration files like this are slightly different in location from version to version - Comment with a #
The bind - address = 127.0.0.1
- Restart the service
/etc/init.d/sudo mysql restart
- www.cnblogs.com/patrickding…
- After you set it up, you’ll get a 1045 error. Don’t ask me how I know. Mysql didn’t assign permissions to you
- Enter the directory
cd /etc/init.d
Copy the code
- Enter the mysql
Mysql -h localhost -u root -p // Enter the password set during the installationCopy the code
- Enter the mysql table
mysql>use mysql;
Copy the code
- View permission table
mysql>select host, user from user;
Copy the code
- Grant host x access to the x database at 192.168.1.x with account youruser and password yourpassword
mysql>GRANT ALL PRIVILEGES ON *.* TO 'youruser'@'192.168.1. *' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
Copy the code
- Refresh to make the configuration work
mysql>FLUSH PRIVILEGES;
Copy the code
- You need to cancel the permission
mysql>Delete from user where user = "user_name" and host = "host_name" ;
Copy the code
- Make the configuration work
mysql>FLUSH PRIVILEGES;
Copy the code
All done
Now that the server Node development environment is configured, you are happy to deploy the Node service
Series of portals from scratch
- Re from scratch UI library authoring life specification
- Re from scratch UI library writing buttons for Life
- Re writing forms for Life from scratch UI Library
- Re from scratch UI library writing life table
- Re from scratch UI library writing life loading progress bar
- Re from scratch UI library writing Life pages
- Re from scratch UI library to write life’s menu navigation bar
- Re from scratch UI library writing life messages popover
- Re writing life step Manager from scratch UI library
- Re writing Life’s Bread Crumbs from scratch UI Library
- “Re from scratch webpack4 practical to full practice”
- Efficient React+Redux Project Architecture from Scratch
- Re back-end learning configuration for Ubuntu+Ngnix+Nodejs+Mysql environment from scratch