lamp服务一php部署

1.安装函数库

[root@lamp ~]# yum install zlib  libjpeg freetype libpng gd  zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel -y
[root@lamp ~]# ll libiconv-1.14.tar.gz 
-rw-r--r--. 1 root root 4984397 Aug  4  2018 libiconv-1.14.tar.gz
[root@lamp ~]# tar xf libiconv-1.14.tar.gz 
[root@lamp ~]# cd libiconv-1.14
[root@lamp libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[root@lamp libiconv-1.14]# make && make install

2.编译安装PHP

2.1解压安装包

[root@lamp ~]# tar xf php-5.3.27.tar.gz 
[root@lamp ~]# cd php-5.3.27

2.2编译安装

[root@lamp php-5.3.27]# ./configure --prefix=/usr/local/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
[root@lamp php-5.3.27]# make && make install
[root@lamp php-5.3.27]# ln -s /application/php5.3.27/ /application/php
报错一:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
The output of /application/apache/bin/apxs follows:
./configure: /application/apache/bin/apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory
configure: error: Aborting
解决方法:
[root@lamp php-5.3.27]# vi /application/apache2.2.27/bin/apxs
1 #!/replace/with/path/to/perl/interpreter -w
修改成
1 #!/usr/bin/perl -w
报错二:
configure: error: Cannot find OpenSSL's <evp.h>
解决方法:
[root@lamp php-5.3.27]# yum install openssl-devel -y
报错三:
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
解决方法:
[root@lamp php-5.3.27]# yum install libxslt-devel -y

3.编译参数详解

博客链接:点击

4.拷贝php配置文件到默认目录并改名

[root@lamp php-5.3.27]# cp php.ini-production /application/php/lib/php.ini

5.配置Apache支持PHP

[root@lamp php-5.3.27]# cd /application/apache
[root@lamp apache]# vi conf/httpd.conf
    67 User www
    68 Group www
    168     DirectoryIndex index.php index.html
    311     AddType application/x-httpd-php .php .phtml
    312     AddType application/x-httpd-source .phps
[root@lamp apache]# useradd www -M -s /sbin/nologin
[root@lamp apache]# bin/apachectl -t
Syntax OK
[root@lamp apache]# bin/apachectl restart
[root@lamp html]# cd /var/www/html/www/
[root@lamp www]# cat index.php   
<?php
        phpinfo()
?>

6.网页访问

这里写图片描述

7.测试连接mysql

[root@lamp www]# cat index.php 
<?php
        //$link_id=mysql_connect('主机名','用户','密码');
        $link_id=mysql_connect('localhost','root','000000') or mysql_error();

        if($link_id){
                echo "mysql successful by https://blog.csdn.net/liang_operations!";
        }else{
                echo mysql_error();
        }
?>

8.网页访问

这里写图片描述

猜你喜欢

转载自blog.csdn.net/liang_operations/article/details/81429409