Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos 7 deployment and application of LAMP architecture (details can be followed)

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Blog catalogue

I. Overview of the LAMP platform

II. Deploy the LAMP architecture

Deploy the phpMyAdmin system

I. Overview of the LAMP platform

LAMP is an acronym that includes the following:

L:Linux operating system,

A:APache website server,

M:MySQL database server,

P:PHP (or Perl, Python) web programming language,

1. The components of the LAMP platform

Among the four components of the LAMP platform, each component undertakes part of the key applications. After more than ten years of development, the compatibility between the components has been continuously improved, and the writing ability and stability have been continuously enhanced, which can build a very excellent Web application system. The main functions of each component are as follows:

Linux operating system: as the basis of LAMP architecture, it provides an operating system for supporting Web sites, which can provide better stability and compatibility with other three components (AMP components also support windows, UNIX and other operating systems).

APache website server: as the front end of the LAMP architecture, it is a powerful and stable Web server program. The servers provide website access to users, generating web pages, pictures and other file content.

MySQL database server: as the back end of LAMP architecture, it is a popular open source relational database system. In enterprise websites, business systems and other applications, all kinds of account information, product information, customer data and business data can be stored in MySQL database, and other programs can query and change these information through SQL statements.

PHP/Perl/Python web page programming language: as three programming languages for developing dynamic web pages, it is responsible for interpreting dynamic web page files and providing the development and running environment for Web applications. Among them, PHP is a widely used open source multi-purpose scripting language, which can be embedded in HTML, especially suitable for Web application development. 2. Application advantages of LAMP platform

Low cost: the components are all open source software, which can be freely obtained and used free of charge, and there are no strict restrictions on technology and license, which greatly reduces the implementation cost of enterprises.

Customizable: modules with a large number of additional components and expandable functions can meet the customization needs of most enterprise applications, and can even develop and add new functions by themselves.

Easy to develop: in the dynamic website based on LAMP platform, the page code is simple, and the integration with HTML markup language is very good, even non-professional programmers can easily read or even modify the web code.

Easy to use: PHP, Perl and other explanatory languages, the development of various Web programs do not need to be compiled, easy to transplant and use. A complete set of website project programs can be accessed directly as long as they are copied to the website directory.

Security and stability: thanks to the advantages of open source, a large number of programmers are paying attention to and continuously improving the various components of the LAMP platform, and the problems found can be solved quickly. The LAMP architecture has been validated for decades and has performed very well in terms of security and stability.

When building the LAMP platform, the installation order of each component is Linux, Apache, MySQL, PHP. There is no strict sequence for the installation of APache and MySQL, while the installation of the PHP environment is generally placed at the end, responsible for communicating with the Web server and the database system to coordinate the work.

II. Deploy the LAMP architecture

Linux environment can refer to the blog post: making Centos 7.4 operating system template

All CDs used to deploy LAMP can be extracted from the network disk: link: https://pan.baidu.com/s/1TkzHigBOHvFDuLykbukl3w

Extraction code: jsam

1. Install the Apache service

Toggle Linux CD

[root@centos01 ~] # mount / dev/cdrom / mnt/ [root@centos01 ~] # tar zxvf / mnt/httpd-2.2.17.tar.gz-C / usr/src/ [root@centos01 ~] # tar zxvf / mnt/cmake-2.8.6.tar.gz-C / usr/src/ [root@centos01 ~] # tar zxvf / mnt/mysql-5.5.22.tar.gz-C / usr/src/ [root@centos01 ~] # tar zxvf / mnt/php-5.3.28.tar.gz-C / usr/src/ [root@centos01 ~] # tar zxvf / mnt/phpMyAdmin-4.2.5-all-languages.tar.gz-C / usr/src/ [root@centos01 ~] # tar zxvf / mnt/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz-C / usr/ Src/ [root@centos01 ~] # cd / usr/src/httpd-2.2.17/ [root@centos01 httpd-2.2.17] #. / configure-- prefix=/usr/local/httpd-- enable-so-- enable-rewrite--enable-charset-lite-- enable-cgi [root@centos01 httpd-2.2.17] # make & & make install [root@ Centos01 httpd-2.2.17] # ls-ld / usr/local/httpd/ [root@centos01 ~] # ln-s / usr/local/httpd/bin/* / usr/local/bin/ [root@centos01 ~] # cp / usr/local/httpd/bin/apachectl / etc/init.d/httpd [root@centos01 ~] # chmod + x / etc/init.d/httpd [root@centos01 ~] # vim / etc/init.d/httpd #! / bin/sh # chkconfig: 3580 20 # description:apache server [root@centos01 ~] # chkconfig-- add httpd [root@centos01 ~] # chkconfig- -level 35 httpd on [root@centos01 ~] # systemctl start httpd [root@centos01 ~] # systemctl enable httpd [root@centos01 ~] # netstat-anptu | grep 80

Listening to the running state of the port 80 httpd service proves that there is no problem with building the Apache service, and then start building the MySQL database.

2. Install the MySQL service

1) Uninstall the CD

[root@centos01 ~] # umount / mnt/

2) switch the operating system CD

[root@centos01 ~] # mount / dev/cdrom / mnt/ [root@centos01 ~] # rm-rf / etc/yum.repos.d/CentOS-* [root@centos01 ~] # yum-y install ncurses-devel [root@centos01 ~] # cd / usr/src/cmake-2.8.6/ [root@centos01 cmake-2.8.6] # / configure [root@centos01 cmake-2.8.6] # gmake & & gmake install [root@centos01 ~] # groupadd mysql [root@centos01 ~] # useradd-M-s / sbin/nologin mysql- g mysql [root@centos01 ~] # cd / usr/src/mysql-5.5.22/ [root@centos01 mysql-5.5.22] # cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DDEFAULT_CHARSET=utf8-DDEFAULT_ COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all-DSYSCONFDIR=/etc [root@centos01 mysql-5.5.22] # make & & make install [root@centos01 mysql-5.5.22] # chown-R mysql:mysql / usr/local/mysql/ [root@centos01 mysql-5.5.22] # cp support-files/my -medium.cnf / etc/my.cnf cp: overwrite "/ etc/my.cnf"? Y [root@centos01 ~] # vim / etc/profile # / etc/profilePATH= "$PATH:/usr/local/mysql/bin/" [root@centos01 ~] # source / etc/profile [root@centos01 mysql-5.5.22] # cp support-files/mysql.server / etc/init.d/mysqld [root@centos01 mysql-5.5.22] # chmod + x / etc/init.d/mysqld [root@centos01 ~] # chkconfig-- add mysqld [root@centos01 ~] # chkconfig-- level 35 mysqld on [root@centos01 ~] # / usr/local/mysql/scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data [root@centos01 ~] # systemctl start mysqld [root@centos01 ~] # systemctl enable mysqld [root@centos01 ~] # netstat-anptu | grep 3306 [root@centos01 ~] # mysqladmin-u root password New password: Confirm new password: [root@centos01 ~] # mysql-u root-p Enter password:

You can successfully log in to the MySQL database to prove that there is no problem with building the MySQL database, and then start deploying PHP.

3. Install the PHP extension tool library

In practical enterprise applications, some Web applications developed based on PHP will need additional extension tools, such as data encryption tools libmcrypt, mhash, mcrypt and so on (can be downloaded from http://sourceforge.net). These extension tools should be installed before installing the PHP package.

[root@centos01 ~] # yum-y install gd libxml2-devel libjpeg-devel libpng-devel [root@centos01 ~] # umount / mnt/

Toggle LAMP CD

[root@centos01 ~] # mount / dev/cdrom / mnt/ [root@centos01 ~] # tar zxvf / mnt/mcrypt-2.6.8.tar.gz-C / usr/src/ [root@centos01 ~] # tar zxvf / mnt/mhash-0.9.9.9.tar.gz-C / usr/src/ [root@centos01 ~] # tar zxvf / mnt/libmcrypt-2.5.8.tar.gz-C / usr/src/ [root@centos01 ~] # cd / usr/src/libmcrypt-2.5.8/ [root@centos01 libmcrypt-2 .5.8] #. / configure [root@centos01 libmcrypt-2.5.8] # make & & make install [root@centos01 libmcrypt-2.5.8] # ln-s / usr/local/lib/libmcrypt.* / usr/lib [root@centos01 mhash-0.9.9.9] #. / configure [root@centos01 mhash-0.9.9.9] # make & & make install [root@centos01 mhash-0.9. 9.9] # ln-s / usr/local/lib/libmhash* / usr/lib [root@centos01 ~] # cd / usr/src/mcrypt-2.6.8/ [root@centos01 mcrypt-2.6.8] # export LD_LIBRARY_PATH=/usr/local/lib [root@centos01 mcrypt-2.6.8] # / configure [root@centos01 mcrypt-2.6.8] # make & & make install 4, Install PHP [root @ centos01 php-5.3.28] #. / configure-- prefix=/usr/local/php-- with-mcrypt-- with-apxs2=/usr/local/httpd/bin/apxs-- with-mysql=/usr/local/mysql/-- with-mysqli=/usr/local/mysql/bin/mysql_config-- with-config-file-path=/usr/local/php-- enable-mbstring [root@centos01 php-5.3.28] # make & & make install [root@centos01 php-5.3.28] # ls-ld / usr/local/php/ [root@centos01 ~] # cp / usr/src/php-5.3.28/php.ini-production / usr/local/php/php.ini [root@centos01 ~] # vim / usr/local/php/php.ini 174short_open_tag = On 740 post_max_size = 8m 785 default_charset = "utf-8" 883 file_uploads = On 892 upload_max_filesize = 2m 895 max_file_uploads = 20973 Extension=php_mysqli.dll [root@centos01 ~] # cd / usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ [root@centos01 php-5.3.x] # mv ZendGuardLoader.so / usr/local/php/lib/php/ [root@centos01 ~] # vim / usr/local/php/php.ini 2 zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so 3 zend_loader.enable=1 [root@centos01 ~] # vim / usr/local/httpd/htdocs/index.php [root@centos01 ~] # vim / usr/local/httpd/conf/httpd.conf 168 DirectoryIndex index.html index.php 299 AddType application/x-httpd-php .php [root@centos01 ~] # systemctl stop httpd [root@centos01 ~] # systemctl start httpd

In the above configuration command, the meaning of each option is as follows:

-- prefix: specify the directory where the PHP program will be installed. -- with-pcrypt: support for loading extended tools such as data encryption. -- with-apxs2: sets the file location of the apxs module support program provided by Apache HTTP Server. -- with-mysql: sets the installation location of the MySQL database service program. -- with-mysqli: add mysqli extension support. -- with-config-file-path: sets the location where PHP's configuration file php.ini will be stored. -- enable-mbstring: enables the multi-byte string feature to support codes such as Chinese. 5. Test access to php

1) Open the client and set the same network card as the server

2) configure IP address for client

3) access test php

Http://192.168.100.10/index.php

6. Test php and MySQL database work together [root@centos01 ~] # vim / usr/local/httpd/htdocs/index1.php

2) access testing

Http://192.168.100.10/index1.php

Deploy the phpMyAdmin system

PhpMyAdmin is a Web application system written in PHP language and used to manage MySQL database. Through the web interface provided by this suite, even people who are not familiar with SQL statements can easily manage and maintain MySQL databases.

[root@centos01 src] # mv phpMyAdmin-4.2.5-all-languages/ / usr/local/httpd/htdocs/phpMyadmin [root@centos01 ~] # cp / usr/local/httpd/htdocs/phpMyadmin/config.sample.inc.php/usr/local/httpd/htdocs/phpMyadmin/config..inc.php

2) access the phpMyAdmin system

Http://192.168.100.10/phpMyadmin/

3) create a new library with the database name of benet

4) create a new data table with the name student

5) the names in the first column of the table are names, the second column names are gender, the third column names are age, and the fourth column names are job numbers.

6) insert data in student table

7) View the data in the table

[root@centos01 ~] # mysql-uroot-ppwd@123 mysql > use benet; mysql > select * from student +-+ | name | Sex | Age | Job ID | +-+ | Zhang San | male | 20 | 11111111 | +- +-+ 1 row in set (0.00 sec)

-this is the end of this article. Thank you for reading-

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report