部署LAMP平臺搭建 一、源碼安裝LAMP 1、 安裝apache [root@localhost ~]# yum -y install gcc* apr-devel apr-util-devel pcre-devel [root@localhost src]# [root@localhost sr ...
部署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平臺就完成了!