博客列表 >php 环境搭建

php 环境搭建

Benald的博客
Benald的博客原创
2018年07月20日 18:33:19551浏览

1、安装依赖包。

yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel php-mcrypt libmcrypt libmcrypt-devel libmcrypt-devel openssl-devel libcurl-devel libjpeg-turbo-devel mysql-devel
yum -y install curl-devel
yum -y install libxslt-devel

2、PHP 7.0.13下载

cd /usr/lcoal/src/

wget http://cn2.php.net/get/php-7.0.13.tar.gz/from/this/mirror

3、解压

tar -zxvf php-7.0.13.tar.gz

4、编译安装

./configure --prefix=/usr/local/php7 \ --with-curl \ --with-freetype-dir \ --with-gd \
--with-jpeg-dir \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysqli \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-pear \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-native-ttf \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip

make &&  make install

6、拷贝配置文件

cp php.ini-production /usr/local/php7/lib/php.ini
vim /usr/local/php7/lib/php.ini

    修改 php.ini 文件 设置 expose_php = Off
    vim /usr/local/php7/etc/php.ini
    找到 expose_php = On
    改为 expose_php = Off
    

cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf

 #把pid 改成 /run/php-fpm.pid

vim /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

 #listen = 127.0.0.1:9000 默认可不改

vim /usr/local/php7/etc/php-fpm.d/www.conf

7、添加服务

vim /etc/systemd/system/php-fpm.service

内容如下


[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/run/php-fpm.pid
ExecStart=/usr/local/php7/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php7/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target

8、启动php-fpm

systemctl start php-fpm.service

9、添加到开机启动

systemctl enable php-fpm.service

 

10、systemctl指令


systemctl enable *.service #开机运行服务
systemctl disable *.service #取消开机运行
systemctl start *.service #启动服务
systemctl stop *.service #停止服务
systemctl restart *.service #重启服务
systemctl reload *.service #重新加载服务配置文件
systemctl status *.service #查询服务运行状态
systemctl --failed #显示启动失败的服务


转自(https://www.cnblogs.com/onephp/p/6093707.html)

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议