Installing LNMP environment under Ubuntu 18.04

Time:2021-12-9

Before writing this article, I tried to install laravel Ubuntu init in the environment of VMware virtual machine Ubuntu 16.04. The installation process was very smooth, but when adding database users, something broke down and made me cry. No matter how I entered the password, I always prompted the wrong password. Later, I really couldn’t stand it. I had to uninstall and reinstall, However, the password error is still prompted when adding database users. Until today, I don’t know the cause of this problem. If there is a great God who knows the cause of the problem, please let me know. Thank you.

Installing LNMP environment under Ubuntu 18.04

Next is the learning process of installing LNMP environment with reference to the online materials. What’s wrong? I hope the great gods don’t beat bricks.

1: Installing nginx
1: Execute command
sudo apt-get install nginx
2: Restart nginx
sudo service nginx restart
3: Enter 127.0.0.1 in the browser and see the nginx welcome page, which proves that the nginx installation is successful

2: Install MySQL
1: Execute command
sudo apt-get install mysql-server mysql-client
2: After installing mysql, the database will set a default user and password. We need to use this default user to log in to the database and modify the root password
3: Execute the following command to view the default user and password
sudo cat /etc/mysql/debian.cnf

! [install LNMP environment under Ubuntu 18.04](https://cdn.learnku.com/uploads/images/201…)

4: Use the above user name and password to log in to the database and change the root password

Installing LNMP environment under Ubuntu 18.04

5: Modify the password of root, refresh the permissions, exit, and restart mysql
1:update mysql.user set authentication_string = password(‘123456′) where user=’root’ and Host=’localhost’
2:update user set plugin=”mysql_native_password”;
3:flush privileges;
4:quit;

6: Open MySQL remote connection
1:sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
2: Note: bind address = 127.0.0.1, or bind address = 0.0.0.0
3: Log in to the database client with root and open the remote connection permission
1:grant all on . to [email protected]’%’ identified by ‘123456’ with grant option;
2: flush privileges;
3: Exit the client and restart mysql
Installing LNMP environment under Ubuntu 18.04

3: Install PHP
1: Install PHP and PHP extensions
php-common php7.2 php7.2-cli php7.2-common php7.2-fpm php7.2-json php7.2-mbstring php7.2-mysql php7.2- opcache php7.2-readline php7.2-xml
2: Configure nginx to parse PHP
1:sudo vim /etc/nginx/sites-available/default
2: Point the root directory to – > root / var / www
3: Remove some comments from location ~. PHP $
4: Save exit
5: Restart nginx sudo service nginx restart
6: Restart PHP sudo service php7.2-fpm restart

Installing LNMP environment under Ubuntu 18.04

3: Create a new info.php file at / var / www / to view the PHP configuration information
sudo vim /var/www/info.php
4: Enter 127.0.0.1/info.php in the browser, and the installation is successful when you see the configuration information of PHP

Installing LNMP environment under Ubuntu 18.04

4: Configure nginx virtual domain name
1: Copy nginx default profile
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/test
2: Edit the copied configuration file, point the root directory to root / var / www / test, and the domain name is server_ Name test.com, nothing else will be changed.
sudo vi /etc/nginx/sites-available/test

Installing LNMP environment under Ubuntu 18.04

3: Delete default profile
sudo rm etc/nginx/sites-available/default
4: After having the test configuration, we need to inform nginx of this configuration:
sudo ln -s /etc/nginx/sites-available/test /etc/nginx/sites-enabled/
5: After executing the above command, we can use nginx – t to detect whether there is an error in the configuration file of nginx:
sudo nginx -t

Installing LNMP environment under Ubuntu 18.04

6: If there are no errors, restart nginx
sudo service nginx restart

Installing LNMP environment under Ubuntu 18.04

7: Virtual domain name configuration succeeded

Installing LNMP environment under Ubuntu 18.04

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Recommended Today

A brief introduction to file import in HTML5

Template, shadow Dom and custom elements make it easier for you to create UI components than before. However, resources such as HTML, CSS and JavaScript still need to be loaded one by one, which is very inefficient. Removing duplicate dependencies is not easy. For example, now loading the jQuery UI or bootstrap requires adding separate […]