Under CentOS LAMP platform and application deployment

In the Internet, to provide a full-featured, scalable enterprise server, it requires not only HTTP server software, database systems, but also inseparable from the support of dynamic web applications. LAMP platform well these services, combined together. As a business operation and maintenance personnel must understand and master's.

LAMP Platform Overview

LAMP architecture is one of the mature enterprise web application mode, refer to the complete set of system and software that work together to provide a dynamic Web site services and application development environment.

LAMP platform constituent components:

  • Linux operating system: as a basis for LAMP architecture, providing an operating system for supporting Web sites can provide better stability with the other three components, compatibility (AMP components also support Windows, UNIX and other operating systems);
  • Apache Web server: as a front end of LAMP, is a powerful, good stability Web server program, the server directly to provide users with access to the site, send web pages, images and other contents of the file;
  • MySQL database server: as a backend LAMP architecture, is a popular open source relational database;
  • PHP / Perl / web programming language pattern as three developing dynamic web programming language, is responsible for interpreting the dynamic page document, and provides a development and runtime environment Web applications. Purpose scripting language PHP open source which is a widely used, it can be embedded into HTML is especially suited for Web application development.

Application advantages LAMP platform

LAMP platform composed of four components, each have gone through the test of several decades-long enterprise applications, each are similar software leader, thus becoming a typical "golden partner." Its main advantages:

  • low cost;
  • customizable;
  • Ease of development;
  • Easy to use;
  • Security and stability.

When building LAMP platform, the installation order of the components were Linux, Apache, MySQL, PHP. Which Apache and MySQL installation order is not strict order requirements; however install PHP environment is generally placed at the end, responsible for communication Web servers and database systems work together.

Apache build service can refer Bowen: CentOS 7 build Web sites using the Apache service ;
build a MYSQL database service can refer Bowen: CentOS 7 compile and install MySQL database system .

The installation is complete APache, MySQL service and start building PHP is the focus of this blog! ! !

PHP installation packages have the required source: libmcrypt-2.5.8.tar.gz, the mhash-0.9.9.9.tar.gz, the mcrypt-2.6.8.tar.gz, PHP-5.5.38.tar.gz, Zend -php5.5-Linux--loader x86_64_update1.tar.gz, phpMyAdmin-4.7.2-All-languages.tar.gz

------------------------------------------Dividing line------ ------------------------------------

Available for download from the following information:

If Unfollow Linux commune public number, even if attention once again, will not be able to provide this service!

Links:  https://pan.baidu.com/s/1hzr7J6InJLGcgqQTY0lwuw  Password: method of obtaining See above, please leave a message at the following address failure.

------------------------------------------Dividing line------ ------------------------------------

Building the PHP runtime environment

First, install the PHP packages

1) Preparations

In order to avoid the phenomenon of conflict program, we recommend that the first RPM installed php and lazy bag unloading in accordance with relevant, such as php, php-cli, php-ldap, php-common, php-mysql and so on. And the mounting plate is present on the system zlib-devel, libxml2-devel and xz-devel RPM package.

[root@localhost ~]# rpm -e php php-cli php-ldap php-common php-mysql --nodeps
错误:未安装软件包 php 
错误:未安装软件包 php-cli 
错误:未安装软件包 php-ldap 
错误:未安装软件包 php-common 
错误:未安装软件包 php-mysql
[root@localhost Packages]# rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm
[root@localhost Packages]# rpm -ivh xz-devel-5.2.2-1.el7.x86_64.rpm 
[root@localhost Packages]# rpm -ivh libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm 

2) install an expansion tool library

In the real business environment, some will require additional tools extend Web applications based on PHP development, such as data encryption tool libmcrypt, mhash, mcrypt and so on. (Link network disk tool has been attached to the beginning of the blog) installed php package of installation should be preceded by data encryption tool, and make a symbolic link.

1. Install libmcrypt

[root@localhost ~]# tar zxf libmcrypt-2.5.8.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/libmcrypt-2.5.8/
[root@localhost libmcrypt-2.5.8]# ./configure && make && make install
[root@localhost libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.* /usr/lib

2. Install mhash

[root@localhost ~]# tar zxf mhash-0.9.9.9.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/mhash-0.9.9.9/
[root@localhost mhash-0.9.9.9]# ./configure && make && make install
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash* /usr/lib

3. Install mcrypt

[root@localhost ~]# tar zxf mcrypt-2.6.8.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/mcrypt-2.6.8/
[root@localhost mcrypt-2.6.8]# ./configure
configure: error: *** libmcrypt was not found
//配置时出现这种错误,应该这样:
[root@localhost mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
//修改环境变量
[root@localhost mcrypt-2.6.8]# ./configure && make && make install

3) compile and install PHP

1. unpack (php source package resource has been attached to the beginning of the blog)

[root@localhost ~]# tar zxf php-5.5.38.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/php-5.5.38/

2. Configure

[root@localhost php-5.5.38]# ./configure \
--prefix=/usr/local/php5 \
--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/php5 \
--enable-mbstring

The above configuration commands, the meaning of each option:
Under CentOS LAMP platform and application deployment

3. Compile and install

[root@localhost php-5.5.38]# make && make install

Install a long time to wait!

Second, set the LAMP components of the environment

1) php.ini configuration adjustments

1.php.ini configuration adjustments
After installing PHP package, the system does not automatically create a php.ini configuration file, but provides two sample configuration files in the source directory:

/usr/src/php-5.5.38/php.ini-development                           //开发版样例文件,用于学习、测试
/usr/src/php-5.5.38/php.ini-production                              //生产办样例文件,用于实际运营

Almost two sample files, select a sample file, and copy the configuration files in the php directory, and renamed the php.ini (file with ";" the beginning of the content expressed annotations).

[root@localhost php-5.5.38]# cp /usr/src/php-5.5.38/php.ini-development /usr/local/php5/php.ini
[root@localhost php-5.5.38]# vim /usr/local/php5/php.ini 
…………                                                          //省略部分内容
default_charset = "UTF-8"                              //设置默认字符集为utf-8
file_uploads = On                                           //允许通过PHP网页上传文件
upload_max_filesize = 2M                             //允许上传的文件大小限制
max_file_uploads = 20                                  //每个HTTP最多允许请求上传的文件数
post_max_size = 8M                                    //每次通过表单post提交的数据量限制
short_open_tag = On                                   //允许识别PHP段语法标记,<?……?>
extension=php_mysqli.dll                            //添加MySQL支持

The above configuration items, default already exists, you can modify! In particular, "short_open_tag = Off", the first one is not screened, and the second is.

2. Add ZendGuardLoader
order to improve the efficiency of PHP optimization program to optimize the speed of the page, you can add ZendGuardLoader Zend developed optimization module for PHP in the real world. (Link network disk optimization module has been attached to the beginning of the blog), optimization module should be noted that this experiment provides the only support PHP 5.3 to PHP 5.6 version of the series, if need other optimization module version, can go to the official website https: // www.zend.com/ download the appropriate version.

[root@localhost ~]# tar zxf zend-loader-php5.5-linux-x86_64_update1.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/zend-loader-php5.5-linux-x86_64/
[root@localhost zend-loader-php5.5-linux-x86_64]# cp ZendGuardLoader.so /usr/local/php5/lib/php
//将源码目录下的模块文件复制到PHP程序i的模块文件夹

And modify the php.ini configuration file, add a statement to load the configuration and enabled modules.

[root@localhost ~]# vim /usr/local/php5/php.ini
…………                //省略部分内容,添加以下内容
zned_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1

2) httpd.conf configuration adjustments

[root@localhost ~]# vim /usr/local/httpd/conf/httpd.conf
//修改Apache服务配置文件
………………                                                //省略部分内容
LoadModule php5_module        modules/libphp5.so                 //Apache调用PHP模块文件,默认存在,不用修改 
<IfModule dir_module>
DirectoryIndex index.html  index.php                                    //添加以支持index.php的首页文件
</IfModule>
AddType application/x-httpd-php .php                                 //手工添加,Apache添加对php文件支持
[root@localhost ~]# systemctl restart httpd                             //重新启动httpd服务

Third, the LAMP test work

Created in the root directory of the site corresponding PHP test page, and then accessed through a browser, displays the results can be judged based on whether the LAMP platform to build success! We were parsed from PHP pages, MySQL database access testing two aspects of PHP pages!

1) to test whether the PHP pages display correctly

[root@localhost ~]# vim /usr/local/httpd/htdocs/test1.php
//在Apache服务器下存放测试配置文件,添加下列内容:
<?php
phpinfo();                      //显示服务器的PHP环境信息
?>

The client browser to access the test (recommended Google or Firefox):
Under CentOS LAMP platform and application deployment
client access success! ! !

2) test PHP page can access MYSQL database

[root@localhost ~]# vim /usr/local/httpd/htdocs/test2.php
<?php
$link=mysqli_connect('localhost','root','123456');                  //连接MySQL数据库
if($link) echo "恭喜你,数据库连接成功!!!";                //连接成功时,返回的消息
mysqli_close($link);                                                              //关闭数据库连接
?>

Client Access test:
Under CentOS LAMP platform and application deployment

Fourth, the deployment of the system PHPMyAdmin

PHPMyAdmin is a PHP language to use to manage Web applications MYSQL database. Even for people who are not familiar with SQL statements can also be very easy to manage and maintain MySQL database through a web interface provided by the suite.

phpMyAdmin source package can be downloaded from the official website https://www.phpmyadmin.net/; You can also use the beginning of the Bowen provides network drive link is acquired.

1) unpacked and moved to the Site Directory

[root@localhost ~]# tar zxf phpMyAdmin-4.7.2-all-languages.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/
[root@localhost src]# mv phpMyAdmin-4.7.2-all-languages/ /usr/local/httpd/htdocs/phpadmin

2) establish the configuration file config.inc.php

[root@localhost src]# cd /usr/local/httpd/htdocs/phpadmin/
[root@localhost phpadmin]# cp config.sample.inc.php config.inc.php

3) access PHPMyAdmin Web management page

Under CentOS LAMP platform and application deployment

Fifth, use PHPMyAdmin system

1) Create a new library, a new table

Under CentOS LAMP platform and application deployment
Under CentOS LAMP platform and application deployment
Under CentOS LAMP platform and application deployment

2) management table and the data records

Under CentOS LAMP platform and application deployment
Under CentOS LAMP platform and application deployment

3) direct the implementation of MySQL query

Under CentOS LAMP platform and application deployment

About PHPMyAdmin system introduced here is not to say, are interested can own research, after all, it is a graphical, easy to implement!

Guess you like

Origin www.linuxidc.com/Linux/2019-08/160182.htm