How to deploy PHP Project environment under Linux system

Source: Internet
Author: User
Tags install php mysql command line
This article introduces to you about how to deploy the PHP project environment under the Linux system, has certain reference value, has the need friend to consult, hoped to be helpful to you.

The deployment of PHP project environment under Linux can be divided into two kinds, a compressed package installation using Apache,php,mysql, a kind of installation with the Yum command.

With the three software package for installation, you need to manually configure the relationship between the three. The configuration between Apache and PHP is not difficult, but it is necessary to understand PHP when configuring with MySQL.

Here's how to configure the PHP environment in Linux with Yum:

Install MySQL

1.mysql and Apache are best installed first because they need to be configured and tested with MySQL and Apache when configuring PHP

Download the Mysql-sever file first, because the blogger Linux environment is the CentOS version, the Yum source does not seem to be properly installed when MySQL mysql-sever file, need to go to the official web download

1. Download Mysql-service file [root@tele-1 ~]# wgetmysql-service[root@tele-1 ~]# RPM-IVH mysql-community-release-el7-5.noarch.rpm

2. Install MySQL

[root@tele-1 ~]# Yum Install Mysql-community-server

3. Start the MySQL service after the installation is complete

[root@tele-1 ~]# Service mysqld Restart

4. The initial installation of MySQL is no password, the user name is root by default. So we need to change the password and modify it with the MySQL command line.

1. Go to MySQL command line [root@tele-1 ~]# mysql-urootwelcome to the MySQL monitor.  Commands End With; or \g.your MySQL connection ID is 474801Server version:5.6.36 mysql Community Server (GPL) Copyright (c), Orac Le and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql>2. Use the command for password modification mysql> set password for ' root ' @ ' localhost ' = passwo RD (' Password you want to modify '); Query OK, 0 rows affected (0.06 sec)

5. Because the blogger uses local navicat software to connect to MySQL under Linux, if you want to access it locally, you need to change the user table in the MySQL database.

1. Operation MySQL database table mysql> use MySQL; Reading table information for completion of table and column namesyou can turn off this feature to get a quicker startup W Ith-a Database changedmysql><br><span style= "font-family: italics; Font-size:14px ">2. View data in the user table (SQL statements can be written directly on the MySQL command line) </span>mysql> select * from user;+-----------+-- ----+-----------------------------------+-------------+-------------+-------------+-------------+-------------+ -----------+-------------+---------------+--------------+-----------+------------+-----------------+----------- -+------------+--------------+------------+-----------------------+------------------+--------------+---------- -------+------------------+------------------+----------------+---------------------+--------------------+----- -------------+------------+--------------+------------------------+----------+------------+-------------+------ --------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+| Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | Ssl_type | Ssl_cipher | X509_issuer | X509_subject | max_questions | Max_updates | max_connections | max_user_connections | Plugin | authentication_string | password_expired |+-----------+------+-----------------------------------+-------------+-------------+--------- ----+-------------+-------------+-----------+-------------+---------------+--------------+-----------+--------- ---+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+- ----------------+------------------+------------------+----------------+---------------------+----------------- ---+------------------+------------+--------------+------------------------+----------+------------+----------- --+--------------+---------------+-------------+-----------------+----------------------+---------------------- -+-----------------------+------------------+| %         | Root | *3ce8dad2446975d8b0c771bd7e48d15b | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |        Y              |            |             |              |             |           0 |               0 |                    0 | 0 |                       Mysql_native_password | | N | | localhost | Root | *3ce8dad2446975d8b0c771bd7e48d15b | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |          Y |            |             |              |             |           0 |               0 |                    0 | 0 |                       Mysql_native_password | | N | | 127.0.0.1 | Root | *3ce8dad2446975d8b0c771bd7e48d15b | Y |     Y      | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |          Y |            |             |              |             |           0 |               0 |                    0 | 0 |                       Mysql_native_password | | N | | :: 1 | Root | *3ce8dad2446975d8b0c771bd7e48d15b | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |  Y              | Y | Y | Y | Y | Y | Y | Y |          Y |            |             |              |             |           0 |               0 |                    0 | 0 |                       Mysql_native_password | | N | |      tele-1 |                                           | | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N |          N |            |             |              |             |           0 |               0 |        0 |            0 | Mysql_native_password | NULL | N |+-----------+------+-----------------------------------+-------------+-------------+-------------+------ -------+-------------+-----------+-------------+---------------+--------------+-----------+------------+------- ----------+------------+------------+--------------+------------+-----------------------+------------------+--- -----------+-----------------+------------------+------------------+----------------+---------------------+---- ----------------+------------------+------------+--------------+------------------------+----------+----------- -+-------------+--------------+---------------+-------------+-----------------+----------------------+--------- --------------+-----------------------+------------------+5 rows in Set (0.00 sec) mysql>3. The table of the blogger is the modified table, and you want to access it remotely, You need the data on the top of the red, host refers to the IP address that can access the database, and% means that all requests can be connected.

You can change one piece of data, or you can add a piece of data. However, it is best not to modify the data in the blue callout above, and the modified statement is the bottom format

mysql> Update user Set Host = '% ' where???

4. Last Exit or \q is the way to exit the MySQL command line

Mysql> \qbye

Installing Apache

1.apache mounting method is relatively simple

[Root@tele-2 ~]# Yum Install httpd

2. External network access to the address in the virtual machine, we need to modify the Apache configuration file/etc/httpd/conf/httpd.conf

Find #ServerName www.example.com:80 to ServerName localhost:80

As shown in the image on the right:

Found #Listen changed to listen:8080 (open port number 80XX in Linux)

As shown in the image on the right:

3. After the modification is complete we need to start the HTTPD service again and check the boot status

[root@tele-2 ~]# service httpd startredirecting to/bin/systemctl start httpd.service[root@tele-2 ~]# service httpd Statu sredirecting to/bin/systemctl status Httpd.service httpd.service-the Apache HTTP Server loaded:loaded (/usr/lib/sy Stemd/system/httpd.service; Enabled Vendor preset:disabled) active:active (running) since Mon 2017-06-05 15:57:34 CST; 5s ago DOCS:MAN:HTTPD (8) Man:apachectl (8) process:54532 Execstop=/bin/kill-winch ${mainpid} (code=exited , status=0/success) process:39046 execreload=/usr/sbin/httpd $OPTIONS-K Graceful (code=exited, status=0/success) Main P   id:54573 (httpd) Status: "Processing requests ..." Memory:15.8m CGroup:/system.slice/httpd.service├─54573/usr/sbin/httpd-dforeground├─54576/usr/           Sbin/httpd-dforeground├─54577/usr/sbin/httpd-dforeground├─54578/usr/sbin/httpd-dforeground ├─54579/usr/sbin/httpd-dforeground└─54580/usr/sbin/httpd-dforeground June to 15:57:34 Tele-2 Systemd[1]: Starting the Apache HTTP Server ... June to 15:57:34 Tele-2 systemd[1]: Started the Apache HTTP Server.

4. At this point you can access your server, enter localhost or IP address, an Apache test page powered by CentOS test pages

Install PHP

1.php installation Command

[root@tele-2 ~]# Yum Install PHP

2. Direct installation, restart HTTPD service after installation is complete

[root@tele-2 ~]# service httpd startredirecting to/bin/systemctl start  httpd.service

3. After restarting we test PHP information, we create a new PHP interface to test

/ var /www/html Create a new test.php page under the Apache default page path, add code

<?php phpinfo ();? >

4. Visit this page, enter localhost/test.php, or

IP: Port number/test.php You can see the configuration information for the PHP environment. As shown on the right:

associating PHP with MySQL

1. Search Module

[Root@tele-2 ~]# Yum Search php

2. Installing the relevant modules

[Root@tele-2 ~]# yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml  php-xmlrpc

3. Install, restart Mysqld, restart httpd

Re-accessing the info.php, we found that we had more information about MySQL. As shown on the right:

At this point, the operating environment of PHP in Linux has been successfully configured to complete.

1.mysql Yum install default folders and related commands

/var/lib/mysql/:/usr/share/mysql (mysql.server)/usr/bin (mysqladmin mysqldump) my.cnf:/etc/my.cnf:/ETC/RC.D/INIT.D /mysql:service mysql start stop command: Service MySQL stop running status: Service MySQL status

2.apache

Configuration file path:/etc/httpd/conf/httpd.confservice httpd startservice httpd stop running Status: Service httpd status

3.php

PHP default page path:/var/www/html

Related articles recommended:

Parsing of the Tal template engine syntax in PHP (code)

How to upgrade the PHP7 operation MongoDB Method Introduction

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.