Linux下安装PHP

一、 安装环境&软件
1、环境:CentOS-7-x86_64虚拟机
2、软件:php-7.2.1.tar.gz
二、 获取php
1、方式一:打开浏览器进入php的官网,链接如下
http://cn2.php.net/downloads.php
这里写图片描述

这里写图片描述

2、方式二:远程连接到Linux系统,进入/usr/local/src目录下通过wget命令进行下载
# cd /usr/local/src
# wget http://cn2.php.net/get/php-7.2.1.tar.gz/from/this/mirror

三、安装步骤
1、解压
# cd /usr/local/src
# tar -zxvf php-7.2.1.tar.gz

2、安装php的依赖包
由于php安装的依赖比较多,这里不在罗列,给出所有常用的依赖包进行安装
# yum -y install wget vim vim-enhanced lrzsz cmake gcc gcc-c++ pcre pcre-devel libtool libtool-ltdl bison ntp libevent-devel openssl* autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make gd gd2 gd-devel gd2-devel libxslt libxslt-devel libaio libaio-devel mhash libmcrypt mcrypt freetype freetype-devel net-snmp-devel mysql-devel php-bcmath php-mbstring

3、配置php
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –enable-fpm –with-pdo-mysql=mysqlnd –with-mysqli=mysqlnd –with-mysql=mysqlnd –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –enable-mbregex –enable-mbstring –enable-ftp –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear –with-gettext –disable-fileinfo –enable-maintainer-zts –with-libdir=lib64

4、编译安装
# make
# make install
安装结果摘要信息如下图:
这里写图片描述

四、配置php
1、复制php配置文件到安装目录,php.ini是php运行核心配置文件
# cp php.ini-production /usr/local/php/etc/php.ini
删除系统自带配置文件
# rm -rf /etc/php.ini
添加软连接到etc目录
# ln -s /usr/local/php/etc/php.ini /etc/php.ini
修改php.ini文件中cgi.fix_pathinfo配置项,这一项默认被注释并且值为1,根据官方文档的说明,这里为了当文件不存在时,阻止Nginx将请求发送到后端的PHP-FPM模块,从而避免恶意脚本注入的攻击,所以此项应该去掉注释并设置为0
# vim /usr/local/php/etc/php.ini
cgi.fix_pathinfo = 0
保存退出

2、复制php-fpm.conf,php-fpm.conf是php-fpm进程服务的配置文件
# 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
添加软连接到 /etc目录
# ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf

3、设置管理php服务,复制php-fpm到启动目录
#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
添加执行权限
# chmod +x /etc/init.d/php-fpm
设置开机启动
# chkconfig php-fpm on

4、设置环境变量
# vim /etc/profile
在最后一行添加
export PHP_HOME=/usr/local/php
export PATH= PHPHOME/bin: PATH
保存退出,使配置文件生效
# source /etc/profile

五、测试、启动php
1、测试php配置
# /usr/local/php/sbin/php-fpm -t
打印出如下文字说明php测试成功
NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful

2、启动php
# service php-fpm start
打印出如下文字说明php安装成功:
Starting php-fpm done

3、查看php进程:
# ps aux | grep -c php-fpm

4、关闭php服务:
# service php-fpm stop

六、配置nginx和php
1、修改nginx的配置
# vim /usr/local/nginx/conf/nginx.conf
location / {
root html;
index index.html index.htm index.php;
}
在配置php请求被转发到后端的php-fpm模块,默认情况下php配置块是被注释的,此时去掉注释并修改为以下内容:
这里写图片描述
保存退出
2、编写测试的php脚本
在nginx的html目录下创建test.php
# cd /usr/local/nginx/html
# vim test.php
输入以下内容,就是打印php的信息
这里写图片描述

3、启动nginx和php
# cd /usr/local/nginx/sbin
# ./nginx
# service php-fpm start

4、测试配置
打开浏览器输入http://IP/test.php
出现如下界面说明配置成功:
这里写图片描述

基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip 【备注】 1、该资源内项目代码百分百可运行,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值