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-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces you how to install php environment under Linux, the content is very detailed, interested friends can refer to, I hope to help you.

If you want to install it in one step, use the following procedure:

Step 1: Install cmake

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

Run cmake -version to see if the installation is successful:

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

Step 2: Install libzip 1.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 www users

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 again.

Step 5: Download php source code and pre-configure

#install wget tool yum install wget -y#download php source code wget https://www.php.net/distributions/php-7.3.12.tar.gz#extract php tar package tar xf php-7.3.12.tar.gz#enter php decompressed directory cd php-7.3.12#pre-configuration./ 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

See if error appears in the final output:

If no error occurs 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 administration 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 the startup script to the specified directory cp /root/php-7.3.13/sapi/fpm/php-fpm.service /usr/lib/systemd/system/systemctl daemon-reload systemctl start php-fpmsystemctl enable php-fpmsystemctl status php-fpm

At this point, the 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

At this time, no accident is normal state:

Check if the process exists

ps -ef|grep php-fpm

Check whether the port is enabled:

ss -lntup| grep 9000 on how to install php environment under Linux to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

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

Development

Wechat

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

12
Report