Home>Article>Backend Development> How to deploy php on centos6.8
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.
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-develcurl curl-devel mhash mcrypt libxslt-devel
When installing No package libmcrypt available
libmcrypt- devel libjpeg-devel libpng-devel
Solution: yum install epel-release //Extension package update package
Refer to https://www.cnblogs.com/jkko123/p/6357670.html
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
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
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-zts-20151012/"session.save_path = "/usr/local/php7/tmp"
echo 'export PATH=/usr/local/php7/bin: /usr/local/php7/sbin:$PATH' >> /etc/profileMake it effective
source /etc/profile
chkconfig --add php-fpmchkconfig php-fpm on
chmod 755 /etc/init.d/ php-fpmservice php-fpm start
Add the following configuration to the apache configuration file:
AddType application/x-httpd-php .phpThis enables apache to call the php module to parse the php file
Add index.php
test
before index.html in
< IfModule dir_module>
< ?phpphpinfo();
? >
Test on the browser
Download the compressed package of pdo_mysql extensionhttp://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 foundln -s /usr/local/mysql/include/ /usr/local/include/
make
make install
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
Thencp /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!