Table of Contents
The following is to use yum to configure the php environment in linux: " >The following is to use yum to configure the php environment in linux:
Install MySql" >Install MySql
Install Apache" >Install Apache
Install PHP" >Install PHP
Associating php and mysql## 1. Search module" >Associating php and mysql## 1. Search module
Home Backend Development PHP Tutorial How to deploy php project environment under linux system

How to deploy php project environment under linux system

Aug 02, 2018 pm 03:51 PM
php Project deployment

This article introduces to you how to deploy the PHP project environment under the Linux system. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

The environment for deploying PHP projects under Linux can be divided into two types, one is installed using the compressed package of Apache, PHP, and MySQL, and the other is installed using the yum command.

Use the compressed packages of the three software to install, and you need to manually configure the relationship between the three. The configuration between apache and php is not difficult, but when configuring with mysql, you need to understand php.

The following is to use yum to configure the php environment in linux:

Install MySql

1 .mysql and apache are best installed first, because when configuring php, they need to be configured and tested in conjunction with mysql and apache.

First download the mysql-sever file, because the blogger's Linux environment is the CentOS version. It seems that there is no mysql-sever file for normal installation of mysql in the yum source. You need to download it from the official website

1

2

3

4

1.下载mysql-service文件

[root@tele-1 ~]# wget

mysql-service

[root@tele-1 ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

Copy after login

2. Install mysql

1

[root@tele-1 ~]# yum install mysql-community-server

Copy after login

3. After the installation is completed, start the mysql service

1

[root@tele-1 ~]# service mysqld restart

Copy after login

4. The initial installation of mysql does not have a password, and the default user name is root. So we need to change the password and use the mysql command line to change it

1

2

3

4

5

6

7

8

9

1.进入mysql命令行

[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) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

2.使用命令进行密码修改

mysql> set password for 'root'@'localhost' = password('你要修改的密码');

Query OK, 0 rows affected (0.06 sec)

Copy after login

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

1.操作mysql数据库表

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

  

Database changedmysql>

<br><span style="font-family: 楷体; font-size: 14px">

2.查看user表中的数据(在mysql命令行中可以直接进行sql语句编写)</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.博主的表中是修改之后的表了,想要远程访问,就需要上边红色标注的数据了,Host指的是可以访问此数据库的ip地址,%代表的是所有的请求都可以连接进来。

Copy after login

. You can modify a piece of data or add a piece of data. But it is best not to modify the data marked in blue above. The modification statement is in the format below

mysql> update user set Host = '%' where ???

4. Finally, exit or \q are Is the method to exit the mysql command line

1

2

mysql> \q

Bye

Copy after login

Install Apache

1. The apache installation method is relatively simple

1

[root@tele-2 ~]# yum install httpd

Copy after login

2. When visiting the address in the virtual machine, we need to modify the configuration file of Apache /etc/httpd/conf/httpd.conf

Q to find #Servername www.example. com:80 Change to ServerName localhost:80

As shown on the right:

Find #Listen Change to Listen:8080 (an open port in Linux No. 80XX)

As shown in the picture on the right:

3. After the modification is completed, we need to start the httpd service again and check the startup status

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

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

[root@tele-2 ~]# service httpd statusRedirecting 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

     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 PID: 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

  

Jun 05 15:57:34 tele-2 systemd[1]: Starting The Apache HTTP Server...Jun 05 15:57:34 tele-2 systemd[1]: Started The Apache HTTP Server.

Copy after login

4. At this time you will You can access your server. Enter localhost or IP address, and an Apache test page powered by centos will appear.

Install PHP

1.php installation command

1

[root@tele-2 ~]# yum install php

Copy after login

2. Install it directly. After the installation is completed, restart the httpd service again

1

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

Copy after login

3. After restarting, we will test the PHP related information. We will create a new PHP interface. Test

Create a new test.php page under the apache default page path

/var/www/html and add the code

1

<?php phpinfo();?>

Copy after login

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

ip:port number/test.php to see the configuration information of the PHP environment. As shown on the right:

Associating php and mysql## 1. Search module

1

[root@tele-2 ~]# yum search php

Copy after login

 2.Install related modules

1

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

Copy after login

3. The installation is complete, restart mysqld, restart httpd

Revisit the info.php just now, we found that there is more MySQL related information. As shown on the right:

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

 1.mysql yum installation default folder and related commands

1

2

3

4

5

6

7

8

9

10

11

12

/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

停止命令:service mysql stop

运行状态:service mysql status

Copy after login

 2.apache

1

2

3

4

配置文件路径:/etc/httpd/conf/httpd.conf

service httpd start

service httpd stop

运行状态:service httpd status

Copy after login

 3.php

1

php默认页面路径:/var/www/html

Copy after login

Recommended related articles:

Parsing of TAL template engine syntax in PHP (code)

Introduction to how to upgrade PHP7 to operate MongoDB

The above is the detailed content of How to deploy php project environment under linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles