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

添加

<?php

phpinfo();

?>

[root@localhost ~]# systemctl restart httpd

测试

 

 

 

 

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

添加

<?php

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

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

mysqli_close($link);

?>

测试连接数据库

 

 

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

 

posted @ 2019-10-23 20:35  小啊博  阅读(699)  评论(0编辑  收藏  举报