linux lamp架构部署,Centos7部署LAMP平台之架构之路

本文将为您描述Centos7部署LAMP平台之架构之路,具体完成步骤:

部署LAMP平台搭建

一、源码安装LAMP

1、 安装apache

[root@localhost ~]# yum -y install gcc* apr-devel apr-util-devel pcre-devel

[root@localhost src]#

[root@localhost src]# tar zxvf httpd-2.4.25.tar.gz

[root@localhost src]# cd httpd-2.4.25

[root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi

[root@localhost httpd-2.4.25]# make && make install

[root@localhost httpd-2.4.25]# ln -s /usr/local/httpd/bin/* /usr/local/bin/

[root@localhost httpd-2.4.25]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

[root@localhost httpd-2.4.25]# vi /etc/init.d/httpd

#chkconfig:35 85 21

[root@localhost httpd-2.4.25]# chkconfig --add httpd

[root@localhost httpd-2.4.25]# service httpd start

[root@localhost php-5.5.38]# netstat -anpt | grep httpd

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 71820/httpd

2、 安装mysql

安装MySQL之前文档有安装,这里就不例举了!

访问https://www.cnblogs.com/-bobo/p/11643172.html

3、 安装php

[root@localhost ~]# cd /usr/src

[root@localhost src]# yum –y install zlib* libxml2*

[root@localhost src]# tar zxf libmcrypt-2.5.8.tar.gz

[root@localhost src]# cd libmcrypt-2.5.8

[root@localhost libmcrypt-2.5.8]# ./configure

[root@localhost libmcrypt-2.5.8]# make && make install

[root@localhost libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.* /usr/lib

[root@localhost libmcrypt-2.5.8]# cd /usr/src

[root@localhost src]# tar zxf mhash-0.9.9.9.tar.gz

[root@localhost src]# cd mhash-0.9.9.9

[root@localhost mhash-0.9.9.9]# ./configure

[root@localhost mhash-0.9.9.9]# make && make install

[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash* /usr/lib/

[root@localhost mhash-0.9.9.9]# cd /usr/src

[root@localhost src]# tar zxf mcrypt-2.6.8.tar.gz

[root@localhost src]# cd mcrypt-2.6.8

[root@localhost mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

[root@localhost mcrypt-2.6.8]# ./configure

[root@localhost mcrypt-2.6.8]# make && make install

[root@localhost mcrypt-2.6.8]# cd /usr/src

[root@localhost src]# tar zxf php-5.5.38.tar.gz

[root@localhost src]# cd php-5.5.38

[root@localhost php-5.5.38]# ./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring

[root@localhost php-5.5.38]# make && make install

4、 实现LAMP平台

[root@localhost php-5.5.38]# cp php.ini-development /usr/local/php5/php.ini

[root@localhost php-5.5.38]# vim /usr/local/php5/php.ini

修改配置文件

short_open_tag = on #Off改成on

extension=php_mysqli.dl #873行注释去掉

[root@localhost ~]# vim /usr/local/httpd/htdocs/index.php

添加

phpinfo();

?>

[root@localhost ~]# systemctl restart httpd

测试

linux lamp架构部署,Centos7部署LAMP平台之架构之路_第1张图片

[root@localhost ~]# vim /usr/local/httpd/htdocs/test.php

添加

$link=mysqli_connect('localhost','root','1122');

if($link) echo "恭喜你,数据库连接成功啦!!";

mysqli_close($link);

?>

测试连接数据库

linux lamp架构部署,Centos7部署LAMP平台之架构之路_第2张图片

到这里部署LAMP平台就完成了!

Centos7部署LAMP平台之架构之路就为您介绍到这里,感谢您关注懒咪学编程c.lanmit.com.

本文地址:https://c.lanmit.com/czxt/Linux/20830.html

你可能感兴趣的:(linux,lamp架构部署)