云中漫步 发表于 2018-12-16 10:48:47

Linux PHP

  安装php的程序环境
检查apache及mysql的安装情况
# lsof-i :3306
COMMANDPIDUSERFD   TYPE DEVICE SIZE/OFF NODENAME
mysqld1743 mysql   10u IPv412158      0t0 TCP *:mysql(LISTEN)
# lsof-i :80
COMMANDPID   USERFD   TYPE DEVICE SIZE/OFF NODENAME
httpd   1567   root   4uIPv611482   0t0TCP *:http (LISTEN)
httpd   1570 daemon    4u IPv611482      0t0 TCP *:http (LISTEN)
httpd   1571 daemon    4u IPv611482      0t0 TCP *:http (LISTEN)
#
  apache和mysql必须安装好才能安装php
检查安装php所需lib库
# yuminstallzlib libxml libjpeg freetype libpng gdcurl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-develcurl-devel –y
# rpm -qazlib libxml libjpeg freetype libpng gdcurl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-develgd-devel curl-devel   
zlib-1.2.3-29.el6.x86_64
gd-2.0.35-11.el6.x86_64 +m
libxml2-devel-2.7.6-21.el6_8.1.x86_64
freetype-devel-2.3.11-17.el6.x86_64y
libpng-1.2.49-2.el6_7.x86_64
libpng-devel-1.2.49-2.el6_7.x86_64
gd-devel-2.0.35-11.el6.x86_64
zlib-devel-1.2.3-29.el6.x86_64
freetype-2.3.11-17.el6.x86_64
curl-7.19.7-52.el6.x86_64
安装libiconv
# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
# ./configure --prefix=/usr/local/libiconv
# make && make install
# cd ../
开始安装php
rz -y
tar xf php-5.3.27.tar.gz
cd php-5.3.27
编译:
./configure --prefix=/application/php5.3.27--with-apxs2=/application/apache/bin/apxs --with-mysql=/application/mysql--with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd--with-jpeg-dir --with-png-dir --with-iconv=/usr/local/libiconv--enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap--enable-mbstring --enable-static --enable-gd-native-ttf --with-curl --with-xsl--enable-ftp --with-libxml-dir
1047 yum install openssl-devle -y
  

  编译(Configure)出现的错误:
  1.
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannotfind OpenSSL's
解决办法:
yum install openssl-devel –y
  2.
configure: error: xslt-confignot found. Please reinstall the libxslt >= 1.1.0 distribution
解决办法:
yum install libxslt-devel –y
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif=====================》》》》》编译成功!
make && make install
# echo$?
0
# ln-s /application/php5.3.27/ /application/php
# ll/application/php/
total 20
drwxr-xr-x 2 root root 4096 Jul920:18 bin
drwxr-xr-x 2 root root 4096 Jul920:18 etc
drwxr-xr-x 3 root root 4096 Jul920:18 include
drwxr-xr-x 3 root root 4096 Jul920:18 lib
drwxr-xr-x 3 root root 4096 Jul920:18 man

http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
配置php
# ll php.ini-*
-rw-r--r-- 1 101 101 69606 Jul 11 2013 php.ini-development =======è>>开发环境
-rw-r--r-- 1 101 101 69627 Jul 11 2013 php.ini-production =============》》产品环境
比较两者的区别:
# diff `ls php.ini-*`
521c521
< error_reporting = E_ALL | E_STRICT
---
> error_reporting = E_ALL & ~E_DEPRECATED
538c538
< display_errors = On
---
> display_errors = Off
549c549
< display_startup_errors = On
---
> display_startup_errors = Off
593c593
< track_errors = On
---
> track_errors = Off
611c611
< html_errors = On
---
> html_errors = Off
751c751
< ; removed in PHP 5.4.
---
> ; scheduled removed in PHP 5.4.
845c845
< ;cgi.redirect_status_env =
---
> ;cgi.redirect_status_env =
1318c1318
< mysqlnd.collect_memory_statistics = On
---
> mysqlnd.collect_memory_statistics = Off
1587c1587
< session.bug_compat_42 = On
---
> session.bug_compat_42 = Off
1596c1596
< session.bug_compat_warn = On
---
> session.bug_compat_warn = Off
#
拷贝php配置文件到php默认目录并更改文件名称为php。ini:
# cpphp.ini-production /application/php/lib/php.ini ===========》》php的配置文件


  小结:
1.      正式配置文件一般关闭LOG,不输出LOG
2.      php的配置文件目录:/application/php/lib
配置apache支持php
安装php默认产生的文件及配置
# ll /application/apache/modules/
total 28888
-rw-r--r-- 1 root root   9115Jul7 00:42 httpd.exp
-rwxr-xr-x 1 root root 29566389 Jul 9 20:18 libphp5.so
# grep libphp5 /application/apache/conf/httpd.conf
LoadModule php5_module       modules/libphp5.so
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
  执行下面的命令编辑apache的主配置文件http.conf
# cd /application/apache/conf/
# cp httpd.confhttpd.conf.ori    ===========è> 养成备份的好习惯
# vi/application/apache/conf/httpd.conf   ====切换到311gg,添加如下
AddType application/x-httpd-php .php.phtml
AddType application/x-httpd-php .source.phps
:wq
修改damon用户为ett
# vi/application/apache/conf/httpd.conf      ====切换到65gg,添加如下
# running httpd, as with most system services.
#
User daemon   ========== www
Group daemon========== www
注意:如果不存在www用户,一会保存好配置,需要执行useradd www –M -s /sbin/nologin 建立www。
  然后转到166行修改默认的首页文件,本例中添加一个index.php:
# is requested.
#

DirectoryIndexindex.php index.html
  提示:养成备份的习惯,再就是可以diff(比对文件)
# diff httpd.confhttpd.conf.
httpd.conf.20160712httpd.conf.bak       httpd.conf.ori
# diff httpd.confhttpd.conf.ori
67,68c67,68
< User www
< Group www
---
> User daemon
> Group daemon
100,101c100
< #ServerName 192.168.1.128:80
<
---
>
169c168
<    DirectoryIndex index.php index.html
---
>    DirectoryIndex index.html
312,313d310
<    AddType application/x-httpd-php .php .phtml
<    AddType application/x-httpd-php .source .phps
# useradd www -M -s/sbin/nologin
# id www
uid=816(www) gid=816(www)groups=816(www)
#
# cd/application/apache/conf/extra/
# ll
total 60
-rw-r--r-- 1 root root2859 Jul 7 00:44 httpd-autoindex.conf
-rw-r--r-- 1 root root1753 Jul 7 00:44 httpd-dav.conf
-rw-r--r-- 1 root root2344 Jul 7 00:44 httpd-default.conf
-rw-r--r-- 1 root root1103 Jul 7 00:44 httpd-info.conf
-rw-r--r-- 1 root root5078 Jul 7 00:44 httpd-languages.conf
-rw-r--r-- 1 root root   949 Jul 7 00:44 httpd-manual.conf
-rw-r--r-- 1 root root3789 Jul 7 00:44 httpd-mpm.conf
-rw-r--r-- 1 root root2207 Jul 7 00:44 httpd-multilang-errordoc.conf
-rw-r--r-- 1 root root 11530 Jul7 00:44 httpd-ssl.conf
-rw-r--r-- 1 root root   817 Jul 7 00:44 httpd-userdir.conf
-rw-r--r-- 1 root root1507 Jul 7 08:17 httpd-vhosts1.conf
-rw-r--r-- 1 root root1507 Jul 7 08:55 httpd-vhosts.conf
# cat httpd-vhosts.conf
#
# Virtual Hosts
。。。。。。。。。。。。。。。。。。
# match a ServerName or ServerAlias inanyblock.
#

   ServerAdmin 813415154@qq.com
   DocumentRoot "/var/html/www"
   ServerName www.etiantian.org
   ServerAlias www.etiantian.org
   ErrorLog "logs/www-error_log"
   CustomLog "logs/www-access_log" common



    ServerAdmin 813415154@qq.com
    DocumentRoot "/var/html/blog"
    ServerName blog.etiantian.org
    ErrorLog "logs/blog-error_log"
    CustomLog "logs/blog-access_log"common



   ServerAdmin 813415154@qq.com
   DocumentRoot "/var/html/bbs"
   ServerName bbs.etiantian.org
   ErrorLog "logs/bbs-error_log"
   CustomLog "logs/bbs-access_log" common

# cd /var/html/blog/
# ll
total 8
-rw-r--r-- 1 root root26 Jul 7 08:13 index.html
# vi index.php

"index.php" 3L, 22C written
#
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
# cd /var/html/blog/
# vi index.php

"index.php" 15L, 256C written
#

http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
  LAMP搭建成功!!!!!
  




页: [1]
查看完整版本: Linux PHP