lnmp服务一PHP部署

1.安装依赖于函数库

[root@lnmp ~]# ll libiconv-1.14.tar.gz php-5.3.27.tar.gz 
-rw-r--r--. 1 root root  4984397 Aug  4 03:16 libiconv-1.14.tar.gz
-rw-r--r--. 1 root root 15008639 Aug  4 00:29 php-5.3.27.tar.gz
[root@lnmp ~]# yum install zlib gcc-c++ libjpeg freetype \
libpng gd  zlib-devel libxml2-devel libjpeg-devel freetype-devel \
libpng-devel gd-devel curl-devel libxslt-devel openssl-devel -y 
[root@lnmp ~]# tar xf libiconv-1.14.tar.gz 
[root@lnmp ~]# cd libiconv-1.14
[root@lnmp libiconv-1.14]# ./configure --prefix=/usr/local/libiconv-1.14
[root@lnmp libiconv-1.14]# make && make install

2.安装PHP

2.1解压php安装包

[root@lnmp ~]# tar xf php-5.3.27.tar.gz 
[root@lnmp ~]# cd php-5.3.27

2.2编译PHP

[root@lnmp php-5.3.27]# ./configure --prefix=/usr/local/php \
--with-mysql=mysqlnd  --with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir  --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr  --enable-xml --disable-rpath --enable-safe-mode \
--enable-bcmath  --enable-shmop --enable-sysvsem --enable-inline-optimization  \
--with-curl --with-curlwrappers --enable-mbregex --enable-fpm  \
--enable-mbstring  --with-gd --enable-gd-native-ttf --with-openssl  \
--enable-pcntl --enable-sockets --with-xmlrpc --enable-zip  --enable-soap \
--enable-short-tags --enable-zend-multibyte  --enable-static --with-xsl \
--with-fpm-user=nginx --with-fpm-group=nginx  --enable-ftp
[root@lnmp php-5.3.27]# make && make install
[root@lnmp php-5.3.27]# ln -s /usr/local/php/ /application/php

3.配置PHP

3.1修改配置文件

[root@nginx php-5.3.27]# \cp php.ini-production /application/php/lib/php.ini
[root@nginx php-5.3.27]# cd /application/php/
[root@nginx ~]# egrep -v "^$|^;" /application/php/etc/php-fpm.conf|cat -n
     1  [global]
     2  pid = /app/logs/php-fpm.pid
     3  error_log = /app/logs/php-fpm.log
     4   log_level = error
     5   
     6  rlimit_files = 32768
     7   
     8  events.mechanism = epoll
     9  [www]
    10  user = nginx
    11  group = nginx
    12  listen = 127.0.0.1:9000
    13  listen.owner = nginx
    14  listen.group = nginx
    15  pm = dynamic
    16  pm.max_children = 1024
    17  pm.start_servers = 16
    18  pm.min_spare_servers = 5
    19  pm.max_spare_servers = 20
    20  pm.process_idle_timeout = 15s;
    21  pm.max_requests = 2048 
    22  slowlog = /app/logs/$pool.log.slow  
    23  request_slowlog_timeout = 10
    24  php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f 1093626742@qq.com
 

3.2创建日志目录

[root@lnmp php]# mkdir /app/logs/ -p

3.3设置环境变量

[root@lnmp php]# cp sbin/php-fpm /usr/local/sbin/

3.4检查语法,启动php

[root@lnmp php]# php-fpm -t
[06-Aug-2018 11:22:37] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful

[root@lnmp php]# php-fpm
[root@lnmp php]# netstat -lntup|grep php
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      6625/php-fpm

4.整合nginx与PHP

4.1修改nginx配置文件

[root@lnmp php]# vim /application/nginx/conf/nginx.conf
 10     server {
 11         listen       80;
 12         server_name  www.liang.com;
 13             root   html/www;
 14             index  index.php index.html index.htm;
 15         location ~ \.php$ {
 16             root           html/www;
 17             fastcgi_pass   127.0.0.1:9000;
 18             fastcgi_index  index.php;
 19             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
 20             include        fastcgi.conf;
 21                }
 22         }

4.2检查语法,启动nginx

[root@lnmp php]# nginx -t
nginx: the configuration file /usr/local/nginx-1.6.2/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.6.2/conf/nginx.conf test is successful
[root@lnmp php]# nginx -s reload

4.3编写php网页测试

[root@lnmp php]# cat /application/nginx/html/www/index.php
<?php
        phpinfo();
?>

4.4网页查看

这里写图片描述

4.5测试mysql连接

[root@lnmp php]# cat /application/nginx/html/www/index.php    
<?php
        //$link_id=mysql_connect('主机名','用户','密码');
        $link_id=mysql_connect('localhost','root','000000') or mysql_error();

        if($link_id){
                echo "mysql successful by https://blog.youkuaiyun.com/liang_operations!";
        }else{
                echo mysql_error();
        }
?>

这里写图片描述

Php web application manager 〖目的〗 鉴于tomcat提供了应用后台管理功能,而php中没有,所以开发这个小应用方便php应用的远程快速部署(php源码必须打包为zip包)。 〖服务器环境〗 服务器环境要求: a. php5.2以上 b. zip模块必须启用(linux环境下若用php源码编译需要加入zlib路径) c.服务器为linux环境, 应用根目录必须有读写权限, 如部署在apache的htdocs下面, 则htdocs必须有读定权限 〖管理权限〗 对于php应用的部署和去部署,要求输入密钥,以验证用户管理权限。此验证操作很简单,开发人员可根据管理要求修改和扩展。默认密钥为: abc123,如要修改,请修改deployer.php的5847行$authkey的值。 〖使用说明〗 1. 部署: 系统支持上传php zip压缩包和指定服务器上php zip压缩包部署两种方式部署,类似于tomcat,:) 注意: 若部署的压缩包没有输入context name,则压缩包去掉后缀(般为.zip)的名称即为context name; 对于选择服务器上的zip包部署,若仅输入zip名称,而非全路径, 则其必须与deployer.php位于同目录下。 2.部署: 对于需要删除的php应用,可以点undeploy链接即可完成。 3. 查看服务器环境: 若需要查看服务器环境变量,点[Server Status]链接即可完成。 〖版权说明〗 这简易应用为方便开发而开发,所以,大家可自由使用。欢迎使用和修改,有问题请联系: yiming_1983@qq.com.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值