溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

CentOS 6.4 x64 安裝Tengine+MaraiaDB+php-fpm+Discuz

發(fā)布時(shí)間:2020-10-04 19:15:43 來(lái)源:網(wǎng)絡(luò) 閱讀:789 作者:linux_python 欄目:web開(kāi)發(fā)

系統(tǒng)環(huán)境:Centos6.4X64

安裝方式:yum安裝

tengine是由淘寶網(wǎng)發(fā)起的Web服務(wù)器項(xiàng)目。它在tengine的基礎(chǔ)上,針對(duì)大訪問(wèn)量網(wǎng)站的需求,添加了很多高級(jí)功能和特性。tengine的性能和穩(wěn)定性已經(jīng)在大型的網(wǎng)站如淘寶網(wǎng),天貓商城等得到了很好的檢驗(yàn)。它的最終目標(biāo)是打造一個(gè)高效、穩(wěn)定、安全、易用的Web平臺(tái)。

tengine不支持對(duì)外部程序的直接調(diào)用或者解析,所有的外部程序(包括PHP)必須通過(guò)FastCGI接口來(lái)調(diào)用。FastCGI接口在Linux下是socket,(這個(gè)socket可以是文件socket,也可以是ip socket)。為了調(diào)用CGI程序,還需要一個(gè)FastCGIwrapperwrapper可以理解為用于啟動(dòng)另一個(gè)程序的程序),這個(gè)wrapper綁定在某個(gè)固定socket上,如端口或者文件socket。當(dāng)tengineCGI請(qǐng)求發(fā)送給這個(gè)socket的時(shí)候,通過(guò)FastCGI接口,wrapper接納到請(qǐng)求,然后派生出一個(gè)新的線程,這個(gè)線程調(diào)用解釋器或者外部程序處理腳本并讀取返回?cái)?shù)據(jù);接著,wrapper再將返回的數(shù)據(jù)通過(guò)FastCGI接口,沿著固定的socket傳遞給tengine;最后,tengine將返回的數(shù)據(jù)發(fā)送給客戶端,這就是tengine+FastCGI的整個(gè)運(yùn)作過(guò)程。


1.安裝MariaDB

由于Oracle進(jìn)一步對(duì)mysql閉源的舉措讓人難以安心,眾多互聯(lián)網(wǎng)公司紛紛開(kāi)始尋求MySQL的替代方案。而MariaDB是一個(gè)向后兼容、替代MySQL的數(shù)據(jù)庫(kù)服務(wù)器。它包含所有主要的開(kāi)源存儲(chǔ)引擎。所以建議使用MariaDB

1.先卸載系統(tǒng)中mysql數(shù)據(jù)庫(kù)

[root@tengine ~]#yum remove mysql mysql-*

2.配置Mariadb安裝源

/etc/yum.repos.d/ 下建立 MariaDB.repo,內(nèi)容如下:

[root@tengine ~]# vi /etc/yum.repos.d/MariaDB.repo

[mariadb]

name = MariaDB

baseurl =http://yum.mariadb.org/10.0.4/centos6-amd64/

gpgkey=http://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1


3.使用YUM安裝MariaDB

[root@tengine ~]#yum -y install MariaDB-client MariaDB-server MariaDB-devel

4.啟動(dòng)數(shù)據(jù)庫(kù)

[root@tengine ~]#service mysql start

5.修改Root的密碼

[root@tengine ~]# mysqladmin -uroot password 'password'


2.關(guān)閉selinux和設(shè)置iptable防火墻

1.關(guān)閉selinux

[root@tengine ~]# vi /etc/selinux/config

SELINUX= enforcing更改為SELINUX=disable

     [root@tengine ~]#setenforce 0

2.設(shè)置iptable

[root@tengine ~]# vi /etc/sysconfig/iptables

增加

-AINPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

3.添加一個(gè)nginx用戶

[root@tengine ~]#groupadd nginx

[root@tengine ~]#useradd -s /sbin/nologin -g nginx nginx

4.安裝pcre

1.下載pcre

[root@tengine ~]#wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz

2.安裝pcre用于支持tengine偽靜態(tài)

[root@tengine ~]#tar -zxvf pcre-8.33.tar.gz

[root@tengine ~]#mkdir /usr/local/pcre

[root@tengine ~]#cd pcre-8.33

[root@tengine pcre-8.33]#./configure --prefix=/usr/local/pcre

[root@tengine pcre-8.33]#make

[root@tengine pcre-8.33]#make install

5.安裝tengine

1.下載tengine1.51

[root@tenginepcre-8.33]#cd ~

[root@tengine ~]#yum install openssl openssl-devel

[root@tengine ~]#wget http://tengine.taobao.org/download/tengine-1.5.1.tar.gz

2.安裝tengine

[root@tengine ~]#mkdir /usr/local/nginx

[root@tengine ~]#tar -zxvf tengine-1.5.1.tar.gz

[root@tengine ~]#cd tengine-1.5.1

[root@tengine tengine-1.5.1]# ./configure--prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/root/pcre-8.33

注:--with-pcre=/root/pcre-8.33指向的是源碼包解壓的路徑,而不是安裝的路徑,否則會(huì)報(bào)錯(cuò)。

[root@tenginetengine-1.5.1]#make

[root@tenginetengine-1.5.1]#make install

[root@tengine~]#chown nginx.nginx -R /usr/local/nginx/html

[root@tengine~]#chmod 700 -R /usr/local/nginx/html

6.設(shè)置tengine服務(wù)

[root@tengine ~]# vi /etc/rc.d/init.d/nginx

#!/bin/bash

# Tengine Startup script# processname: nginx

# pidfile: /var/run/nginx.pid

# config: /usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin/nginx

nginx_config=/usr/local/nginx/conf/nginx.conf

nginx_pid=/usr/local/nginx/logs/nginx.pid

RETVAL=0

prog="nginx"

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[ ${NETWORKING} = "no" ] && exit 0

[ -x $nginxd ] || exit 0

# Start nginx daemons functions.

start() {

if [ -e $nginx_pid ];then

echo "tengine already running...."

exit 1

fi

echo -n $"Starting $prog: "

daemon $nginxd -c ${nginx_config}

RETVAL=$?

echo

[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx

return $RETVAL

}

# Stop nginx daemons functions.

stop() {

echo -n $"Stopping $prog: "

killproc $nginxd

RETVAL=$?

echo

[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid

}

reload() {

echo -n $"Reloading $prog: "

#kill -HUP `cat ${nginx_pid}`

killproc $nginxd -HUP

RETVAL=$?

echo

}

# See how we were called.

case "$1" in

start)

start

;;

stop)

stop

;;

reload)

reload

;;

restart)

stop

start

;;


status)

status $prog

RETVAL=$?

;;

*)

echo $"Usage: $prog {start|stop|restart|reload|status|help}"

exit 1

esac

exit $RETVAL


[root@tengine ~]# chmod 775 /etc/rc.d/init.d/nginx

[root@tengine ~]# chkconfig nginx on

[root@tengine ~]# service nginx start


7.安裝PHP及相關(guān)組件

1.安裝PHP

[root@tengine ~]#yum -y install php

2.安裝PHP組件,使PHP支持FastCGI模式

[root@tengine ~]#yum -y install php-mysql php-gd libjpeg* php-imap php-ldap php-odbcphp-pear php-xml php-xmlrpc php-mbstring php-bcmath php-fpm

8.整合NginxPHP

[root@tengine ~]#vi /usr/local/nginx/conf/nginx.conf

把第二行注釋去掉并把nobody更改為nginx

worker_processes 根據(jù)cpu個(gè)數(shù)進(jìn)行設(shè)置


把71行到77行的注釋去掉,并把/scripts替換為/usr/local/nginx/html

注:上面的/usr/local/nginx/html 是我們PHP網(wǎng)站放置的路徑

CentOS 6.4 x64 安裝Tengine+MaraiaDB+php-fpm+Discuz

[root@tengine ~]#vi /etc/php-fpm.d/www.conf

把39行和41行的apache更改為nginx


9.下載Discuz測(cè)試tengine、phpMariadb

1.測(cè)試tengine

在瀏覽器輸入http://175.102.13.55

2.測(cè)試php

[root@tengine ~]#vi /usr/local/nginx/html/index.php

<?php

phpinfo();

?>

在瀏覽器輸入http://175.102.13.55/index.php


3.下載DiscuzX測(cè)試Mariadb

[root@tengine~]#wget http://download.comsenz.com/DiscuzX/3.1/Discuz_X3.1_SC_UTF8.zip

[root@tengine~]# unzip Discuz_X3.1_SC_UTF8.zip

[root@tengine~]# mv upload/* /usr/local/nginx/html

[root@tengine~]# chown nginx.nginx -R /usr/local/nginx/html

CentOS 6.4 x64 安裝Tengine+MaraiaDB+php-fpm+Discuz

CentOS 6.4 x64 安裝Tengine+MaraiaDB+php-fpm+Discuz

CentOS 6.4 x64 安裝Tengine+MaraiaDB+php-fpm+Discuz

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI