linux centos7.4 php7.1.31安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux centos7.4 php7.1.31安装相关的知识,希望对你有一定的参考价值。
参考技术A yum -y install gcc-c++groupadd httpd
useradd -g httpd httpd
yum install libxml2 -y
yum install libxml2-devel -y
yum install libcurl-devel -y
yum -y install libjpeg-devel libpng-devel
//字体
yum install freetype-devel -y
yum -y install openssl openssl-devel
yum -y install php-mcrypt limcrypt libmcrypt-devel
tar -zxvf php-7.0.1.tar.gz
./configure --prefix=/usr/local/php --with-iconv --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --enable-ftp --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-fpm --with-fpm-user=httpd --with-fpm-group=httpd --with-pdo-mysql --with-mysqli --with-mcrypt=/usr/local/ --enable-opcache=no
make && make install
配置环境变量
export PATH=$PATH:/usr/local/php/bin
export PATH=$PATH:/usr/local/php/sbin
然后立马生效,执行
source /etc/profile
cp php.ini-production /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
修改php.ini
vi /usr/local/php/lib/php.ini
date.timezone = "Asia/Shanghai"
Linux系列Centos 7安装 PHP
目的
为了下面的Laravel部署,本篇开始安装PHP。
设置PHP源
查看Centos源是否有PHP。
yum list php*
进一步查看PHP的版本。
yum info php.x86_64
上图看出自带的PHP源版本太低,需要更高版本的。
设置高版本的PHP源。
rpm -ivh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum list php* #更新源并查看现在的PHP源
现在已有php72版本,安装。
yum install -y php72w-fpm php72w-fpm php72w-cli.x86_64 php72w-common.x86_64 php72w.x86_64 php72w-dba.x86_64 php72w-devel.x86_64 php72w-embedded.x86_64 php72w-enchant.x86_64 php72w-gd.x86_64 php72w-imap.x86_64 php72w-interbase.x86_64 php72w-intl.x86_64 php72w-ldap.x86_64 php72w-mbstring.x86_64 php72w-mysqlnd.x86_64 php72w-odbc.x86_64 php72w-opcache.x86_64 php72w-pdo.x86_64 php72w-pdo_dblib.x86_64 php72w-soap.x86_64 php72w-xml.x86_64 php72w-xmlrpc.x86_64 php72w-mbstring.x86_64 php72w-mcrypt.x86_64 php-posix
安装成功后,查看php
php -v
下面来新建一个网站站点。
service php-fpm start # 启动php
systemctl enable php-fpm # 设置开机启动项
ps -ef | grep php # 查看是否正常启动
设置SELinux
vi /etc/selinux/config
SELINUX=permissive
重启虚拟机,不设置SELinux,nginx访问php-fpm会有权限问题。
mkdir -p /var/www/Test
cd /var/www/Test
vi index.php
index.php
<?php
phpinfo();
?>
nginx站点config配置
cd /etc/nginx/conf.d
vi devtest.plat.goods
server {
listen 80;
server_name devtest.plat.goods;
root "/var/www/Test";
index index.html index.htm index.php;
location ~ (.+.php)(.*)$ {
fastcgi_split_path_info ^(.+.php)(.+)$;
fastcgi_pass unix:/var/run/php-fpm/php7-fpm.sock; #用unix套接字通讯
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
}
配置php-fpm
vi /etc/php-fpm.d/www.conf
listen = /var/run/php-fpm/php7-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
service php-fpm restart
service nginx reload
service nginx status
物理主机访问虚拟机站点,需要配置物理机的hosts
C:WindowsSystem32driversetchosts
192.168.10.18 devtest.plat.goods
访问 http://devtest.plat.goods/index.php
以上是关于linux centos7.4 php7.1.31安装的主要内容,如果未能解决你的问题,请参考以下文章
Linux监控篇—Centos7.4下构建zabbix监测系统