CENTOS7 (2)-the first time to deploy a PHP project under Linux with the Lamp website Architecture (linux+apache+mysql+php)

Source: Internet
Author: User
Tags install php iptables mysql import

Lamp refers to the Linux (operating system), Apache (HTTP server), MySQL (Database software) and PHP (sometimes referred to as perl or Python) abbreviation, generally used to build a Web server.

(1) Mysql 5.6

1. Download mysql-~]# wget http://dev.mysql.com/get/ mysql-community-release-el7-5.noarch.rpm2. Installing the mysql-server file
~]# RPM-IVH mysql-community-release-el7-5. Noarch.rpm[[email protected] ~]# Yum install Mysql-server
[[email protected] ~]# ls /etc/yum.repos.d/
You can see these two files of Mysql-community.repo,mysql-community-source.repo
[[Email protected] ~] #yum Install Mysql-server
[Email protected] ~]# service mysqld restart

Default blank password after installation, password reset required

[Email protected] ~]# Mysql-uroot
mysql> set password for ' root ' @ ' localhost ' = password (' 123456 ');

# #数据库常用命令: http://www.runoob.com/sql/sql-distinct.html

If database management tools such as Navicat are not connected to CentOS MySQL, you can refer to this article:
Https://www.cnblogs.com/fnlingnzb-learner/archive/2016/09/01/5830661.html
If you can't, just log in with SSH.


If you want to install MySQL database management platform phpMyAdmin can refer to the following articles:
Http://www.cnblogs.com/huanglinxin/p/8710578.html

(2) Apache 2.4

Installing Apache is relatively straightforward.

[email protected] ~]# Yum install httpd

After loading, modify the configuration file by vim/etc/httpd/conf/httpd.conf.

Change #servername www.example.com:80 to ServerName localhost:80

Change #listen to listen:8080 (open port number 80XX in Linux)

After the configuration is complete, test view.

[[email protected] ~]# service httpd start  Redirecting to /bin/systemctl start httpd.service[[email protected]  ~]# service httpd status  redirecting to /bin/systemctl status httpd.service httpd.service - The Apache HTTP Server loaded:loaded (/usr/lib/systemd/system/ Httpd.service; Enabled Vendor preset:disabled) Active:   Active   (running) since Mon 
     2017 -06 - 05  15 : 57 : 34  CST; 5s ago 

The host test access through the LAN, if the failure is generally not added 8080 port iptables access rules, remember to save the restart, as follows,

8080 -j ACCEPT

[[Email protected] ~]# service Iptables Save

[Email protected] ~]# service iptables restart

[[email protected] ~]# IPTABLES-NL #查看规则表, see Add success

After adding the Apache access test, the success is as shown.

(3) PHP 5.4

After the installation of PHP is complete, install the Php-mysql link module, PHP fastcgi parser php-fpm, and then restart the httpd service.

[[email protected] ~]# Yum install PHP
[Email protected] ~]#
[[Email protected]
#测试php解析是否成功
[Email protected] ~]#vi /var/www/html/test.php 

Enter the following:

<?php  phpinfo();?>

(4) PHP Project deployment

When the lamp environment has been deployed, the next step is to put the PHP source into the Apache folder and import the database SQL file into the MySQL database.

1) in Xshell use the RZ command to copy the project Phpoa to the/var/www/html folder

(yum-y install Lrzsz installation upload Download tool, if it is a. zip compressed file to be extracted with the Uzip command)

2) Use the source command to import the Test.sql file in MySQL database.

MySQL import file can refer to the following links:

Https://www.cnblogs.com/yuwensong/p/3955834.html

3) When the project is successfully imported, enter the HTTP://IP address: 8080/project location to access the Web page at any terminal in the LAN.

1.mysql

Database directory:/var/lib/mysql/ configuration file:/usr/share/MySQL (mysql.server command and configuration file) related commands:/usr// etc/my.cnf startup script:/etc/rc.d/init.d/(startup script file mysql directory) Start command: Service mysql start stop command: service MySQL Stop running status: Service MySQL status

2.apache

Configuration file path:/etc/httpd/conf/httpd.conf
Start command: Service httpd start
Stop command: Service httpd stop
Operational status: Service HTTPD status

3.php

PHP default page path:/var/www/html

CENTOS7 (2)-the first time to deploy a PHP project under Linux with the Lamp website Architecture (linux+apache+mysql+php)

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.