Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install php environment under linux

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

How to install php environment under linux? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

The method of installing php environment under linux: 1, install cmake;2, install libzip;3, install php dependency; 4, create www user; 5, download php source code and pre-configure; 6, compile and install; 7, create startup script.

The installation steps are as follows:

Step 1: install cmake

Yum install epel-release-yyum install cmake3-ycp / usr/bin/cmake3 / usr/bin/cmake

Execute the command cmake-version to see if the installation is successful:

# output cmake version 3.16.1CMake suite maintained and supported by Kitware (kitware.com/cmake).

Step 2: install libzip1.5.2

# install bzip2-devel dependency package yum install bzip2 bzip2-devel-y # install libzipcd ~ wget https://libzip.org/download/libzip-1.5.2.tar.gztar xf libzip-1.5.2.tar.gz cd libzip-1.5.2mkdir buildcd buildcmake.. make#make testmake install

Step 3: install php dependencies

Yum install gcc\ gcc-c++\\ libxml2\ libxml2-devel\ openssl\ openssl-devel\ libcurl\ libcurl-devel\ freetype\ freetype-devel\ libjpeg\ Libjpeg-devel\ libpng\ libpng-devel\ libxslt\ libxslt-devel\ systemd-devel\ libicu-devel\ libedit-devel

Step 4: create a www user

Useradd-M-s / sbin/nologin www

Modify library load path

Vim / etc/ld.so.conf# add the following lines / usr/local/lib64/usr/local/lib/usr/lib/usr/lib64

To bring it into effect:

Ldconfig-v

Or

Echo / usr/local/lib64 > > / etc/ld.so.conf echo / usr/local/lib > > / etc/ld.so.conf echo / usr/lib > > / etc/ld.so.conf echo / usr/lib64 > > / etc/ld.so.conf ldconfig-v

Finally, pre-configuration will be carried out again.

Step 5: download the php source code and preconfigure it

# install wget tool yum install wget-y # download php source code wget https://www.php.net/distributions/php-7.3.12.tar.gz# decompress php tar package tar xf php-7.3.12.tar.gz# enter the directory cd php-7.3.12# preconfiguration after php decompression. / configure-- prefix=/usr/local/php\-- with-config-file-path=/usr/local/php/etc\\- -with-config-file-scan-dir=/usr/local/php/etc/conf.d\-- disable-cgi\\-- enable-fpm\-- with-fpm-user=www\-- with-fpm-group=www\-- enable-ftp\-- with-curl\-- with-gd\-- with-gettext\-- with-iconv-dir\-- with-kerberos\\ -- with-libedit\-- with-openssl\\-- with-pcre-regex\-- with-pdo-mysql\-- with-xsl\-- with-zlib\-- with-mhash\-- with-mysqli\-- with-png-dir=/usr/lib\-- with-jpeg-dir=/usr/lib\-- with-freetype-dir=/usr/lib\ \-- enable-mysqlnd\-- enable-bcmath\\-- enable-libxml\-- enable-inline-optimization\-- enable-gd-jis-conv\-- enable-mbregex\-- enable-mbstring\-- enable-opcache\-- enable-pcntl\-- enable-shmop\-- enable-soap\-- enable-sockets\\-- enable -sysvsem\-- enable-xml\-- enable-zip\-- enable-calendar\-- enable-intl\-- enable-exif

Check to see if error appears in the final output:

If no error appears and the following words appear, proceed to the next step

Thank you for using PHP

Step 6: compile and install

Make & & make install

Step 7: create a startup script

Cp php.ini-development / usr/local/php/etc/php.ini cd / usr/local/php/etc/ cp php-fpm.conf.default php-fpm.conf

The default official provides a systemd management script

The path is php-fpm.service under / root/php-7.3.12/sapi/fpm

# copy a configuration file cp php-fpm.conf.default php-fpm.conf# copy startup script to the specified directory cp / root/php-7.3.13/sapi/fpm/php-fpm.service / usr/lib/systemd/system/systemctl daemon-reloadsystemctl start php-fpmsystemctl enable php-fpmsystemctl status php-fpm

This time is not over, startup will prompt you that you cannot find the included configuration file:

Cd / usr/local/php/etc/php-fpm.d/cp www.conf.default www.confsystemctl start php-fpmsystemctl status php-fpm

No accident at this time is a normal state:

Check whether the process exists

Ps-ef | grep php-fpm

Check to see if the port is started:

Ss-lntup | grep 9000 Thank you for reading! After reading the above, do you have a general idea of how to install the php environment under linux? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report