Lamp creation and simple application

Source: Internet
Author: User


Linux+apache+mysql/mariadb+perl/php/python a group of open-source software used to build Dynamic Web sites or servers , themselves are independent programs, but because they are often used together, they have an increasingly high degree of compatibility, which together form a powerful Web application platform.

LAMP:

A:apache

M:MARIADB, MySQL

p:php, Perl, Python

LAMMP: make an m a memcached

Requested resource type:

static resources: static content; The client obtains the same resources from the server as the original file;

Dynamic resource: Usually a program file that needs to be returned to the client after the server executes;

httpd+php: Three ways to combine

Modules

Cgi

FastCGI (FPM)

Request flow for dynamic resources:

Request Flow: Client--> (HTTP protocol )--httpd Server --(CGI protocol )--Application Server (program file) --(MySQL protocol )-->mariadb database


operating under CentOS 7:

Package:httpd,php, Php-mysql, Mariadb-server

Note:php requires httpd to use prefork MPM

if not prefork MPM, change/etc/httpd/conf.modules.d/00-mpm.conf to prefork and restart httpd service,PHP started the

Start the service:

Systemctl Start Httpd.service

Systemctl Start Mariadb.server

Restart the httpd service, and then use the httpd-m | grep php

Systemctl restart Httpd.service to see if the PHP module is loaded

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/9C/wKiom1YCHcKTiirPAAEcyOfFIDY937.jpg "title=" image 002. PNG "alt=" wkiom1ychcktiirpaaecyoffidy937.jpg "/>

then change the index.html to index.php in/www/htdocs( The directory of resources in the httpd configuration file) ,then edit, reload the service and test

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/9C/wKiom1YCHgSzI48cAAB3eZHCHgg267.jpg "title=" image 003. PNG "alt=" wkiom1ychgszi48caab3ezhchgg267.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/99/wKioL1YCHiDA49lcAAIupaKJUwo437.jpg "title=" image 004. PNG "alt=" wkiol1ychida49lcaaiupakjuwo437.jpg "/>

This means that the PHP environment is ready.

Open the database server below

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/9C/wKiom1YCHjDQg8SwAAFYjgTVHcI270.jpg "title=" image 000. PNG "alt=" wkiom1ychjdqg8swaafyjgtvhci270.jpg "/>

and then you can connect it directly to MySQL.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/99/wKioL1YCHk7SE1p6AAFAqSzuWZg764.jpg "title=" image 001. PNG "alt=" wkiol1ychk7se1p6aafaqszuwzg764.jpg "/>

then add code to the index.php , connect to the mariadb database, test whether you can connect

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/99/wKioL1YCHmPTdWmGAAC6mQDZnfc158.jpg "title=" image 005. PNG "alt=" wkiol1ychmptdwmgaac6mqdznfc158.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/9C/wKiom1YCHmzCYPopAABebny91jU920.jpg "title=" image 006. PNG "alt=" wkiom1ychmzcypopaabebny91ju920.jpg "/>

Prove the connection was successful.

then put the database service off systemctl stop Mariadb.service, under the connection

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/99/wKioL1YCHnqyIkB0AABgq50TVsQ674.jpg "title=" image 007. PNG "alt=" wkiol1ychnqyikb0aabgq50tvsq674.jpg "/>

this in in CentOS7,the LAMP environment is ready.

You can install some client programs.


Database (mariadb):

Common components of a relational database:

databases: Database

Tables:table

row:row

Columns: Column

Indexes: Index

Views:View

Users: User

Permissions:privilege

stored procedure:procedure

stored functions:function

Trigger:Trigger

Event Scheduler:Eventscheduler

Mysql_secure_installation: Safe initialization


SQL statement: The statement used to manage the database

Database components: Databases, tables, indexes, views, users, permissions

stored procedures, stored functions, triggers, event schedulers

Create a database, design a data table

fields: Field names, data types, data type modifiers, constraints

DDL,DML,DCL

Ddl:create,DROP,ALTER

Dml:insert (REPLACE), DELETE,UPDATE,SELECT

DCL:grant,revoke

CREATE DATABASE [IF not EXISTS] ' db_name '; Create a database

Create user account:

CREATEUSER ' username ' @ ' host ' [identified by ' Password '];

To Delete a user:

Dropuser ' username ' @ ' host ';

Authorized:

permission levels: Manage permissions, databases, tables, fields, storage routines;

Grantpriv_type,... On [object_type] db_name.tb_name to ' user ' @ ' host ' [identified by ' Password '] [with GRANT OPTION];

Priv_type:all [Privileges]

Db_name.tb_name:

*. *: table of all libraries;

Db_name.*: Specifies all tables for the library;

Db_name.tb_name: Specifies the specified table for the library;

Db_name.routine_name: Specifies the storage routines for the library;

To view the authorizations obtained by the specified user:

Showgrants for ' user ' @ ' host ';

SHOW GRANTS for Current_User;

Reclaim Authorization:

Revokepriv_type, ... On db_name.tb_name from ' user ' @ ' host ';

To create a table:

createtable [IF not EXISTS] ' tbl_name ' (col1 type1, col2 type2, ...)

To Delete a table: droptable [IF EXISTS] ' tbl_name ';

To Modify a table: ALTER TABLE ' Tbl_name '

Index:

An index is a special data structure; A field that defines a lookup condition when it is found;

Index: To have an index name;

To create an index:

CreateIndex index_name on Tbl_name (Index_col_name,...);

To delete an index:

Dropindex index_name on Tbl_name;

The database has a lot of commands.


Here are a few examples to illustrate the creation and application of LAMP

in the implementation of 3 virtual hosts in CentOS7, complete the required functions;

vhost1:pma.stuX.com, PhpMyAdmin, also provides HTTPS services;

Vhost2:wp.stuX.com, WordPress

Vhost3:dz.stuX.com, Discuz

First Confirm LAMP 's basic environment is set up,PHP can access, the database can be connected properly. (The article starts with a demo);

then download phpMyAdmin,WordPress,Discuz

three packages, then unzip and move to the resource directory in the httpd configuration file under that path, i.e. under the/web/vhosts/directory

then change the httpd configuration file to the central host is forbidden, that is (/etc/httpd/conf/httpd.conf) in documentroot this line,

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/9C/wKiom1YCI7ijoKq7AAD25cQJ2_M299.jpg "title=" image 002. PNG "alt=" wkiom1yci7ijokq7aad25cqj2_m299.jpg "/>

then /etc/httpd/conf.d/ Create a virtualhost.conf file, then do 3 virtual hosts, each corresponding to a software

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/99/wKioL1YCJCmDBK69AAH7PeARRm4740.jpg "title=" image 010. PNG "alt=" wkiol1ycjcmdbk69aah7pearrm4740.jpg "/>

To ensure that the <directory "/web/vhosts" in the master configuration file is the same directory as the DocumentRoot file of the virtual host

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/99/wKioL1YCJFWDE8JeAADQxdaoTis312.jpg "title=" image 011. PNG "alt=" wkiol1ycjfwde8jeaadqxdaotis312.jpg "/>

then copy the three software phpMyAdmin wordpress Discuz files to/web/vhosts.

Then configure the configuration files for these software

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/9C/wKiom1YCJHijuj3_AASd69NjPIQ708.jpg "title=" image 005. PNG "alt=" wkiom1ycjhijuj3_aasd69njpiq708.jpg "/>

Then copy the config.sample.inc.php under the PMA to this directory, then change the name to config.inc.php, and then modify the config.inc.php file

Use the command tr-d ' a-za-z0-9 ' </dev/urandom | head-30 | md5sum generate some random numbers, fill them in below, and then save

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/99/wKioL1YCJKCSZXG0AACvgx7yG4k169.jpg "title=" image 006. PNG "alt=" wkiol1ycjkcszxg0aacvgx7yg4k169.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/99/wKioL1YCJjvivN6hAAHEygRjCjc291.jpg "title=" image 008. PNG "alt=" wkiol1ycjjvivn6haaheygrjcjc291.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/99/wKioL1YCJkWR9JOJAAD0WgOwpSI496.jpg "title=" image 007. PNG "alt=" wkiol1ycjkwr9jojaad0wgowpsi496.jpg "/>


then restart the service, setting up the database

First MySQL enters and then sets the password for the root user

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/9C/wKiom1YCKPuyQwhGAAFDx-1ZEoc480.jpg "title=" image 027. PNG "alt=" wkiom1yckpuyqwhgaafdx-1zeoc480.jpg "/>

Then give wpuser authorization to create the user


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/99/wKioL1YCKMnRc704AAIYImWyFeM006.jpg "title=" image 016. PNG "alt=" wkiol1yckmnrc704aaiyimwyfem006.jpg "/>

And then inside the input command flush privileges Sync

This database name password to be the same as in the WordPress software configuration file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/99/wKioL1YCKiyTB_X7AAG1v7j7FfQ511.jpg "title=" image 012. PNG "alt=" wkiol1yckiytb_x7aag1v7j7ffq511.jpg "/>

So the database is ready.

then in the physical machine, modify the hosts file, add

172.16.249.195 pma.stu999.com

172.16.249.195 wp.stu999.com

172.16.249.195 dz.stu999.com


Then access the test under

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/9C/wKiom1YCJ0qCyaR8AAE7mtvkjO4008.jpg "title=" image 012. PNG "alt=" wkiom1ycj0qcyar8aae7mtvkjo4008.jpg "/>

Enter the user name and password to access the database and manage the database.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/99/wKioL1YCK0KgwwPFAANX3TbEs6U130.jpg "title=" image 015. PNG "alt=" wkiol1yck0kgwwpfaanx3tbes6u130.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/99/wKioL1YCJ36B0ntNAAIgvhX3hoI247.jpg "title=" image 013. PNG "alt=" wkiol1ycj36b0ntnaaigvhx3hoi247.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/9C/wKiom1YCJ7qQYHdOAAR3fWLf-3M778.jpg "title=" image 014. PNG "alt=" wkiom1ycj7qqyhdoaar3fwlf-3m778.jpg "/>



under Face pma.stu999.com do https, use the OpenSSL command

first 172.16.249.114 to create a CA, then from the Visa book, and then to the 172.16.249.195 Visa

First Find CA directory, and then generate the private key (umask077 ;OpenSSL genrsa–out Private/cakey.pem 2048 ), and then create your own signature Opensslreq-new-x509-key private/cakey.pem-out Cacert.pem-days 7300

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/99/wKioL1YCK9-z6il9AAQAuTpqfxY869.jpg "title=" image 017. PNG "alt=" wkiol1yck9-z6il9aaqautpqfxy869.jpg "/>

So that your own certificate is created.

then create the certificate on the 172.16.249.195, then go to the CA visa; First create the CSR file and then send it to the CA,and after the CA is signed, it is sent back to 172.16.249.195

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/99/wKioL1YCK_mzxm0aAAPG76mSSb4671.jpg "title=" image 018. PNG "alt=" wkiol1yck_mzxm0aaapg76mssb4671.jpg "/>

send the certificate to Ca

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/9C/wKiom1YCLALQTwUPAAC26PKf3s4801.jpg "title=" image 019. PNG "alt=" wkiom1yclalqtwupaac26pkf3s4801.jpg "/>

the CA signs and then sends back the certificate

to create a file before the CA signs touch index.txt give serial a digital echo 01>serial

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/9C/wKiom1YCLBST7zMpAANCCDlvHbo003.jpg "title=" image 020. PNG "alt=" wkiom1yclbst7zmpaanccdlvhbo003.jpg "/>

the signature was successful and returned to 172.16.249.195.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/99/wKioL1YCLDqxzQL8AAFOr6W6HZw131.jpg "title=" image 021. PNG "alt=" wkiol1ycldqxzql8aafor6w6hzw131.jpg "/>

Then configure the/etc/httpd/conf.d/ssl.conf file in the 172.16.249.195

Specify the path to the certificate and private key

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/9C/wKiom1YCLEiRMmaJAAIuqzmrboc938.jpg "title=" image 022. PNG "alt=" wkiom1ycleirmmajaaiuqzmrboc938.jpg "/>

Add pma.stu999.com This virtual host to the /etc/httpd/conf.d/ssl.conf file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/99/wKioL1YCLFXzcpQgAAEQ88KbnM8515.jpg "title=" image 023. PNG "alt=" wkiol1yclfxzcpqgaaeq88kbnm8515.jpg "/>

and then put the/etc/httpd/conf.d/virtuahost in the pma.stu999.com This virtual host comment out

Restart the service and then The CA 's certificate Cacert.pem is copied out , renamed to Cacert.crt, added to the list of trusted certificates for the physical machine, and tested in the browser settings

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/99/wKioL1YCLH3h-wtTAAFdtYzOnR8975.jpg "title=" image 024. PNG "alt=" wkiol1yclh3h-wttaafdtyzonr8975.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/9C/wKiom1YCLIaBGIriAAMO4fIrslM227.jpg "title=" image 025. PNG "alt=" wkiom1ycliabgiriaamo4firslm227.jpg "/>

so pma.stu999.com this virtual host of HTTPS is ready

So the whole problem is done, this is in my test environment to do, if not CentOS7 may not be the same step.

If there are criticisms and suggestions can leave a message.




Lamp creation and simple application

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.