1. 程式人生 > >源碼安裝CentOs7下的PHP7

源碼安裝CentOs7下的PHP7

-a bstr http style apach libxml2 ror adb ring

首先安裝APACHE環境,直接用yum安裝

yum install httpd httpd-devel
/etc/httpd/
systemctl start httpd.service #啟動apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重啟apache

然後安裝mysql(mariadb)

yum install mariadb mariadb-server
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
vi /etc/my.cnf
#最後添加 
log-slow-queries=/var/log/mariadb/slow.log
long_query_time
=1 log-queries-not-using-indexes systemctl start mariadb.service mysql_secure_installation #(改密碼,如果有密碼 可能是root1234)

完裝完這兩個環境之後,現在源碼安裝PHP7.2.8

#下載鏡像文件
wget http://hk1.php.net/get/php-7.2.8.tar.gz/from/this/mirror 
tar zxvf mirror
cd php-7.2.8

#如果是新環境,需要安裝一些依賴
yum install autoconf gcc  httpd-devel libxml2 libxml2-*  openssl.x86_64 openssl-devel.x86_64  libcurl.x86_64 libcurl-devel.x86_64  libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64  libjpeg-turbo-devel -y

.
/configure --with-mysqli --with-curl --with-apxs2=/usr/bin/apxs --with-openssl --enable-mbstring --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-jpeg-dir --with-config-file-path=/etc/php.ini make && make install

之後要配置APACHE的配置文件

vi /etc/httpd/conf/httpd.conf
#找到LoadModule 大約在54行左右,在註釋下面,加入下面的配置
#php.ini的目錄 PHPIniDir /etc LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so #解析.php文件 <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> <IfModule dir_module> DirectoryIndex index.php index.html </IfModule> AddType application/x-httpd-php .php

之後重啟apache就可以使用了

systemctl restart httpd.service

源碼安裝CentOs7下的PHP7