[Linux] Linux WEB server set up LAMP (Linux + Apache + MySQL / MariaDB + PHP)

Linux WEB server set up LAMP (Linux + Apache + MySQL / MariaDB + PHP)

OS: Kylin server operating system (and a method similar Cenos)

table of Contents

1.Apache download and install to start

2.PHP installation

3.MariaDB installation

4.Mariadb use

5.phpMyAdmin installation (a MySQL database backend management tools)

6.LAMP topology and the working process


1.Apache download and install to start

Switch to the root user

root$ su
root$ 密码:
root$ 
//安装
root$ yum install httpd -y
//设置开机自启动
root$ systemctl enable httpd
//启动httpd
root$ systemctl start httpd

After the start apache installation is complete, the browser to http: // localhost or a remote computer or http://127.0.0.1 browser enter http: // ip remote server to access the apache home, if there is normal

Note that if remote access, the need to shut down the server-side firewall and the firewall open port 80, otherwise access will fail.

Turn off the firewall command

root$ systemctl stop firewalld

Set up a firewall port 80 open command

root$ firewall-cmd --zone=public --add-port=80/tcp --permanent
root$ systemctl restart firewalld

After installation Apache directory

/ Etc / httpd / conf /: main configuration directory, Apache server configuration information are the main configuration file httpd.conf, including the port number, web hosting, the maximum number of connections, default access paths, and so on.

/etc/httpd/conf.d/: child configuration directory

/ Etc / httpd / log /: apache log logs if problems occur during use apache, error information can be found in the log file

/ Var / www / cgi-bin: cgi default directory publishing

/ Var / www / html: static pages default directory publishing

We create an index.html file in / var / www / html directory, simply set

root$ cd /var//www/html
root$ touch index.html
root$ echo "Hello World" > index.html

We can http: access //localhost/index.html: // localhost or http

2.PHP installation

//安装php
root$ yum install php -y
//安装mysql/mariadb依赖包
root$ yum install php-mysql -y

Let's verify PHP is installed correctly

root$ cd /usr/bin/
root$ echo '<?php echo "Hello PHP";echo "\n";?>' > hello.php
root$ php hello.php

See print out Hello PHP after the installation is successful

3.MariaDB installation

Before installing confirm whether installed on

root$ rpm -q mariadb
未安装软件包 mariadb

Mariadb install the client and server

root$ yum -y install mariadb mariadb-server

Set boot from the start, start mariadb service

root$ systemctl enable mariadb
root$ systemctl start mariadb

View Mariadb Launch OK

root$ ps -e | grep mysql

If you want to uninstall mariadb

root$ yum erase mariadb

4.Mariadb use

root$ mysql -u root -p

Mariadb is a branch of MySQL, the syntax is almost the same

5.phpMyAdmin installation (a MySQL database backend management tools)

root$ yum install phpMyAdmin -y

Be accessed through the website http: // localhost / phpMyAdmin

6.LAMP topology and the working process

LAMP topology Process Reference https://blog.csdn.net/sj349781478/article/details/84224440

    apache achieve the following main functions:

    First: http processing request to construct its own services and other response packet;

    Second: Apache configuration for PHP support response program (or a module by PHP FPM);

    Third: The method for configuring Apache php specific processing procedures, such as by a reverse proxy to php fcgi processing program.

    mariadb achieve the following main functions:

    First: PHP program providing storage of data;

    Second: PHP providing program reads the data (usually considered from the perspective of performance, try to read and write database separation).

    php achieve the following main functions:

    First: providing apache access interface, i.e., CGI or Fast CGI (FPM);

    Second: providing PHP interpreter for the program;

    Third: to provide basic environmental functions mairadb database connection.
 

Published 201 original articles · won praise 46 · views 90000 +

Guess you like

Origin blog.csdn.net/rong11417/article/details/105044750