(二)CentOS: lamp环境初始搭建: php7以及mysql-community安装配置2

php7文件下载:https://download.csdn.net/download/qq_36490086/11185621

php安装

1.解压,重命名(便于之后操作)

tar -xzxvf php-7.0.9.tar.gz
mv php-7.0.9 php7
cd php7

2.安装依赖

yum -y install gcc libxml2 libxml2-devel httpd-devel.x86_64 openssl openssl-devel curl-devel libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 libjpeg-devel bzip2-devel.x86_64 libXpm-devel gmp-devel icu libicu libicu-devel epel-release php-mcrypt libmcrypt libmcrypt-devel postgresql-devel libxslt-devel

3.配置安装选项

./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-mysql-sock=/var/lib/mysql/mysql.sock \
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=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 \
--enable-fastcgi \
--with-fpm-user=apache \
--with-fpm-group=apache \
--without-gdbm \
--with-mcrypt=/usr/local/lib/libmcrypt \
--disable-fileinfo \
--with-apxs2=/usr/bin/apxs \
--enable-mbstring

4.编译安装,耐心等待

make && make install

5.配置php

cp php.ini-production /usr/local/php7/etc/php.ini
cp /root/php7/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

cd /usr/local/php7/lib/php/extensions/
ls
查看下面的文件名,比如我的是no-debug-non-zts-20151012 

vim /usr/local/php7/etc/php.ini
在php.ini中找到extension_dir = "./"修改为: 
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/"

6.添加php变量

echo -e '\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n' >> /etc/profile && source /etc/profile

7.安装并配置php-fpm

yum -y install php-fpm

mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R root:root php-fpm

8.修改session配置开机启动

mkdir -p /var/lib/php/session
chown -R apache:apache /var/lib/php

systemctl start php-fpm
systemctl enable php-fpm

9.重点:配置Apache解析php文件并自动关联

vim /etc/httpd/conf/httpd.conf

找到:DirectoryIndex index.html改为:DirectoryIndex index.html index.htm index.php 
找到:AddType application/x-gzip .gz .tgz在该行下面添加:AddType application/x-httpd-php .php

重启Apache:systemctl restart httpd

参考内容:https://blog.csdn.net/u010347814/article/details/81502867

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值