PHP安装依赖于以前的Apache和MySQL
LAMP体系结构应用实战APACE服务介绍与安装。
LAMP体系结构应用实战MySQL服务介绍与安装
一、准备安装环境
因为首先要确认服务器上是否安装了上述两种服务。
1、检查安装路径。
[root @ centos/]# ls-LD/application/Apache
Lrwxrwxrwx.1根根根根根25 sep 12 03:44/application/Apache-/application
[root @ centos/]# ls-LD/application
drw xr-xr-x . 11 MySQL MySQL 4096 sep 19 09:16/应用程序
2、确认服务是否启动。
[root @ centos extra]# chkconfig-list | grep httpd
httpd 0: off 1: off 2: off : on 4: on 5: on 63360 off
[root @ centos extra]# chkconfig-list | grep MySQL
MySQLD 0: off 1: off 2: on : on 4: on 5: on 63360 off
3、端口视图
[root @ centos extra]# netstat-lnt | egrep ' 3306 | 80 '
TCP 0 0 0 . 0 . 0 . 0:3306 0 . 0 . 0 . 03360 * listen
TCP 0 :33603360336080 :336033603360 * Listen
二、安装配置所需的库文件
1、确定PHP安装所需的LIB库。
[root @ centos tools]# rpm-qaz lib-devel libxml 2-evel libjpeg-devel freetype-devel libpng-devel
#未显示表示系统上未安装相应的软件包
使用以下命令进行安装
[root @ centos tools]# yum group install ' x software development '
也可以通过以下命令进行安装
[root @ centos tools]# yum install zlib libxml libjpeg freetype libpng GD curl libiconv zlib-devel libxml 2-evel libjpeg-
2、libiconv库安装。
下载地址:
[root @ centos tools]# wgetlibiconv-1 . 7。
-2016-09-20 01:34336001-libiconv-1.7 .
Resolving.208.118.235.20,2001:4830:134:3:3360 b
连接到| :80.connected .
Http请求集,awaiting response.302基金会
location : 3358113 . 215 . 215 . 21 . 31:80/1 q 2 w 3 e 4 r 5t 6y 7 u 8 I 9 o 0 p 1 z 2 x 3 c 4v 5 b//pub/GNU/libiconv/libionv
-2016-09-20 01:34:02-http://113 . 215 . 21 . 31/1 Q2 W3 E4 T6 Y7 U 8 I 9 O 0 P1 Z2 X3 C4 V 5 B//PUB/
connecting to 113 . 215 . 21 . 31:80.connected .
Http请求集,awaiting response.200 ok
Length : 2941046) [应用程序/x-gzip]
saving to : ' libiconv-1.7;
100%[===============================================
2016-09-20 01:34336007(979 KB/s)-' Libiconv-1.7;Saved [2941046/2941046]
解压缩编译安装
[root @ centos tools]# tarzxf libiconv-1 . 7。
[root @ centos tools]# CD libiconv-1 . 7
[root @ centos libiconv-1.7] #。/configure-prefix=/application/libiconv
[root @ centos libiconv-1 . 7]# echo $?
0
[root@Centos libiconv-1.7]# make
[root @ centos libiconv-1 . 7]# echo $?
0
[root @ centos libiconv-1.7]# make install
[root @ centos libiconv-1 . 7]# echo $?
0
第三,安装PHP
1、PHP软件下载。
[root @ centos ~]# CD/downloads/tools/
[root @ centos tools]# wget 3358 mirrors。/PHP/
-2016-09-19 2:20:34-http://mirrors。/PHP/
恢复Mirrors.221.236.12.140
Connecting to mirrors.| :80.连接。
Http请求集,awaiting response.302基金会
location : 3358113 . 215 . 21 . 25336080/1 q 2 w 3 e 4 r 5t 6y 7 u 8 I 9 o 0 p 1 z 2 x 3 c 4v 5 b/mirrors。/PHP/。[followid
-2016-09-19 23:20:39-http://113 . 215 . 21 . 25/1 q 2 w 3 e 4 r 5t 6y 7 u 8 I 9 o 0 p 1 z 2 x 3 c 4v 5 b/mirrors
connecting to 113 . 215 . 21 . 25336080.connected .
Http请求集,awaiting response.200 ok
Length : 15311831 (15m) [应用程序/octet-stream]
saving to :’。
100%[=============================15,311,831.29m/s in 12s
2016-09-19 2:20336051mb/s)-'。Saved [15311831/15311831]
2、解压缩软件。
[根@ centos/] # CD/downloads/tools/
[root@Centos tools]# tar zxf。
3、编译和安装PHP
[root@Centos ]#。/configure \
-prefix=/application/\
-with-apxs 2=/application/Apache/bin/apxs \
-with-MySQL=/application \
- with-xmlrpc \
- with-openssl \
- with-zlib \
-with-freetype-dir \
- with-gd \
-with-JPEG-dir \
-with-png-dir \
-with-iconv=/application/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-dir
Checking for xml2-config path.
configure : error : XML 2-config not found . please check your lib XML 2 installation .
[root@Centos ]# echo $?
1
[root @ centos]# yum install libxml 2 libxml 2-devel-y
重新编译
Configure: creating。
Creating main
Creating main
-
| License: |
| this software is subject to the PHP license,available in this |
| distribution in the file license . by continuing this installation |
| process,you are bound by the terms of this license agreement |
| if you do not agree with the terms of this license,you must abort |
| the installation process at this poin |
-
Thank you for using PHP。
Con: creating
Con: creating main
Con: creating scripts/phpize
Con: creating scripts/man1
con : creating scripts/PHP-config
Con: creating scripts/man1
Con: creating sapi/cli
Con: creating sapi/cgi
Con: creating ext/phar
Con: creating ext/phar
Con: creating main
Con :执行默认命令
configure : warning : unrecognized options :-enable-Zend-multibyte
[root@Centos ]# echo $?
0
[root@Centos ]# make
.................................
Build complete。
Don't forget to run 'make test ' .
[root@Centos ]# make install
.................................
installing pear environment :/application//lib/PHP/
[pear]archive _ tar-installed : 1 . 3 . 11
[pear]console _ getopt-installed 3360 1 . 3 . 1
warning : pear/pear requires package ' pear/structures _ graph '(recommended version 1 . 0 . 4)
warning : pear/pear requires package ' pear/XML _ util '(recommended version 1 . 2 . 1)
[pear] pear-installed 3360 1.9.4
wrote pear system config file at :/application//etc/pear . conf
you may want to add :/application//lib/PHP to your include _ path
[pear]structures _ graph-installed 3360 1 . 0 . 4
[pear]XML _ util-installed : 1 . 2 . 1
/downloads/tools//build/shtool install-c ext/phar/application//bin
ln-s-f/application//bin/application//bin/phar
installing PDO headers :/application//include/PHP/ext/PDO/
[root@Centos ]# echo $?
0
4: PHP配置
1、建立软链接。
[root @ centos]# ln-s/application//application/PHP
[root @ centos]# ls-l/application/PHP
Lrwxrwxrwx.1根根根23 sep 20 02:27/应用程序/PHP-/应用程序/
2、查看个人资料。
[根@ centos] # ls *
-development -production
将配置文件放置在安装路径下
[root @ centos]# CP-production/application/PHP/lib/
[root @ centos]# ls/application/PHP/lib/
/application/php/lib/
3、支持Apache服务的PHP配置。
[root @ centos]# CD/application/Apache/conf/
[root@Centos conf]# ls
1.txtb . logextra . 0918 . 2016-09-09 . bak index . html magic mime . types original
[root@Centos conf]# CP .20160920
[root@Centos conf]# VI
您可以在以下安装文件中查看支持PHP的配置的说明
[root @ centos]# grep x-httpd-PHP . PHP install
grep : PHP : no such file or directory
install : add type application/x-httpd-PHP . PHP . phtml
install : add type application/x-httpd-PHP-source . phps
install : add type application/x-httpd-PHP . PHP
Install : set handler应用程序/x-httpd-PHP
Install : set handler应用程序/x-httpd-PHP
Install : set handler应用程序/x-httpd-PHP-source
Install : rewriterule(.* \。PHP)s $ $ 1[h=application/x-httpd-PHP-source]
install : type=magnus-internal/x-httpd-PHP exts=PHP
install : service fn=' PHP 4 _ execute ' type=' magnus-internal/x-httpd-PHP '[ini key=vhp]
install : object name=' x-httpd-PHP '
install : object type fn=' force-type ' type=' magnus-internal/x-httpd-PHP '
install : server and assign it the style x-httpd-PHP . all files in it will
install : add type application/x-httpd-PHP . PHP
install : add type application/x-httpd-PHP-source . phps
install : add type application/x-httpd-PHP . PHP
install : replace the line addtype application/x-httpd-PHP . PHP with 3360
事实上,只需添加以下内容
# if the add encoding directives above are commented-out,then you
# probably should define those extensions to indicate media types :
#
addtypeapplication/x-compress . z
addtypeapplication/x-gzip . gz . tgz
addtypeapplication/x-httpd-PHP . PHP . phtml
addtypeapplication/x-httpd-PHP-source . phps
修改默认用户
# running httpd,as with most system services。
#
用户PHP
组PHP
默认值是将达蒙更改为PHP。可以自由修改。如果用户不存在,则必须添加
修改默认主页文件
IfModule dir_module
directoryindexindex . PHP index . html
/IfModule
默认情况下,只有index.html
保存结束后,可以比较以下两个文件以查看修改的内容
[root @ centos conf]# diff . 20160920
160,161c160,161
用户PHP
组PHP
-
User daemon
这是集团戴蒙。
249c249
directoryindexindex . PHP index . html
-
DirectoryIndex index.html
378,379d377
addtypeapplication/x-httpd-PHP . PHP . phtml
addtypeapplication/x-httpd-PHP-source . phps
五、测试配置
检查Apache语法并重新启动服务
[root @ centos conf]#/application/Apache/bin/apachectl-t
Ah 0054: httpd : bad用户名PHP
[root @ centos conf]# useradd PHP-s/sbin/nolog in-m
[root @ centos conf]#/application/Apache/bin/apachectl-t
Syntax OK
[root @ centos conf]#/application/Apache/bin/apachectl graceful
查看进程和端口
[root @ centos conf]# lsof-I TCP :80
command PID user FD type device size/off node name
Httpd 1866根4 u ipv 6 14604 0t 0 TCP * : http(listen)
httpd 20498 PHP 4 u ipv 6 14604 0t 0 TCP * : http(listen)
httpd 20499 PHP 4 u ipv 6 14604 0t 0 TCP * : http(listen)
httpd 20500 PHP 4 u ipv 6 14604 0t 0 TCP * : http(listen)
[root @ centos conf]# PS-ef | grep http
根1866 1 0 02:22?启动00:0336000/应用程序/bin/httpd-k
Php 20498 1866 0 03:05?启动00:0336000/应用程序/bin/httpd-k
Php 20499 1866 0 03:05?启动0:00336000/应用程序/bin/httpd-k
Php 20500 1866 0 03:05?启动00:0336000/应用程序/bin/httpd-k
根20584 2091 0 0:05 pts/0 00:00:00 grep http
PHP将模块添加到中
[root@Centos conf]# grep PHP
加载模块PHP 5 _模块模块
用户PHP
组PHP
directoryindexindex . PHP index . html
addtypeapplication/x-httpd-PHP . PHP . phtml
addtypeapplication/x-httpd-PHP-source . phps
由于以前配置的Apache服务器已配置虚拟主机,因此当前无法访问默认站点目录,因此请暂时注释默认配置文件中的虚拟主机功能
[root @ centos conf]# grep httpd-vhosts/application/Apache/conf/
Include conf/extra
[root @ centos conf]# sed-I ' s # include conf/extra # \ # include conf/extra # g '/application
[root @ centos conf]# grep httpd-vhosts/application/Apache/conf/
#Include conf/extra
[root @ centos conf]#/application/Apache/bin/apachectl-t
Syntax OK
[root @ centos conf]#/application/Apache/bin/apachectl graceful
[root @ centos conf]# CD/application/Apache/htdocs/
[root @ centos htdocs]# viindex . PHP
?嗯?PHP
PHP info();
?嗯?
输入本地客户端浏览
PHP
教程完成了。谢谢您的支持
1.《【lamp架构】LAMP架构应用实战之PHP服务安装配置》援引自互联网,旨在传递更多网络信息知识,仅代表作者本人观点,与本网站无关,侵删请联系页脚下方联系方式。
2.《【lamp架构】LAMP架构应用实战之PHP服务安装配置》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。
3.文章转载时请保留本站内容来源地址,https://www.lu-xu.com/keji/1955017.html