溫馨提示×

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

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

在同一臺(tái)CentOS release 6.5 (Final)x86_64上裝lanp和lnmp

發(fā)布時(shí)間:2020-05-25 12:13:18 來源:網(wǎng)絡(luò) 閱讀:1020 作者:13240702173 欄目:MySQL數(shù)據(jù)庫

CentOS release 6.5 (Final)x86_64

lamp

apache
wget http://archive.apache.org/dist/httpd/httpd-2.2.27.tar.gz
tar cd
./configure --prifix=/application/apache2.2.27 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite
yum install -y zlib-devel
make && make install
ln -s /application/apache2.2.27/ /application/apache
ll /application/apache/conf/httpd.conf
/application/apache/bin/apachectl -t
/application/apache/bin/apachectl graceful
ps -ef|grep httpd

mqsql
wget https://downloads.mysql.com/archives/get/file/mysql-5.1.68.tar.gz
tar cd
./configure --prefix=/application/mysql5.1.68/ --with-unix-socket-path=/application/mysql5.1.68/tmp/mysql.sock --localstatedir=/application/mysql5.1.68/data --enable-assembler --enable-thread-safe-client --with-mysqld-user=mysql --with-big-tables --without-debug --with-pthread --enable-assembler --with-extra-charsets=complex --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-plugin-PLUGIN
echo $?
yum install -y ncurses-devel
make && make install
/home/oldboy/mysql-5.1.68/support-files/my-small.cnf /etc/my.cnf
/application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql
/home/oldboy/mysql-5.1.68/support-files/mysql.server /etc/init.d/mysqld
登陸mysql測(cè)試

php
1.php依賴包
yum install -y zlib libxml libpng libjpeg freetype gd curl libiconv zlib-devel libxml2-devel libpng-devel libjpeg-devel freetype-devel gd-devel curl-devel libcronv-devel openssl-devel libcurl-devel libxslt-devel
2.php包
http://php.net/get/php-5.3.27.tar.gz/from/a/mirror下到本地,傳到用戶家目錄
tar xf php-5.3.27.tar.gz
cd php-5.3.27
./configure --prefix=/application/php5.3.27 --with-apxs2=/application/apache/bin/apxs --with-mysql=/application/mysql --with-xmlrpc --with-openssl --with-zib --with-freetype-dir --with-gd --with-jpeg-dir --with-png-dir --with-iconv=/usr/local/libiconv --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap --enable-mbstring --enable-gd-native-ttf --with-curl --with-xsl --enable-ftp --with-libxml-dir
make
make install
ln -s /application/php5.3.27 /application/php
cp php.ini-production /application/php/lib/php.ini
/application/apache/conf/httpd.conf 修改apache的
·LoadModule php5_module modules/libphp5.so
·User www
·Group www
·ServerName 127.0.0.1:80
·DirectoryIndex index.php index.html
useradd -M -s /sbin/nologin www
/application/apache/bin/apachectl graceful
測(cè)試瀏覽器--index.html>>apache--index.php>>php--php腳本>>mysql

php腳本內(nèi)容
<?php
$link_id=mysql_connect('localhost','root','123456') or mysql_error();

    if ($link_id) {
                    echo "php-->mysqk successful";
    }else{
                    echo "php ->mysql error()";
    }

?>

lnmp

安裝nginx
wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2
useradd -M -s /sbin/nologin nginx
yum install gcc pcre-devel openssl-devel -y
./configure --user=nginx --group=nginx --prefix=/application/nginx1.6.2 --with-http_stub_status_module --with-http_ssl_module
make
make install
/application/nginx1.6.2/sbin/nginx -t
/application/nginx1.6.2/sbin/nginx
ps -ef |grep nginx
注意防火墻

用二進(jìn)制文件裝mysql
wget https://downloads.mysql.com/archives/get/file/mysql-5.5.32-linux2.6-x86_64.tar.gz --no-check-certificate
tar -zxvf mysql-5.5.32-linux2.6-x86_64.tar.gz
mv mysql-5.5.32-linux2.6-x86_64 /application/mysql
cp my-small.cnf /etc/my.cnf
useradd -M -s /sbin/nologin mysql
./mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data
cp support-files/mysql.server /etc/init.d/mysqld
修改/etc/init.d/mysqld里的basedir 和datadir
/etc/init.d/mysqld start
測(cè)試
/application/mysql/bin/mysql
export PATH=$PATT:/application/mysql/bin/mysql

php
php依賴包
yum install -y zlib libxml libpng libjpeg freetype gd curl libiconv zlib-devel libxml2-devel libpng-devel libjpeg-devel freetype-devel gd-devel curl-devel libcronv-devel openssl-devel libcurl-devel libxslt-devel gcc gcc-c++ libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar -zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz --no-check-certificate
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
sleep 2
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make && make install
wget https://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz --no-check-certificate
tar -zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make && make install
rm -f /usr/lib64/libmhash.

rm -f /usr/lib64/libmcrypt.*
ln -s /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la
ln -s /usr/local/lib64/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a
ln -s /usr/local/lib64/libmhash.la /usr/lib64/libmhash.la
ln -s /usr/local/lib64/libmhash.so /usr/lib64/libmhash.so
ln -s /usr/local/lib64/libmhash.so.2 /usr/lib64/libmhash.so.2
ln -s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
ln -s /usr/local/lib64/libmcrypt-config /usr/lib64/libmcrypt-config
wget https://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz --no-check-certificate
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
/sbin/ldconfig
./configure LD_LIBRARY_PATH=/usr/local/lib
make
make install

php安裝
wget http://mirrors.sohu.com/php/php-5.3.27.tar.gz
tar -zxvf php-5.3.27.tar.gz
cd php-5.3.27
./configure --prefix=/application/php5.3.27 --with-mysql=/application/mysql --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-zend-multibyte --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp
ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64
make
make install
ln -s /application/php5.3.27/ /application/php
cp php.ini-production /application/php/lib/php.ini
cd /application/php/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf 里的
pid = /app/logs/php-fpm.pid
error_log = /app/logs/php-fpm.log
log_level = error
rlimit_files = 32768
listen.owner = nginx
listen.owner = nginx
pm.max_children = 1024
pm.start_servers = 16
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.process_idle_timeout = 15s;
pm.max_requests = 2048
slowlog = /app/logs/$pool.log.slow
request_slowlog_timeout = 10
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f wenxianfeng@linekong.com

mkdir /app/logs -p
/application/php/sbin/php-fpm -t
/application/php/sbin/php-fpm
netstat -nltpu |grep php-fpm
ps -ef |grep php-fpm

開機(jī)自啟動(dòng)/etc/rc.local
/etc/init.d/mysqld start
/application/php/sbin/php-fpm
/application/nginx1.6.2/sbin/nginx
在nginx虛擬主機(jī)里加判定若是.php文件調(diào)用php的fastcgi
location ~ .*.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}

用下列php腳本測(cè)試nginx到mysql通否 wen.php
<?php
$link_id=mysql_connect('localhost','root','123456') or mysql_error();

if ($link_id) {
                echo "php-->mysqk successful";
}else{
                echo "php ->mysql error()";
}

?>
刷新頁面或/application/php/bin/php wen.php

到http://kaiyuan.baike.com/ 下載HDwiki5.1正式版 GBK版放到站點(diǎn)目錄下
unzip HDWiki-v5.1GBK-20141205.zip
把wiki目錄下的文件放到站點(diǎn)目錄下
給wiki所在站點(diǎn)目錄權(quán)限 chown -R nginx.nginx bbs
刷新網(wǎng)頁,圖形配置wiki

nginx反向代理
服務(wù)器上搭nginx服務(wù),服務(wù)正常后
egrep -v "^$|#" nginx.conf.default > nginx.conf
upstream backend {
server 后端web:80 max_fails=3 fail_timeout=30s;
server 后端web:80 max_fails=3 fail_timeout=30s;
}
根據(jù)http://nginx.org/en/docs/http/ngx_http_upstream_module.html upstream 和proxy 模塊
在nginx虛擬主機(jī)里加上
location / {
proxy_pass http://backend;
}
不斷訪問反向代理服務(wù)器看是否交給后端服務(wù)器處理或者寫for循環(huán)在反向代理機(jī)器測(cè)試
客戶端解析域名成反向代理ip,反向代理交給后端服務(wù)器(ip),默認(rèn)會(huì)讀取第一個(gè)虛擬主機(jī),要是想讀取某個(gè)域名的虛擬主機(jī),需在反向代理服務(wù)器配置文件里加
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;

向AI問一下細(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