成都创新互联网站制作重庆分公司

LinuxPHPLAMP

安装php的程序环境

创新互联主营砀山网站建设的网络公司,主营网站建设方案,App定制开发,砀山h5成都小程序开发搭建,砀山网站营销推广欢迎砀山等地区企业咨询

检查apache及MySQL的安装情况

[root@zyl /]# lsof  -i :3306

COMMAND  PID  USER  FD   TYPE DEVICE SIZE/OFF NODENAME

mysqld  1743 mysql   10u IPv4  12158      0t0 TCP *:mysql(LISTEN)

[root@zyl /]# lsof  -i :80

COMMAND  PID   USER  FD   TYPE DEVICE SIZE/OFF NODENAME

httpd   1567   root   4u  IPv6  11482     0t0  TCP *:http (LISTEN)

httpd   1570 daemon    4u IPv6  11482      0t0 TCP *:http (LISTEN)

httpd   1571 daemon    4u IPv6  11482      0t0 TCP *:http (LISTEN)

[root@zyl /]#

apache和mysql必须安装好才能安装php

检查安装php所需lib库

[root@zyl /]# yum  install  zlib libxml libjpeg freetype libpng gd  curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-develcurl-devel –y

[root@zyl /]# rpm -qa  zlib libxml libjpeg freetype libpng gd  curl 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

[root@zyl /]# wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

[root@zyl libiconv-1.14]# ./configure --prefix=/usr/local/libiconv

[root@zyl libiconv-1.14]# make && make install

[root@zyl libiconv-1.14]# 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

Linux PHP LAMP=====================》》》》》编译成功!

make && make install

[root@zyl php-5.3.27]# echo$?

0

[root@zyl php-5.3.27]# ln-s /application/php5.3.27/ /application/php

[root@zyl php-5.3.27]# ll/application/php/

total 20

drwxr-xr-x 2 root root 4096 Jul  920:18 bin

drwxr-xr-x 2 root root 4096 Jul  920:18 etc

drwxr-xr-x 3 root root 4096 Jul  920:18 include

drwxr-xr-x 3 root root 4096 Jul  920:18 lib

drwxr-xr-x 3 root root 4096 Jul  920:18 man

 

Linux PHP LAMP

Linux PHP LAMP

配置php

[root@zyl php-5.3.27]# 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 =============》》产品环境

比较两者的区别:

[root@zyl php-5.3.27]# 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

[root@zyl php-5.3.27]#
拷贝php配置文件到php默认目录并更改文件名称为php。ini:

[root@zyl php-5.3.27]# cpphp.ini-production /application/php/lib/php.ini ===========》》php的配置文件

小结:

1.      正式配置文件一般关闭LOG,不输出LOG

2.      php的配置文件目录:/application/php/lib

配置apache支持php

安装php默认产生的文件及配置

 [root@zyl /]# ll /application/apache/modules/

total 28888

-rw-r--r-- 1 root root     9115Jul  7 00:42 httpd.exp

-rwxr-xr-x 1 root root 29566389 Jul 9 20:18 libphp5.so

[root@zyl /]# grep libphp5 /application/apache/conf/httpd.conf

LoadModule php5_module       modules/libphp5.so

Linux PHP LAMP

执行下面的命令编辑apache的主配置文件http.conf

[root@zyl php-5.3.27]# cd /application/apache/conf/

[root@zyl conf]# cp httpd.confhttpd.conf.ori    ===========è>养成备份的好习惯

[root@zyl apache]# vi/application/apache/conf/httpd.conf    ====切换到  311gg,添加如下

AddType application/x-httpd-php .php.phtml

AddType application/x-httpd-php .source.phps

:wq

修改damon用户为ett

[root@zyl apache]# 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(比对文件)

[root@zyl conf]# diff httpd.confhttpd.conf.

httpd.conf.20160712  httpd.conf.bak       httpd.conf.ori

[root@zyl conf]# 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

[root@zyl conf]# useradd www -M -s/sbin/nologin

[root@zyl conf]# id www

uid=816(www) gid=816(www)groups=816(www)

[root@zyl conf]#

[root@zyl conf]# cd/application/apache/conf/extra/

[root@zyl extra]# ll

total 60

-rw-r--r-- 1 root root  2859 Jul 7 00:44 httpd-autoindex.conf

-rw-r--r-- 1 root root  1753 Jul 7 00:44 httpd-dav.conf

-rw-r--r-- 1 root root  2344 Jul 7 00:44 httpd-default.conf

-rw-r--r-- 1 root root  1103 Jul 7 00:44 httpd-info.conf

-rw-r--r-- 1 root root  5078 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 root  3789 Jul 7 00:44 httpd-mpm.conf

-rw-r--r-- 1 root root  2207 Jul 7 00:44 httpd-multilang-errordoc.conf

-rw-r--r-- 1 root root 11530 Jul  7 00:44 httpd-ssl.conf

-rw-r--r-- 1 root root   817 Jul 7 00:44 httpd-userdir.conf

-rw-r--r-- 1 root root  1507 Jul 7 08:17 httpd-vhosts1.conf

-rw-r--r-- 1 root root  1507 Jul 7 08:55 httpd-vhosts.conf

[root@zyl extra]# cat httpd-vhosts.conf

#

# Virtual Hosts

。。。。。。。。。。。。。。。。。。

# match a ServerName or ServerAlias inany block.

#

   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

[root@zyl extra]# cd /var/html/blog/

[root@zyl blog]# ll

total 8

-rw-r--r-- 1 root root  26 Jul 7 08:13 index.html

[root@zylblog]# vi index.php

  phpinfo();

?>

"index.php" 3L, 22C written

[root@zyl blog]#

Linux PHP LAMP

[root@zyl extra]# cd /var/html/blog/

[root@zyl blog]# vi index.php

        //$link_id=mysql_connect('主机名','用户','密码');

       $link_id=mysql_connect('localhost','root','oldboy123') o

rmysql_error();

 

        if($link_id){

                echo "mysql successful byoldboy !";

        }else{

                echo mysql_error();

        }

?>

"index.php" 15L, 256C written

[root@zyl blog]#

 

Linux PHP LAMP

LAMP搭建成功!!!!!


当前标题:LinuxPHPLAMP
文章起源:http://cxhlcq.com/article/gesddp.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部