Home  >  Article  >  Backend Development  >  How to deploy php on centos6.8

How to deploy php on centos6.8

藏色散人
藏色散人Original
2021-11-25 09:59:541918browse

How to deploy php in centos6.8: 1. Install dependent packages; 2. Download php; 3. Modify the php.ini configuration file; 4. Configure environment variables; 5. Configure apache; 6. Add extensions and Just test it.

How to deploy php on centos6.8

The operating environment of this article: centos6.8 system, php7.0, Dell G3.

How to deploy php in centos6.8?

centos6.8 source code installation php7.0

## Install dependency packages

yum -y install gd gd-devel zlib-devel libjpeg-devel libiconv-devel libxml2 libxml2-devel curl curl-devel mhash mcrypt libxslt-devel
libmcrypt- devel libjpeg-devel libpng-devel
When installing No package libmcrypt available
Solution: yum install epel-release //Extension package update package

If libiconv installation fails , you can download the source code and use the source code to install

Refer to https://www.cnblogs.com/jkko123/p/6357670.html

Download php

Download address: http:// cn2.php.net/distributions/php-7.0.1.tar.gz


tar -zxvf php-7.0.1.tar.gz
cd php-7.0.1
./configure \ --prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--bindir= /usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr /local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-mysqli=shared,mysqlnd \
--with -pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
-- enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
- -enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
-- without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype -dir \
--enable-opcache \
--enable-fpm \
--without-gdbm \
--disable-fileinfo
--with-apxs2="/usr /local/apache2/bin/apxs

make
make install

Configuration file

cp /root/php-7.0.15/php.ini-development /usr/local/php7/lib/php.ini

cp -R /root/php-7.0 .15/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7 /etc/php-fpm.d/www.conf
mkdir /usr/local/php7/tmp
chmod 766 /usr/local/php7/tmp

Modify the php.ini configuration file

extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-zts-20151012/" session.save_path = "/usr/local/php7/tmp"

Configure environment variables

echo 'export PATH=/usr/local/php7/bin: /usr/local/php7/sbin:$PATH' >> /etc/profile Make it effective
source /etc/profile

Auto-start

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

Start service

chmod 755 /etc/init.d/ php-fpm service php-fpm start

Configure apache

After installing php, you need to configure apache to support php.

Add the following configuration to the apache configuration file:

AddType application/x-httpd-php .php This enables apache to call the php module to parse the php file
Add index.php

test

before index.html in
< IfModule dir_module>

DirectoryIndex index.html

< /IfModule>

Create a new index.php file under apache's htdocs


< ?php phpinfo();
? >
Test on the browser

Add extension

After the installation is completed, use phpinfo() to find that there is no extension for pdo_mysql.

Download the compressed package of pdo_mysql extension
http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar -xzvf PDO_MYSQL-1.0. 2.tgz
cd /root/php-7.0.15/ext/pdo_mysql
/usr/local/php7/bin/phpize
./configure --with-php-config=/#usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
for mysql Make a soft link for the header file because the installation directory is specified during mysql installation. Without linking, the header file cannot be found
ln -s /usr/local/mysql/include/ /usr/local/include/
make
make install

Modify the php configuration file

Add in the configuration file:
extension_dir = /usr/local/php7/lib/php/extensions/no-debug-zts-20151012/
extension=pdo_mysql.so

Then restart php-fpm and apache
Tested and found that it still doesn't work.
Found through the phpinfo() function
Loaded Configuration File is none

Then cp /usr/local/php7/lib/php.ini /usr/local/php7/etc/

Retest successfully

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to deploy php on 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