Ubuntu LAMP and build environment LNMP

Operating environment: Ubuntu 18.04.1

 

Build LAMP environment:

GUI configuration update Ubuntu Source: Open in VMware Ubuntu, in order to open the system settings, and software updates. Choose another site to download from and then select mirrors.ustc.edu.cn under China's entry.

 

Update software and resource package: sudo APT Update && sudo sudo APT APT upgrade dist-upgrade APT autoclean && sudo

 

Remove unwanted software and files: sudo APT APT autoclean && sudo autoremove

 

安装apache:sudo apt install apache2

The default configuration file: /etc/apache2/sites-enabled/000-default.conf

The default installation source location (the site root): / var / www / html

 

Check the apache is turned on: sudo apache2 Service Status

Display active (running) it means is turned on.

Related command:

  Open apache: service apache2 start

  Close apache: service apache2 stop

  Restart apache: service apache2 restart

 

80 apache default port check whether the open: netstat -ntulp | grep 80       

 Port in a listening state is proof has been opened.

 

View Virtual Machine IP address: ip the Add

 

Open a browser external host, fill in the IP address of the virtual machine to access the browser input field:

 

安装mysql:sudo apt install mysql-server

mqsql configuration file: vim /etc/mysql/mysql.conf.d/mysqld.cnf

 

Login mysql database: sudo mysql -u root -p started without a password directly enter into the database.

 

According to the needs of database security settings: sudo mysql_secure_installation  To install the plug-in authentication password do I choose No here?

 

Enter the database password to be set for the root administrator

  

Delete anonymous accounts

 

The root administrator is prohibited from remote login, and here I do not forbid

 

Delete the test database, and remove access rights

 

After setting the refresh authorization form, allowing initialization effective immediately

 

View command to view the root user plugin whether mysql_native_password: the SELECT the User, plugin from the mysql.user;

If not mysql_native_password, but auth_socket, enter the following command to change: Update the mysql.user the SET authentication_string = PASSWORD ( 'your password'), plugin = 'mysql_native_password' where user = 'root';

 

Check the mysql port 3306 is used by default is turned on: netstat -ntulp | grep 3306

Port in a listening state is proof has been opened.

 

Mysql configuration to allow remote access, edit /etc/mysql/mysql.conf.d/mysqld.cnf profile, the bind-address = 127.0.0.1 commented: sudo vim /etc/mysql/mysql.conf.d/mysqld. cnf

 

Enter the mysql database, perform authorization command:

mysql -u root -p

mysql> grant all on *.* to root@'%' identified by '密码' with grant option;

mysql> flush privileges; # refresh permission

mysql> exit

 

Restart apache server: Service apache2 restart

 

Navicat remote connection to an external host open mysql, whether the test was successful:

 

Installation PHP: sudo install PHP APT

 

Test whether php installation: php -v

 

Installation php extension: the sudo php-APT-MOD-PEAR for libapache2 php php-MySQL

 

Php installation components: the sudo the install php-APT-curl php JSON php.cgi

 

Change the apache configuration file: sudo vim /etc/apache2/mods-enabled/dir.conf

Before:

 

After the change, the first visit index.php:

 

Restart the Apache : sudo restart the Apache Service

 

Created under / var / www / html directory a file named index.php and write test code: sudo vim /var/www/html/index.php

 

Open a browser external host, fill in the IP address of the virtual machine to access the browser input field:

 

安装phpmyddmin:sudo apt install phpmyadmin

 

Set the parameters and requirements set in accordance with the installation guide. Select apache2 and click OK:

 

Click Yes to configure phpmyadmin management database:

 

Phpmyadmin specify a password when registering to the database server used:

 

Confirm password:

 

Next, the / usr / bin / share / phpadmin soft link to / var / the WWW / HTML / phpMyAdmin: sudo LN -s / usr / report this content share / phpmyadmin / var / the WWW / HTML / phpMyAdmin

 

Then open php profile json.ini, the front of the second row Notes remove the semicolon: the sudo Vim /etc/php/7.2/mods-available/json.ini

 

Then outside the host browser input field virtual machine IP address / phpMyAdmin access:

 

 

 LNMP built environment

Note: Ubuntu LAMP environment has been set up, on this basis, to build LNMP environment.

Because apache2 and nginx use the same default port, so you need to shut down apache service: Service apache2 STOP

 

安装nginx:sudo apt install nginx

The default configuration file: / etc / nginx / sites-available / default

 

Check the nginx is turned on: sudo nginx Service Status

Display active (running) it means is turned on.

Related command:

  Open nginx: service nginx start

  Close nginx: service nginx stop

  Restart nginx: service nginx restart

 

Query whether to install nginx: nginx -v

 

 

Edit the nginx configuration file: sudo vim / etc / nginx / sites-the Available / default

Modify the parsing file:

Line 41 root / var / www; modified web root is / var / www (may also be modified to other directories)

Php parsing format file:

Line 56 starts amended as follows:

    location ~ \.php$ {

            include snippets/fastcgi-php.conf;

            # With php-fpm (or other unix sockets);

            # fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

            # With php-cgi (or other tcp sockets);

            fastcgi_pass 127.0.0.1:9000;

}

 

Restart nginx: Service nginx restart

 

 /Var/www/html/index.nginx-debian.html will move to the next / var / www rename directory: the sudo Music Videos /var/www/html/index.nginx-debian.html /var/www/index.html

 

Enter the IP address of the virtual machine outside the host browser input field:

 

 

FPM-mounted PHP: the sudo APT the install PHP-FPM

 

 

Edit php configuration file : sudo vim /etc/php/7.2/fpm/pool.d/www.conf

In line 37 add the following code: listen = 127.0.0.1:9000

 

Restart php-fpm Service: Service php7.2-FPM restart

 

In / var / www new info.php, and then modify the file as follows: the sudo Vim /var/www/info.php 

 

 

Open a browser external host, fill in the input field in the browser virtual machine IP address /info.php visit :

 

 

Test whether the database connection is active, a new mysql.php at / var / www directory, change the contents as follows: the sudo Vim /var/www/mysql.php

 

 

Change /etc/php/7.2/fpm/php.ini file: sudo vim /etc/php/7.2/fpm/php.ini

 

Restart php-fpm Service: Service php7.2-FPM restart

 

Enter the external host browser input field virtual machine IP address /mysql.php :

 

 

 

 

Reference blog:

Build LAMP environment Ubuntu18.04

mysql ordinary users without permission connectivity issues

phpmyadmin prompt Solution The mbstring extension is missing the

Ubuntu18.04 desktop environment built LNMP

The page is not working properly are unable to process this request HTTP ERROR 500

The same linux Server install lamp and lnmp

 

Guess you like

Origin www.cnblogs.com/yanxuezhengwanqi/p/11568621.html