Home > Backend Development > PHP Problem > How to install php on Linux

How to install php on Linux

藏色散人
Release: 2023-03-15 07:28:02
Original
12415 people have browsed it

How to install php on Linux: 1. Download and decompress "php-7.0.30.tar.gz"; 2. Download and install dependencies; 3. Pass "./configure --prefix=/usr/local" /php..." Compile and install PHP; 4. Configure PHP related files.

How to install php on Linux

The operating environment of this article: linux5.9.8 system, php-7.0.30 version, DELL G3 computer

Installing php under Linux

1. Download

wget http://cn2.php.net/distributions/php-7.0.30.tar.gz
解压 tar -zxvf php-7.0.30.tar.gz
Copy after login

2. Download and install dependencies

yum -y install gcc openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-devel
Copy after login

3. Compile and install php

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-pdo-mysql --with-mysqli --with-gd --with-zlib --with-mcrypt --enable-fpm

make && make install
安装完成后,别忘记 make test

有如下报错 configure: error: mcrypt.h not found. Please reinstall libmcrypt.  
解决
yum install -y epel-release
yum install -y libmcrypt-devel
重新编译
Copy after login

4. Configure PHP Related files

1)配置php.ini,这是php的配置文件:
    cp /etc/we/php-7.1.11/php.ini-development /usr/local/php/lib/php.ini
2)配置php-fpm.conf,这是php-fpm配置文件:
     cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
3)配置www.conf,配置用户的文件:
    cp etc/php-fpm.d/www.conf.default  etc/php-fpm.d/www.conf
4)将php-fpm启动文件复制到init.d文件夹中一份方便启动php:
     cp /usr/local/php/sbin/php-fpm /etc/init.d/php-fpm
Copy after login

5. Start php and confirm whether the installation is successful

执行命令/etc/init.d/php-fpm即可
查看是否启动:ps -ef |grep php
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to install php on Linux. For more information, please follow other related articles on the PHP Chinese website!

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