1. 程式人生 > 實用技巧 >LAMP平臺部署及應用

LAMP平臺部署及應用

1、LAMP平臺作用和組成
1)LAMP的作用
針對前端網站使用php語言後端資料儲存使用mysql
一般動態網站或者軟體專案都可以部署在LAMP平臺上進行釋出
2)LAMP的組成
L:Linux系統
A:apache用於釋出網站使用
M:mysql資料庫儲存網站的資料
P:開發LAMP專案使用的語言支援php、perl、python、html
3)LAMP平臺的優勢
成本低:所有工具全部開源
可定製:原始碼安裝可以根據需要定製環境
易於開發:php或者html網頁標記語言簡單
方便易用:使用簡單
安全性強:更新速度快
2、安裝apache
1)配置apache
[[email protected]

hppt-2.2.17]# ./configure --prefix=/usr/local/httpd --enable-so–enable-chrset-lite --enable-rewrite --enable-cgi
2)編譯安裝apache
[[email protected] hppt-2.2.17]#make && make install
3)生成服務控制
[[email protected] httpd-2.2.17]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[[email protected]
httpd-2.2.17]# chmod +x /etc/init.d/httpd
[[email protected] httpd-2.2.17]# vim /etc/init.d/httpd
4)新增系統服務設定開機自動啟動
[[email protected] ~]# chkconfig --add httpd
[[email protected] ~]# chkconfig --level 35 httpd on
5)優化apache命令
[[email protected] hppt-2.2.17]#ln -s /usr/local/httpd/binapachectl /usr/local/bin/
6)啟動apache服務
[[email protected] ~]# systemctl start httpd
3、安裝mysql
1)安裝依賴程式
[[email protected] ~]# yum -y install cmake ncurses-devel
2)建立管理組和使用者
[[email protected] ~]# groupadd mysql
[[email protected] ~]# useradd -M -s /sbin/nologin -g mysql mysql
3)配置mysql
[[email protected] ~]# tar zxvf /iso/mysql-5.5.22.tar.gz -C /usr/src/
[[email protected] mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc
4)編譯安裝mysql
[[email protected] ~]# make && make install
5)生成主配置檔案
[[email protected] mysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf
cp:是否覆蓋"/etc/my.cnf"? y
6)新增服務控制檔案
[[email protected] mysql-5.5.22]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql-5.5.22]# chmod +x /etc/init.d/mysqld
7)優化mysql命令
[[email protected] ~]# vim /etc/profile
/etc/profile
PATH=$PATH:/usr/local/mysql/bin/
[[email protected] ~]# source /etc/profile
[[email protected] ~]# chown -R mysql:mysql /usr/local/mysql/
8)新增系統服務設定開啟自動啟動
[[email protected] ~]# chkconfig --add mysqld
[[email protected] ~]# chkconfig --level 35 mysqld on
9)初始化mysql
[[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
10)啟動mysql服務設定密碼
[[email protected] ~]# systemctl start mysqld
[[email protected] ~]# mysqladmin -uroot password
二、配置LAMP
1、安裝php依賴工具
1)安裝libmcrypt
[[email protected] libmcrypt-2.5.8]# ./configure && make && make install
[[email protected] libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt* /usr/lib/
在這裡插入圖片描述
2)安裝mhash
[[email protected] mhash-0.9.9.9]# ./configure && make && make install
[[email protected] mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash* /usr/lib
在這裡插入圖片描述
3)安裝mcrypt
[[email protected] mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib
[[email protected] mcrypt-2.6.8]# ./configure
[[email protected] mcrypt-2.6.8]# make && make install
在這裡插入圖片描述
2、安裝配置php
1)安裝依賴程式
[[email protected] ~]# yum -y install libxml2-devel
在這裡插入圖片描述

2)配置php
[[email protected] php-5.3.28]# ./configure --prefix=/usr/local/php --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/php --enable-mbstring
在這裡插入圖片描述
3)編譯安裝php
[[email protected] php-5.3.28]# make && make install
在這裡插入圖片描述
在這裡插入圖片描述
4)生成php主配置檔案
[[email protected] php-5.3.28]# cp php.ini-production /usr/local/php/php.ini
在這裡插入圖片描述
5)修改php主配置檔案
[[email protected] ~]# vim /usr/local/php/php.ini
785 default_charset = “utf-8”
在這裡插入圖片描述
在這裡插入圖片描述
6)修改zend位置
[[email protected] ~]# cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-i386/
[[email protected] ZendGuardLoader-php-5.3-linux-glibc23-i386]# cd php-5.3.x/
[[email protected] php-5.3.x]# cp ZendGuardLoader.so /usr/local/php/lib/php/
在這裡插入圖片描述
在這裡插入圖片描述
7)修改hph主配置檔案載入zend
[[email protected] ~]# vim /usr/local/php/php.ini
[PHP]
zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so
zend_loader.enable=1
在這裡插入圖片描述
在這裡插入圖片描述
3、修改apche支援php
1)修改apache主配置檔案
[[email protected] ~]# cp /usr/local/httpd/conf/httpd.conf /usr/local/httpd/conf/httpd.conf.bak
cp:是否覆蓋"/usr/local/httpd/conf/httpd.conf.bak"? y
[[email protected] ~]# vim /usr/local/httpd/conf/httpd.conf
167 DirectoryIndex index.html index.php
310 AddType application/x-httpd-php .php
在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述
2)重新啟動apache
[[email protected] ~]# systemctl restart httpd
在這裡插入圖片描述
3)編輯php測試檔案
[[email protected] ~]# vim /usr/local/httpd/htdocs/index.php

<?php phpinfo(); ?>

在這裡插入圖片描述
在這裡插入圖片描述
驗證
在這裡插入圖片描述
掛在LAMP光碟
在這裡插入圖片描述
4、部署phpMyadmin專案
1)移動專案到網站的根目錄
[[email protected] src]# mv phpMyAdmin-3.3.10-all-languages/ /usr/local/httpd/htdocs/phpMyadmin
在這裡插入圖片描述
2)生成phpMyadmin配置檔案
[[email protected] ~]# cd /usr/local/httpd/htdocs/phpMyadmin/
[[email protected] phpMyadmin]# cp config.sample.inc.php config.inc.php
在這裡插入圖片描述
訪問phpMyadmin專案
在這裡插入圖片描述
3)訪問phpMyadmin專案
http://192.168.100.10/phpMyadmin

在這裡插入圖片描述
修改名字
在這裡插入圖片描述
在這裡插入圖片描述
域名解析
在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述