Home  >  Article  >  Backend Development  >  Let’s talk about the PHP7 software installation process

Let’s talk about the PHP7 software installation process

PHPz
PHPzOriginal
2023-04-19 09:19:181468browse

PHP7 is an open source programming language with high performance and strong stability. It is suitable for web development and command line scripting, and is widely used in application development, data processing and other fields. This article will introduce the installation process of PHP7 to help developers set up a development environment faster.

1. Preparation

Before installing PHP7, you need to install and configure related environments and software, including web servers, databases, editors, etc.

1. Install the Web server

The Web server is software used to process HTTP requests. We can choose open source software such as Apache and Nginx as the Web server.

In the Ubuntu system, we can install Apache by running the following command:

sudo apt-get update
sudo apt-get install apache2

2. Install the database

In PHP applications, the database is an essential part , common databases include MySQL, MariaDB, etc.

In the Ubuntu system, we can install MySQL by running the following command:

sudo apt-get update
sudo apt-get install mysql-server

During the installation process, we will be asked to set the administrator account and password.

3. Install the editor

The editor is a tool used to write and modify code. We can choose Sublime, Atom, etc.

2. Install PHP7

There are many ways to install PHP7, including source code compilation, binary package installation, etc. Below we will introduce the specific steps of source code compilation and binary package installation.

1. Source code compilation method

(1) Download the source code package

We can download the latest stable version source code package on the PHP official website, the download address is http ://php.net/downloads.php, select the stable version of PHP7 to download, and extract the downloaded source code package to the local directory.

(2) Install dependent libraries

During the compilation process, you need to install some necessary dependent libraries, including: libxml, libcurl, libjpeg, libpng, libmcrypt, etc.

In Ubuntu system, we can install these libraries by running the following command:

sudo apt-get install libxml2-dev libcurl4-gnutls-dev libjpeg-dev libpng-dev libmcrypt-dev

(3) Configuration and compilation

After installing the dependent libraries, we need Configure and compile PHP through the following commands:

./configure --with-apxs2=/usr/bin/apxs2 \
--with-mysql \
--with-mysqli \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-zlib-dir \
--with-iconv \
--with-mcrypt \
--enable-fpm \
--enable-sockets \
--enable-bcmath \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-shmop \
--enable-zip \
--enable-exif \
--enable-ftp

(4) Installation

After the configuration and compilation are completed, we can install PHP through the following commands:

make
make test
sudo make install

2 .Binary package installation method

The binary package installation method is relatively simple. We can install PHP7 by running the following command in the Ubuntu system:

sudo apt-get install php7.0

3. Configure the PHP environment

After installing PHP, we also need to perform some configurations on the PHP environment.

1. Modify the php.ini file

When installing PHP, a php.ini file will be generated by default. In this file, we can configure some basic settings and extensions of PHP.

In the Ubuntu system, the default location of the php.ini file is /etc/php/7.0/apache2/php.ini.

We can improve the performance of PHP by modifying the following configuration:

memory_limit = 256M
max_execution_time = 300
max_input_time = 600
upload_max_filesize = 128M
post_max_size = 256M

In addition, in the Ubuntu system, we also need to open the following two lines of configuration:

extension=mysqli.so
extension=gd.so

2. Enable PHP FPM

PHP FPM is a PHP processing method for high-concurrency scenarios. It can quickly process requests and improve system performance.

In the Ubuntu system, we can enable PHP FPM through the following command:

sudo apt-get install php7.0-fpm

After enabling it, we also need to set the Apache configuration file /etc/apache2/mods-enabled /php7.0.conf Modify to the following content:

<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"
</FilesMatch>

3. Restart the service

After modifying the php.ini and Apache configuration files, we need to restart Apache and PHP FPM Service to make the configuration take effect:

sudo service apache2 restart
sudo service php7.0-fpm restart

At this point, the installation and configuration of PHP7 is completed, and we can happily start PHP development!

The above is the detailed content of Let’s talk about the PHP7 software installation process. For more information, please follow other related articles on the PHP Chinese website!

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