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

How to deploy php on centos6.8

藏色散人
Release: 2023-03-14 06:50:02
Original
2094 people have browsed it

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 <br> libmcrypt- devel libjpeg-devel libpng-devel<br> 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 \ <br> --exec-prefix=/usr/local/php7 \ <br> --bindir= /usr/local/php7/bin \ <br> --sbindir=/usr/local/php7/sbin \ <br> --includedir=/usr/local/php7/include \ <br> --libdir=/usr /local/php7/lib/php \ <br> --mandir=/usr/local/php7/php/man \ <br> --with-config-file-path=/usr/local/php7/etc \ <br> --with-mcrypt=/usr/include \ <br> --with-mhash \ <br> --with-openssl \ <br> --with-mysqli=shared,mysqlnd \ <br> --with -pdo-mysql=shared,mysqlnd \ <br> --with-gd \ <br> --with-iconv \ <br> --with-zlib \ <br> --enable-zip \ <br> -- enable-inline-optimization \ <br> --disable-debug \ <br> --disable-rpath \ <br> --enable-shared \ <br> --enable-xml \ <br> --enable-bcmath \ <br> --enable-shmop \ <br> --enable-sysvsem \ <br> --enable-mbregex \ <br> --enable-mbstring \ <br> --enable-ftp \ <br> - -enable-gd-native-ttf \ <br> --enable-pcntl \ <br> --enable-sockets \ <br> --with-xmlrpc \ <br> --enable-soap \ <br> -- without-pear \ <br> --with-gettext \ <br> --enable-session \ <br> --with-curl \ <br> --with-jpeg-dir \ <br> --with-freetype -dir \ <br> --enable-opcache \ <br> --enable-fpm \ <br> --without-gdbm \ <br> --disable-fileinfo <br> --with-apxs2="/usr /local/apache2/bin/apxs<br>

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"<br>

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<br>

Start service

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

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(); <br/> ? ><br> Test on the browser<br></p>Add extension<h3 id="添加扩展"></h3>After the installation is completed, use phpinfo() to find that there is no extension for pdo_mysql. <p></p> <p>Download the compressed package of pdo_mysql extension<br><code>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/ <br> 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!

Related labels:
php
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