Linux Fast build Lamp website Platform

Source: Internet
Author: User

1.1 Questions
This example requires a fast build of the lamp dynamic Web platform based on a Linux host and ensures that PHP applications and databases can be supported to accomplish the following tasks:

1) Install the Lamp platform components to start the lamp platform

Packages: httpd, Mariadb-server, mariadb, PHP, Php-mysql
System services: HTTPD, MARIADB
2) write a test page to ensure that the lamp platform is available

Access HTTP.//virtual machine address/test1.php, can display the PHP environment information
Access/HTTP/virtual machine address/test2.php, can report database connection status information
1.2 Solutions
When you turn on network service applications such as WEB/FTP in a CentOS7 system, you may receive security policy effects such as firewall, SELinux, and so on, which are configured by default. To avoid interference, these protection mechanisms are recommended in the learning process.

To turn off firewall policy:

[Email protected] ~]# Systemctl stop Firewalld
[Email protected] ~]# systemctl disable FIREWALLD
Turn off the SELinux protection mechanism:

[[email protected] ~]# Setenforce 0//Switch to loose mode now
[[email protected] ~]# Getenforce//Confirm result
Permissive
[[email protected] ~]# vim/etc/selinux/config//After boot no longer mandatory
Selinux=permissive//Loose mode
1.3 Steps
The implementation of this case needs to follow the steps below.

Step one: Install the lamp platform components, start the lamp platform

1) Install lamp each component package mainly includes: httpd, Mariadb-server, mariadb, PHP, Php-mysql. [[email protected] ~]# yum-y install httpd mariadb-server mariadb php php-mysql. ..                        Installed: mariadb.x86_64 1:5.5.52-1.el7 mariadb-server.x86_64 1:5.5.52-1.el7                          php.x86_64 0:5.4.16-42.el7 php-mysql.x86_64 0:5.4.16-42.el7                         Installed as dependency: libzip.x86_64 0:0.10.1-8.el7 perl-dbd-mysql.x86_64 0:4.023-5.el7                           php-cli.x86_64 0:5.4.16-42.el7 php-common.x86_64 0:5.4.16-42.el7 Php-pdo.x86_64 0:5.4.16-42.el7 finished! 2) Start lamp the corresponding system services include: Web service httpd, database service mariadb. PHP Web page parsing function by the HTTPD service when needed to invoke the corresponding module file implementation, no corresponding service.   [[email protected] ~]# systemctl restart httpd mariadb//from service [[email protected] ~]# systemctl Enable httpd mariadb//Set boot created symlink From/etc/systemd/system/mulTi-user.target.wants/mariadb.service to/usr/lib/systemd/system/ Mariadb.service. Step two: Write a test page to make sure the lamp platform is available 1) test PHP page parsing create a new test page test1.php in the Web server's web directory.                                              [[email protected] ~]# vim/var/www/html/test1.php<?phpphpinfo (); Display PHP Environment information?> through the Firefox browser to access http://127.0.0.1/test1.php, you can see the PHP environment information, 1 shown.

Figure-1

2)测试PHP网页解析及数据库连接在Web服务器的网页目录下新建另一个测试网页 test2.php,其中本机的mariadb数据库服务未做配置时,管理员账号为root、密码为空。[[email protected] ~]# vim  /var/www/html/test2.php<?php    $link=mysql_connect(‘localhost‘,‘root‘,‘‘);    if($link) echo "Success !!";                 //成功则显示 Success !!    else echo "Failure !!";                     //失败则显示 Failure !!    mysql_close();                              //关闭数据库连接?>通过Firefox浏览器访问 http://127.0.0.1/test2.php ,可以看到数据库连接的反馈信息,正常结果页面应显示"Success !!".-2所示。

Linux Fast build Lamp website Platform

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.