您好,登錄后才能下訂單哦!
安裝php的程序環境
[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
[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
[root@zyl /]# wget http://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 ../
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 <evp.h>
解決辦法:
yum install openssl-devel –y
2.
configure: error: xslt-confignot found. Please reinstall the libxslt >= 1.1.0 distribution
解決辦法:
yum install libxslt-devel –y
=====================》》》》》編譯成功!
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
[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
[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
執行下面的命令編輯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
[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.
#
<IfModule dir_module>
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 <VirtualHost> block.
#
<VirtualHost *:80>
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
</VirtualHost>
<VirtualHost*:80>
ServerAdmin 813415154@qq.com
DocumentRoot "/var/html/blog"
ServerName blog.etiantian.org
ErrorLog "logs/blog-error_log"
CustomLog "logs/blog-access_log"common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin 813415154@qq.com
DocumentRoot "/var/html/bbs"
ServerName bbs.etiantian.org
ErrorLog "logs/bbs-error_log"
CustomLog "logs/bbs-access_log" common
</VirtualHost>
[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
<?php
phpinfo();
?>
"index.php" 3L, 22C written
[root@zyl blog]#
[root@zyl extra]# cd /var/html/blog/
[root@zyl blog]# vi index.php
<?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]#
LAMP搭建成功!!!!!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。