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 packagesyum -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
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 \ <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
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"<br>
echo 'export PATH=/usr/local/php7/bin: /usr/local/php7/sbin:$PATH' >> /etc/profile
Make it effective
source /etc/profile
chkconfig --add php-fpm chkconfig php-fpm on<br>
chmod 755 /etc/init.d/ php-fpm service php-fpm start<br>
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>
< ?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
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!