日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
CentOS6.7編譯安裝LAMP詳解

一、所需軟件下載

測試機環(huán)境為:

httpd2.4 下載:http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.25.tar.bz2

Apr 下載:http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.bz2

Apr-util 下載:

http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.bz2

Mariadb 10.1.21 下載:https://downloads.mariadb.org/ 官網(wǎng)下載目前不知道什么原因下載不了,需要通過特殊渠道(你懂得)來獲取最新的軟件。

php5.6.30 下載:http://php.net/get/php-5.6.30.tar.bz2/from/a/mirror

目前最新版已到7.1.2還是保守一點選擇了5.6的版本。編譯php時會依賴到其他的包,所以提前通過yum 安裝

1 yum install libxml2-devel bzip2-devellibmcrypt -y

Xcache php加速工具 下載:http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz

編譯xcache 需要依賴的包有m4和autoconf兩個包

1 yum install m4 autoconf -y

phpmyadmin 下載:

https://files.phpmyadmin.net/phpMyAdmin/4.6.6/phpMyAdmin-4.6.6-all-languages.zip

二、httpd安裝

CentOS 6.7中安裝的apr版本較低,編譯httpd2.4所需較新的版本,而直接通過yum升級系統(tǒng)現(xiàn)有版本apr包時可能會將其他依賴此程序包的軟件,因為apr的升級造成無法啟動,所以保險起見自己手動編譯新版本。

1、apr安裝

~]# tar –jxf apr-1.5.2.tar.bz2 –C /usr/local/src
~]# tar –jxf apr-util-1.5.4.tar.bz2 –C /usr/local/src
~]# cd /usr/local/src/apr-1.5.2
~]# ./confirure –prefix=/usr/local/apr
~]# make && make install    #apr安裝完成
~]# cd /usr/local/src/apr-util-1.5.4
~]# ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr  #with-apr參數(shù)指定編譯apr-util時所依賴的程序包,如不指定則編譯時會查找系統(tǒng)默認的安裝路徑去查找。
~]# make && make install

很多人都會有疑問apr到底有什么作用,為什么每次編譯都要用到這個包?

APR(Apache portable Run-time libraries,Apache可移植運行庫)的目的如其名稱一樣,主要為上層的應(yīng)用程序提供一個可以跨越多操作系統(tǒng)平臺使用的底層支持接口庫。

APR最大的作用就是socket調(diào)度。

2、httpd安裝

將下載的httpd-2.4.25解壓至/usr/local/src目錄中

~]# tar –jxf httpd-2.4.25.tar.bz2 –C /usr/local/src
~]# cd /usr/local/src/httpd-2.4.25
~]# ./configure –prefix=/usr/local/apache –sysconfdir=/etc/apache–enable-so –enable-ssl –enable-cgi –enable-rewrite –with-zlib –with-pcre –with-apr=/usr/local/apr–with-apr-util=/usr/local/apr-util –enable-modules=most –enable-mpms-shared=all–with-mpm=prefork
~]# make –j 4 && make install
#安裝完成之后進行啟動前配置,添加啟動用戶和組
~]# groupadd –r –g 80 apache
~]# useradd –r –g apache –u 80 apache
#為apache提供服務(wù)腳本
~]# vim /etc/rc.d/init.d/apache
#!/bin/bash
#
#httpd        Startup script for theApache HTTP Server
#
#chkconfig: - 85 15
#description: Apache is a World Wide Web server. It is used to serve \
#        HTML files and CGI.
#processname: httpd
# config:/etc/httpd/conf/httpd.conf
# config:/etc/sysconfig/httpd
#pidfile: /var/run/httpd.pid
 
# Sourcefunction library.
./etc/rc.d/init.d/functions
 
if [ -f/etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi
 
# Starthttpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
 
# Thiswill prevent initlog from swallowing up a pass-phrase prompt if
# mod_sslneeds a pass-phrase from the user.
INITLOG_ARGS=""
 
# SetHTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# withthe thread-based "worker" MPM; BE WARNED that some modules may not
# workcorrectly with a thread-based MPM; notably PHP will refuse to start.
 
# Path tothe apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
 
start() {
  echo -n $"Starting $prog: "
  LANG=$HTTPD_LANG daemon --pidfile=${pidfile}$httpd $OPTIONS
  RETVAL=$?
  echo
  [ $RETVAL = 0 ] && touch${lockfile}
  return $RETVAL
}
 
stop() {
  echo -n $"Stopping $prog: "
  killproc -p ${pidfile} -d 10 $httpd
  RETVAL=$?
  echo
  [ $RETVAL = 0 ] && rm -f ${lockfile}${pidfile}
}
reload(){
    echo -n $"Reloading $prog: "
    if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t>&/dev/null; then
        RETVAL=$?
        echo $"not reloading due toconfiguration syntax error"
        failure $"not reloading $httpd dueto configuration syntax error"
    else
        killproc -p ${pidfile} $httpd -HUP
        RETVAL=$?
    fi
    echo
}
 
# See howwe were called.
case"$1" in
  start)
  start
  ;;
  stop)
  stop
  ;;
  status)
        status -p ${pidfile} $httpd
  RETVAL=$?
  ;;
  restart)
  stop
  start
  ;;
  condrestart)
  if [ -f ${pidfile} ] ; then
    stop
    start
  fi
  ;;
  reload)
        reload
  ;;
  graceful|help|configtest|fullstatus)
  $apachectl $@
  RETVAL=$?
  ;;
  *)
  echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
  exit 1
esac
 
exit $RETVAL
~]# chmod +x /etc/rc.d/init.d/apache
~]# chkconfig –add apache
~]# service apache start        #測試啟動是否成功

默認情況下系統(tǒng)防火墻會將80端口禁止通信,網(wǎng)上好多編譯安裝時,為了方便都會將防火墻關(guān)閉,我覺得生產(chǎn)環(huán)境中關(guān)閉防火墻畢竟不太安全,估計也沒人這么干,現(xiàn)在就將用到的80端口以及mariadb和php用到的3306、9000端口都開放。

~]# iptables –I INPUT –p ctp –m multiport –dports80,8080,3306,9000 –m state –state NEW,ESTABLISHED –j ACCEPT
#注:防火墻策略一般是自上而下審核,所以為了避免與其他策略沖突,直接將此條策略加入到最上方。
~]# setenforce 0    #設(shè)置selinux為Permissive模式,后續(xù)可能會將htdocs目錄指向其他路徑,如果不設(shè)為Permissive會無法訪問。

最后在瀏覽器中填入測試機的IP地址,配置成功會有以下顯示。

下面關(guān)于LAMP相關(guān)的內(nèi)容你可能也喜歡

三、mariadb安裝

首先將mysql用戶mysql組。

~]# groupadd –r –g 36 mysql
~]# useradd –r –g mysql –u 36 mysql

此處使用的是二進制格式的程序包,解壓至特定路徑后簡單配置后即可使用。

在生產(chǎn)環(huán)境當中數(shù)據(jù)庫文件會單獨存放在一個較大的空間當中,在此測試機中模擬有兩塊硬盤,在兩塊硬盤當中各劃分出50G的空間來組成邏輯卷來存放數(shù)據(jù)文件,下邊就來進行具體操作。

~]# yum install lvm2                #此步如果系統(tǒng)中已安裝lvm管理工具可跳過
~]# pvcreate /dev/sd{a,b}3    #將硬盤a,b中的分區(qū)添加到物理卷
~]# vgcreate –s 16M datavg /dev/sd{a,b}3    #將物理卷中的兩塊物理卷加入到datavg物理卷組中
~]# lvcreate –L 50G –n marialv datavg          #將物理卷組中分出50G空間來創(chuàng)建marialv邏輯卷
~]# mkfs –t ext4 –m 1 –L “mariadata” –b 2048/dev/datavg/marialv  #格式化marialv邏輯卷
~]# mount /dev/datavg/marialv /data/
~]# mkdir /data/mariadb –p            #創(chuàng)建數(shù)據(jù)存放路徑
~]# chown mysq:mysql /data/mariadb #更改mariadb目錄的屬組屬主為mysql
#至此數(shù)據(jù)存放位置準備完畢,如果需要開機掛載此目錄則需要修改/etc/fstab文件
~]# tar –zxf mariadb-10.1.21-linux-x86_64.tar.gz –C/usr/local
~]# cd /usr/local
~]# ln –s mariadb-10.1.21 mysql            #默認安裝配置都要mysql目錄中,所以需要將解壓后的數(shù)據(jù)庫做一個鏈接,也方便日后數(shù)據(jù)庫升級,直接將鏈接更新即可。
~]# cd mysql
~]# chown –R root:mysql ./*                    #將程序包中的所有文件屬主屬組修改為root用戶mysql組
~]# scripts/mysql_install_db  --datadir=/data/mariadb –user=mysql  #此步驟需要注意,mysql_install_db只能在scripts目錄中執(zhí)行,執(zhí)行完畢之后如果不出意外安裝完成了o(╯□╰)o

先不要急著運行,后續(xù)還要有點小調(diào)整,因為mariadb還木有配置文件和啟動腳本呢!下邊就來將這兩項做好。

還是在mysql目錄中操作,這點需要注意

mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld  #添加啟動腳本
mysql]# chkconfig –add mysqld
mysql]# mkdir /etc/mariadb
mysql]# cp support-files/my-larg.cnf  /etc/mariadb/my.cnf
#在support-files目錄中提供了三個針對不同硬件的配置文件,可以根據(jù)自己系統(tǒng)硬件的不同來自行選配,這里選擇的是my-larg.cnf
#編輯my.cnf并添加以下三個選項
mysql]# vim /etc/mariadb/my.cnf
 
[client]
#password  = your_password
port        = 3306
#socket    = /tmp/mysql.sock
socket      = /data/mariadb /mysql.sock
 
# Herefollows entries for some specific programs
# TheMariaDB server
[mysqld]
port        = 3306
socket = /data/mariadb /mysql.sock
#…省略其他不變的選項
thread_concurrency= 8                  #這個參數(shù)可以根據(jù)自己服務(wù)器硬件配置來更改,一般為CPU個數(shù)乘以2
datadir=/data/mariadb                      #數(shù)據(jù)庫存放路徑
innodb_file_per_table= on              #每個數(shù)據(jù)表存儲類型都是獨立的
skip_name_resolve = on                    #跳過數(shù)據(jù)庫反向解析主機名
 
mysql]#bin/mysql_secure_installation        #可以為root設(shè)置密碼,刪除匿名用戶等一些操作
配置完成可以運行service mysqld start啟動服務(wù)
 ~]#ss –nat|grep 3306    #可以看到端口已經(jīng)啟動


網(wǎng)站標題:CentOS6.7編譯安裝LAMP詳解
文章網(wǎng)址:http://www.dlmjj.cn/article/djhhiei.html