Deploying Lamp in Centos 7

Source: Internet
Author: User

Deploying Lamp in CentOS 7 (linux,apache,mariadb,php)



Description : Centos 7 replaces MySQL with mariadb, but the PHP connection mariadb still uses the Php-mysql module.

"From Wikipedia"
MARIADB database management System is a branch of MySQL, mainly by the open source community in the maintenance, the use of GPL license. One of the reasons for developing this branch is that after Oracle acquired MySQL, there is a potential risk of shutting MySQL out of the source, so the community uses a branching approach to avoid this risk.
MARIADB is designed to be fully compatible with MySQL, including APIs and command lines, making it easy to be a replacement for MySQL. In the storage engine, the 10.0.9 version uses xtradb (named aria) instead of MySQL's InnoDB.


1. Preparation before installation
Shutting down firewalls and Seliux

    • temporarily close Seliux setenforce=0

    • Temporary shutdown iptables/firewalld systemctl stop Firewalld.service

Temporarily closed, effective immediately, but fails after rebooting the system.

    • Permanently close seliux sed-i s/^selinux=enforcing$/selinux=disabled/g/etc/selinux/config

    • Permanently close iptables systemctl disable Firewalled.service

Permanently closed, does not take effect immediately, but takes effect after the system restarts.


2. Configure the Yum source
See blog:
http://wangjun51.blog.51cto.com/6124567/1260001


3. Deploying Apache

    1. yum Install httpd  //install Apache

    2. systemctl start Httpd.service  //Start Apache now

    3. systemctl enable Httpd.service  //Add Apache to boot from boot

    • Firewall-cmd--zone=public--add-port=80/tcp--permanent

    • Firewall-cmd--reload


4. Deploying MARIADB

    1. yum Install mariadb-server /install mariadb

    2. systemctl Start Mariadb.service

    3. systemctl enable Mariadb.service  //Add mariadb to boot from startup

    • Firewall-cmd--zone=public--add-port=3306/tcp--permanent

    • Firewall-cmd--reload

5. Initialize the MARIADB Administrator password (optional action)

    • mysqladmin-u root password ' 123456 ' //Set Administrator password to 123456, default is empty.


5. Deploying PHP

    1. Yum install php php-mysql //install PHP and connect mariadb module

    2. echo "extension=msql.so" >>/ect/php.ini //Open PHP connection mariadb extension function


6. Verification

    1. Create a test page

cat/var/www/html/test.php
<?php
$conn = mysql_connect ("localhost", "root", "");
if ($conn)
echo "OK";
Else
echo "Fail";
Mysql_close ();
Phpinfo ();
?>

2. Access Testing

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/78/FA/wKiom1aE2ADzuJZkAAGRE6LhDPw340.png "title=" Centos7lamp.png "alt=" Wkiom1ae2adzujzkaagre6lhdpw340.png "/>


7. Fault Handling

Fault 1:

PHP Fatal error:call to undefined function mysql_connect ()

The PHP connection mariadb extension is not turned on.

echo "extension=msql.so" >>/ect/php.ini

Systemctl Restart Httpd.service


Fault 2:

The server ' s fully qualified domain name, using 127.0.0.1. Set the ' server...his message

Apache default site name not set

echo "' ServerName 127.0.0.1 ' >>/etc/httpd/conf/httpd.conf"

Systemctl Restart Httpd.service



This article from "Life in the diligent, not So Ho get" blog, please be sure to keep this source http://wangjun51.blog.51cto.com/6124567/1730441

Deploying Lamp in Centos 7

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.