search
HomeBackend DevelopmentPHP ProblemHow to start php installation from source code

PHP is a popular server-side scripting language that is widely used in web development and system programming due to its ease of use and high performance. In some cases, you need to install PHP from source and manually start the PHP compiler to complete programming and web application deployment. This article will introduce the process of installing PHP from source code and how to start it.

1. Source code installation of PHP

1. Preparation:

Before installing PHP, you need to install the compiler and some related development libraries. You can execute the following command to install these tools:

$ sudo yum install gcc
$ sudo yum install libxml2-devel
$ sudo yum install openssl-devel
$ sudo yum install bzip2-devel
$ sudo yum install libcurl-devel
$ sudo yum install libjpeg-devel
$ sudo yum install libpng-devel
$ sudo yum install freetype-devel
$ sudo yum install libxslt-devel

2. Download the PHP source code

Download the latest stable version of PHP and extract it to a directory. You can use the following command to complete:

$ wget https://www.php.net/distributions/php-x.x.x.tar.gz
$ tar xfz php-x.x.x.tar.gz

3. Compile and install PHP

Next, you need to enter the PHP source code directory and execute the ./configure command to configure PHP . Verify that the compilation options match the server configuration. Execute the following command:

$ cd php-x.x.x
$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --prefix=/usr/local/php --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-zlib --with-zlib-dir --enable-mbstring --enable-zip

--with-apxs2 option specifies the APXS interface of the Apache server, which is used to communicate PHP with Apache. The --prefix option specifies the PHP installation directory, the --with-mysql option specifies the MySQL driver used, the --with-openssl option enables SSL Support, --with-zlib option turns on zlib library support, --enable-mbstring option enables multi-byte support, --enable-zip option Enable zip library support.

After the configuration is completed, execute the make and make install commands to compile and install. Execute the following command:

$ make
$ sudo make install

2. Start PHP

After the installation is completed, you need to ensure that PHP is accurately installed in the specified directory. Execute the following command:

$ which php
/usr/local/php/bin/php

If the output shows /usr/local/php/bin/php, it means that PHP has been correctly installed in the specified directory.

Next, you need to integrate PHP with the Apache server. Edit Apache's configuration file httpd.conf and add the following content:

LoadModule php5_module        /usr/local/php/lib/php/modules/libphp5.so
AddType                      application/x-httpd-php .php .html

LoadModule instruction to load the PHP module, and use the AddType instruction to add the PHP script Compatible with Apache. After changing the configuration file, you need to restart the Apache server and execute the following command:

$ sudo /usr/local/apache2/bin/apachectl restart

At this point, PHP has been successfully installed and started, and can be tested through the browser or command line. If everything goes well, PHP will output the corresponding results.

Summary

Installing PHP from source may require longer time and patience, but it can provide finer control and flexibility for more advanced needs. The main steps to install PHP include preparation, downloading source code, compiling and installing PHP, and integrating PHP with the Apache server. Once the installation is complete, you can test whether PHP starts successfully via a browser or command line.

The above is the detailed content of How to start php installation from source code. 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

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 Article

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools