Home > Backend Development > PHP Tutorial > LNMP environment construction (1) Building PHP environment

LNMP environment construction (1) Building PHP environment

WBOY
Release: 2016-08-08 09:31:34
Original
1047 people have browsed it

First download the PHP installation file. We use the source code to compile and install PHP5.4.36. Go to the PHP official website to download the PHP installation file.

Next, compile and install the PHP source code. After entering the source code directory, execute the following command to install:

Note: If you need mysql, it is best to do it during mutation Provide parameters and specify to use the mysqlnd library, otherwise the installation of separately compiled extensions can only use the MySQL Client Library.

The following error appears:

It prompts that libxml2 cannot be found, install it:

Continue to recompile, the following error appears:

Because we have enabled --with-openssl , therefore, we need to install openssl-devel:

Compile again, prompt:

GD library is not installed:

Continue compiling, prompt:

Not installed libmcrypt, this lib is not available in yum, so you need to download it and compile it manually:

Compile again:

Need Install libcurl:

Compile again, no errors:


configure is successful, start the installation:


If everything goes well, the beautiful artistic conception successfully compiles and installs PHP, installation directory In /usr/local/php.

Finally, we need to provide the PHP configuration file php.ini.


Note: The PHP installation directory is specified by the --prefix=directory parameter of configure . In addition, what we have built here is an environment for development. If it needs to be used as a production environment, you need to pay attention to some security issues. At the same time, it is recommended not to copy php.ini-development file, instead copy the php.ini-production file.

Check the PHP version:

For ease of operation, you can add the PHP directory to the environment variable. Edit ~/.bash_profile, ​​in export PATH Add the following line above:

Then execute the following command:

In this way, we can use the command directly without adding a directory.

Tip: Check which configuration file PHP is using?

If the strace command is not installed, use yum install strace Just install it.

Install extension

Now that the basic PHP installation is complete, we need to install some extensions that meet business needs.

Install the yaf development framework extension

Execute the command to install using pecl:

If nothing else, the above command is enough to complete the installation of yaf:


Next, you need to install it in php. Enable yaf extension in ini file. Edit /usr/local/php/etc/php.ini

Install eAccelerator extension



in php Add eAccelerator configuration information in .ini:

Execute php -v You can see:


The above introduces the LNMP environment construction (1) Setting up the PHP environment, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template