search
HomeBackend DevelopmentPHP ProblemHow to compile and install php in centos6.8

How to compile and install php in centos6.8: 1. Install dependencies through the "yum -y install" command; 2. Copy the configuration file; 3. Add environment variables; 4. Execute "source /etc/profile" Command; 5. Add auto-start, and then restart the php service.

How to compile and install php in centos6.8

The operating environment of this tutorial: Windows10 system, centos6.8&&php7.1.5 version, Dell G3 computer.

How to compile and install php in centos6.8?

centOS6.8, centOS7 compile and install PHP:

I installed PHP 7 times on centOS, and I concluded that both centOS6.8 and centOS7 can be used Use the method to compile and install PHP. It’s like a long-term illness that makes a good doctor. Don’t worry if you can’t install it at first. You’ll gain experience after installing it a few times.

Installation dependencies:

yum -y install gd-devel zlib-devel libjpeg-devel libpng-devel libiconv-devel freetype-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libxslt-devel libmcrypt-devel mhash mcrypt

Unable to install automatically online Searching for manual installation tutorials, in fact, there is basically nothing wrong.

Enter the local directory: cd /usr/local

Download PHP7.1.5: wget http://am1. php.net/distributions/php-7.1.5.tar.gz

Decompression: tar zxvf php-7.1.5.tar.gz

Enter the decompression directory :cd php-7.1.5

编译:./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-fpm-user=www --with-fpm-group=www --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-mysql --enable-mysqlnd-compression-support --with-pear --enable-maintainer-zts --enable-session --with-gettext

The installation directory is /usr/local/php

After the compilation is completed, you will see: Thank you for using PHP.

Then execute the installation command:

make
make install

Then copy the configuration file (currently still in the php7.1.5 folder, do not use the mv command, these configuration files can still be used in the future and do not delete them):

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm(这个很重要)

Add environment variables:

echo 'export PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH'>> /etc/profile

Load environment variables: source /etc/profile (My habit is to execute this command first after starting the virtual machine, which will avoid a lot of trouble)

Execute At this point, run php -v to see the installed version of PHP

Add auto-start:

chkconfig --add php-fpm
chkconfig php-fpm on
chkconfig --list php-fpm

Add permissions: chmod 755 /etc/init.d/php-fpm

Start PHP:/etc/init.d/php-fpm start

View PHP service status:/etc/init.d/php-fpm status

Stop PHP service :/etc/init.d/php-fpm stop

Restart the php service:/etc/init.d/php-fpm restart

The configuration file of php is /usr/local/php /lib/php.ini can be referenced here if you install extensions in the future.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to compile and install php in centos6.8. 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

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Clair Obscur: Expedition 33 - How To Get Perfect Chroma Catalysts
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools