Install one of the lamp keys to install PHP

Source: Internet
Author: User
Tags install php

#!/bin/sh

#一键安装php

#xiaogao 20190921


#安装依赖包:

Yum install zlib libxml libjpeg freetype libpng gd Curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel L Ibpng-devel gd-devel curl-devel libxslt-devel openssl*-y


#上面安装完还是没有libiconv库, you need to compile and install the Libiconv library. If you cannot download it, download it on upload to/home/lvnian/tools/

[-e/home/lvnian/tools/] | | Mkdir-p/home/lvnian/tools/

cd/home/lvnian/tools/

#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

Tar zxf libiconv-1.14.tar.gz

CD libiconv-1.14

./configure--prefix=/usr/local/libiconv

Make

Make install

Cd..


#安装php

Tar zxf 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


Make && make install


#制作软连接

Ln-s/application/php5.3.27//application/php

Ls/application


# #配置配置文件

Cp/home/lvnian/tools/php-5.3.27/php.ini-production/application/php/lib/php.ini


# #修改apache配置文件httpd. conf. make IT support PHP

#到311加下面两行

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

#AddType Application/x-httpd-php-source. Phps

Sed-n ' 310,315p '/application/apache/conf/httpd.conf

Sed-i ' 311aAddType application/x-httpd-php. php. Phtml\naddtype application/x-httpd-php-source. Phps '/application/ Apache/conf/httpd.conf

Sed-n ' 310,315p '/application/apache/conf/httpd.conf


#修改daemon用户和组 Lvnian

Useradd lvnian-s/sbin/nologin-m

Sed-i ' s/user daemon/user lvnian/g '/application/apache/conf/httpd.conf

Sed-i ' s/group daemon/group lvnian/g '/application/apache/conf/httpd.conf

Sed-n '/lvnian/p '/application/apache/conf/httpd.conf


# #修改首页文件

grep ' DirectoryIndex index.html '/application/apache/conf/httpd.conf

Sed-i "s# directoryindex index.html# directoryindex index.php index.html#g"/application/apache/conf/httpd.conf

grep ' DirectoryIndex '/application/apache/conf/httpd.conf


# #重启apache

/application/apache/bin/apachectl stop

/application/apache/bin/apachectl start


# #检查安装php是否成功

Cd/application/apache/htdocs

Cat >>index.php<<eof

<?php

$conne =mysql_connect (' Host name ', ' user ', ' password ');

$link _id=mysql_connect (' localhost ', ' root ', ' Lvnian ') or mysql_error ();


if ($conne) {

echo "MySQL successful by xiaogao!";

}else{

Echo Mysql_error ();

}

?>

<?php

Phpinfo ();

?>

Eof

# # #测试lamp环境是否成功

Window open 10.0.0.4

This article is from the "Technology Change Destiny" blog, please be sure to keep this source http://lvnian.blog.51cto.com/7155281/1696816

Install one of the lamp keys to install PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.