centos7 php开发环境安装-php

2021-05-03 05:27

阅读:497

标签:ast   zone   groupadd   exp   jpeg   system   simple   inter   evel   

PHP7.2 安装

1.创建运行用户

    

groupadd  www

useradd -g  www  www

 

2.建立软连接

cp -frp /usr/lib64/libldap*  /usr/lib/

ln -s /usr/local/lib/libiconv.so.2  /usr/lib64/

 

3.编译安装php

tar -zxvf php-7.2.4.tar.gz

cd php-7.2.4

./configure --prefix=/usr/local/php 
--with-config-file-path=/usr/local/php/etc 
--enable-fpm 
--with-fpm-user=www 
--with-fpm-group=www 
--enable-mysqlnd 
--with-mysqli=mysqlnd 
--with-pdo-mysql=mysqlnd 
--enable-mysqlnd-compression-support 
--with-iconv-dir 
--with-freetype-dir 
--with-jpeg-dir 
--with-png-dir 
--with-zlib 
--with-libxml-dir 
--enable-xml 
--disable-rpath 
--enable-bcmath 
--enable-shmop 
--enable-sysvsem 
--enable-inline-optimization 
--with-curl 
--enable-mbregex 
--enable-mbstring 
--enable-intl 
--with-libmbfl 
--enable-ftp 
--with-gd 
--with-openssl 
--with-mhash 
--enable-pcntl 
--enable-sockets 
--with-xmlrpc 
--enable-zip 
--enable-soap 
--with-gettext 
--disable-fileinfo 
--enable-opcache 
--with-pear 
--enable-maintainer-zts 
--with-ldap=shared 
--without-gdbm 
--with-apxs2=/usr/local/apache/bin/apxs
 

make -j4

如果编译出现错误使用这个编辑命令代替make ZEND_EXTRA_LIBS=-liconv

不要 make test 害死人等时间太长

make install

4.配置php配置文件

       4.1 复制需要的配置文件:    

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

       4.2配置php.ini

expose_php = Off

short_open_tag = ON

max_execution_time = 300

max_input_time = 300

memory_limit = 128M

post_max_size = 32M

date.timezone = Asia/Shanghai

#mbstring.func_overload=2

extension = "/usr/local/php/lib/php/extensions/no-debug-zts-20160303/ldap.so"

            

[opcache]

zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20160303/opcache.so

opcache.memory_consumption=128

opcache.interned_strings_buffer=8

opcache.max_accelerated_files=4000

opcache.revalidate_freq=60

opcache.fast_shutdown=1

opcache.enable_cli=1

 

disable_functions=passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru

    4.3配置www.conf  

取消以下注释并修改优化其参数:

listen = /var/run/www/php-cgi.sock

listen.owner = www

listen.group = www

listen.mode = 0660

listen.allowed_clients = 127.0.0.1

pm = dynamic

listen.backlog = -1

pm.max_children = 180

pm.start_servers = 50

pm.min_spare_servers = 50

pm.max_spare_servers = 180

request_terminate_timeout = 120

request_slowlog_timeout = 50

slowlog = var/log/slow.log

    4.4创建php-cgi.sock存放目录

mkdir /var/run/www/

chown -R www:www /var/run/www

    4.6配置php-fpm.conf

取下以下注释并填写完整路径:

pid = /usr/local/php/var/run/php-fpm.pid

    4.7运行php-fpm

/usr/local/php/sbin/php-fpm

 

5.开机启动

       5.1 启动文件  vim /etc/systemd/system/php-fpm.service

       5.2 文件内容 

[Unit]

Description=The PHP FastCGI Process Manager

After=syslog.target network.target

 

[Service]

Type=simple

PIDFile=/usr/local/php/var/run/php-fpm.pid

ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf

ExecReload=/bin/kill -USR2 $MAINPID

ExecStop=/bin/kill -SIGINT $MAINPID

 

[Install]

WantedBy=multi-user.target

    5.3启动php-fpm

systemctl start php-fpm.service

      5.4添加到开机启动

systemctl enable php-fpm.service

6.启动与关闭

systemctl enable php-fpm.service      #开机运行服务

systemctl disable php-fpm.service      #取消开机运行

systemctl start php-fpm.service        #启动服务

systemctl restart php-fpm.service       #重启服务

7.Php 加入环境变量

1.将 /usr/local/php/bin 加到后面,用:隔开

    vi /root/.bash_profile    

   PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/lcoal/php/bin

 2.重启

   source /root/.bash_profile 

centos7 php开发环境安装-php

标签:ast   zone   groupadd   exp   jpeg   system   simple   inter   evel   

原文地址:https://www.cnblogs.com/ddf128/p/12123885.html


评论


亲,登录后才可以留言!