设为首页 收藏本站
查看: 744|回复: 0

[经验分享] php源码安装、简单配置、测试及连接数据库

[复制链接]

尚未签到

发表于 2018-12-15 13:01:11 | 显示全部楼层 |阅读模式
  主机环境 redhat6.5 64位
  实验环境 服务端 ip172.25.29.1  php
  安装包   php-5.6.20.tar.bz2
          re2c-0.13.5-1.el6.x86_64.rpm
          libmcrypt-2.5.8-9.el6.x86_64.rpm
          libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
          Discuz_X3.2_SC_UTF8.zip
1.  安装php
1.解压
  [root@server1 mnt# tar jxf php-5.6.20.tar.bz2    #解压
  [root@server1 php-5.6.20]# rpm -vih libmcrypt-*   #安装libmcrypt库
  [root@server1 php-5.6.20]# yum installre2c-0.13.5-1.el6.x86_64.rpm –y   #安装re2c
  
2.软件配置
  [root@server1 php-5.6.20]# ./configure --prefix=/usr/local/lnmp/php--with-config-file-path=/usr/local/lnmp/php/etc --with-openssl --with-snmp--with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir--with-jpeg-dir --with-freetype-dir --with-gettext --without-pear --with-gmp--enable-inline-optimization --enable-soap --enable-ftp --enable-sockets--enable-mbstring --with-mysqli --with-mysql --with-pdo-mysql --enable-fpm--with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
  
  如果出现如下错误
  

  [root@server1 php-5.6.20]# yum install libxml2-devel -y
  
  重新配置
  [root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
  
  如果出现如下错误
  
  [root@server1 php-5.6.20]# yum provides */easy.h
  
  [root@server1 php-5.6.20]# yum install -ylibcurl-devel-7.19.7-37.el6_4.x86_64
  
  重新配置
  [root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
  
  如果出现如下错误
  
  [root@server1 php-5.6.20]# yum provides */jpeglib.h
  [root@server1 php-5.6.20]# yum install -ylibjpeg-turbo-devel-1.2.1-1.el6.x86_64
  
  重新配置
  [root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
  
  如果出现如下错误
  
  [root@server1 php-5.6.20]# yum provides */png.h
  [root@server1 php-5.6.20]# yum install -ylibpng-devel-1.2.49-1.el6_2.x86_64
  
  重新配置
  [root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
  
  如果出现如下错误
  
  [root@server1 php-5.6.20]# yum install -y freetype-devel
  
  重新配置
  [root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
  
  如果出现如下错误
  
  [root@server1 php-5.6.20]# yum provides */gmp.h
  [root@server1 php-5.6.20]# yum install -y gmp-devel-4.3.1-7.el6_2.2.x86_64
  
  重新配置
  [root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-openssl--with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir--with-jpeg-dir --with-freetype-dir --with-gettext --without-pear --with-gmp--enable-inline-optimization --enable-soap --enable-ftp --enable-sockets--enable-mbstring --with-mysqli --with-mysql --with-pdo-mysql --enable-fpm--with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
  
  如果出现如下错误
  
  [root@server1 php-5.6.20]# yum install -y net-snmp-devel
  
  重新配置
  [root@server1 php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash
  
  3.编译、链接、安装
  [root@server1 php-5.6.20]# make #编译
  [root@server1 php-5.6.20]# make install   #安装
  
  2.php的简单配置
  [root@server1 php-5.6.20]# cd /usr/local/lnmp/php/etc/
  [root@server1 etc]# ls
  php-fpm.conf.default
  [root@server1 etc]# cp php-fpm.conf.default php-fpm.conf   #备份php的文件
  [root@server1 etc]# ls
  php-fpm.conf php-fpm.conf.default
  [root@server1 etc]# cp /mnt/php-5.6.20/php.ini-production php.ini   #php的配置文件
  [root@server1 etc]# ls
  php-fpm.conf php-fpm.conf.default  php.ini
  

  如果要连接数据库,就做以下修改
  [root@server1 etc]# vim php.ini
  925 date.timezone = Asia/Shanghai          #修改时区
  1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock   #指定连接数据库的sock文件的路径
  1150 mysql.default_socket = /usr/local/lnmp/mysql/data/mysql.sock   #同上
  1209 mysqli.default_socket =/usr/local/lnmp/mysql/data/mysql.sock   #同上
  [root@server1 etc]# vim php-fpm.conf
  25 pid = run/php-fpm.pid          #将pid的标记去掉
  
  [root@server1 etc]# cd /mnt/php-5.6.20/sapi/fpm/
  [root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm   #添加启动命令
  [root@server1 fpm]# chmod +x /etc/init.d/php-fpm       #添加可执行权限
  [root@server1 fpm]# ll /etc/init.d/php-fpm
  -rwxr-xr-x 1 root root 2359 Sep 18 00:18 /etc/init.d/php-fpm
  [root@server1 fpm]# /etc/init.d/php-fpm start        #开启php服务
  Starting php-fpm  done
  
  [root@server1 fpm]# cd /usr/local/lnmp/nginx/conf/
  [root@server1 conf]# vim nginx.conf         
   51             root   html;
   52             index  index.php index.html index.htm;     #在nginx里添加默认访问目录为php优先
   50         location / {
  
   53         }
  
   75         location ~ \.php$ {
   76             root           html;
   77             fastcgi_pass   127.0.0.1:9000;
   78             fastcgi_index  index.php;
   79             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
   80             include        fastcgi.conf;         #设置成已存在的文件
   81         }
  
  [root@server1 conf]# nginx –t       #检测
  [root@server1 conf]# nginx           #开启
  [root@server1 conf]# cd ..
  [root@server1 nginx]# cd html
  [root@server1 html]# vim index.php       #写一个简单的测试文件
  
  [root@server1 html]# /etc/init.d/httpd start      #开启httpd
  Starting httpd:                                           [  OK  ]
  
  3.测试  172.25.29.1
  
  
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-651704-1-1.html 上篇帖子: CentOS 上安装高版本PHP-Trying 下篇帖子: PHP多进程
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表