Rhel6-lanmp架构配置文档

理论基础:

l--操作系统:windows  linux  unix  mac OS

a--网页发布软件:apache nginx iis

m--数据库:mysql  pgsql  oracle...

p--网页语言:php  jsp  xml

配置:

系统环境: rhel6 x86_64 iptables and selinux disabled

主机: 192.168.122.185 server85.example.com

相关网址:wiki.nginx.org rpm.pbone.net

所需的包:mysql-5.6.10.tar.gz nginx-1.2.7.tar.gz libiconv-1.13.1.tar.gz libmcrypt-2.5.8.tar.bz2 mhash-0.9.9.9.tar.bz2 mcrypt-2.6.8.tar.gz php-5.4.12.tar.bz2

1.安装mysql

[[email protected]
kernel]# tar zxf mysql-5.6.10.tar.gz

[[email protected]
kernel]# cd mysql-5.6.10

[[email protected]
mysql-5.6.10]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql \
(安装目录)

>
-DMYSQL_DATADIR=/usr/local/lnmp/mysql/data \ (数据库存放目录)

>
-DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock \ (Unix
socket 文件路径)

>
-DWITH_MYISAM_STORAGE_ENGINE=1 \ (安装myisam存储引擎)

>
-DDEFAULT_CHARSET=utf8 \ (使用utf8字符)

>
-DDEFAULT_COLLATION=utf8_general_ci \ (校验字符)

>
-DEXTRA_CHARSETS=all \ (安装所有扩展字符集)

此时会出现如下问题:

(1)-bash:
cmake: command not found

(2)CMake
Error: CMAKE_C_COMPILER not set, after EnableLanguage

CMake
Error: CMAKE_CXX_COMPILER not set, after
EnableLanguage

(3)emove
CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is
libncurses5-dev, on Redhat and derivates it is ncurses-devel.

(4)Warning:
Bison executable not found in PATH

解决方法如下:

(1)[[email protected]
mysql-5.6.10]# yum install cmake -y

(2)[[email protected]
mysql-5.6.10]# yum install gcc gcc-c++ -y

(3)[[email protected]
mysql-5.6.10]# yum install ncurses-devel -y

(4)[[email protected]
mysql-5.6.10]# yum install bison -y

[[email protected]
mysql-5.6.10]# make && make install

重新编译时,需要清除旧的对象文件和缓存信息:

[[email protected]
mysql-5.6.10]# yum install make -y

[[email protected]
mysql-5.6.10]# make clean

[[email protected]
mysql-5.6.10]# rm -rf CMakeCache.txt

[[email protected]
mysql-5.6.10]# useradd -u 27 -d /usr/local/lnmp/mysql/ -M mysql

[[email protected]
mysql-5.6.10]# groupmod -g 27 mysql

[[email protected]
mysql-5.6.10]# chown mysql.mysql -R /usr/local/lnmp/mysql/

[[email protected]
mysql-5.6.10]# cp /usr/local/lnmp/mysql/support-files/my-default.cnf
/etc/my.cnf

[[email protected]
mysql-5.6.10]# vim /etc/my.cnf

basedir
=
/usr/local/lnmp/mysql

datadir
= /usr/local/lnmp/mysql/data

port
= 3306

server_id
= 1

socket
= /usr/local/lnmp/mysql/data/mysql.sock

[[email protected]
mysql-5.6.10]# cd /usr/local/lnmp/mysql/

[[email protected]
mysql]# scripts/mysql_install_db
--user=mysql--basedir=/usr/local/lnmp/mysql/
--datadir=/usr/local/lnmp/mysql/data/

[[email protected]
mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[[email protected]
mysql]# chown root -R /usr/local/lnmp/mysql/

[[email protected]
mysql]# chown mysql -R /usr/local/lnmp/mysql/data/

[[email protected]
mysql]# /etc/init.d/mysqld start

Starting
MySQL. SUCCESS! (看到此提示说明mysql启动成功)

[[email protected]
mysql]# vim ~/.bash_profile

PATH=$PATH:$HOME/bin:$PATH:/usr/local/lnmp/mysql/bin

[[email protected]
mysql]# source ~/.bash_profile

至此mysql安装完成!!!

2.安装及配置nginx

(1)安装:

[[email protected]
kernel]# tar zxf nginx-1.2.7.tar.gz

[[email protected]
kernel]# cd nginx-1.2.7

[[email protected]
nginx-1.2.7]# vim src/core/nginx.h

#define
NGINX_VER "nginx" (编译后外界无法获取程序的版本号)

[[email protected]
nginx-1.2.7]# vim auto/cc/gcc

#CFLAGS="$CFLAGS
-g"(去掉debug模式编译,编译以后程序只有几百k)

[[email protected] nginx-1.2.7]# ./configure
--prefix=/usr/local/lnmp/nginx --with-http_ssl_module
--with-http_stub_status_module

此时会出现如下错误:

(1)./configure:
error: the HTTP rewrite module requires the PCRE library.

(2)./configure:
error: SSL modules require the OpenSSL library.

解决方法如下:

(1)[[email protected]
nginx-1.2.7]# yum install pcre-devel -y

(2)[[email protected]
nginx-1.2.7]# yum install openssl-devel -y

[[email protected]
nginx-1.2.7]# make && make install

[[email protected]
nginx-1.2.7]# cd /usr/local/lnmp/nginx/conf/

[[email protected]
conf]# vim nginx.conf

events
{

use epoll;

worker_connections
1024;

}

[[email protected]
conf]# vim ~/.bash_profile

PATH=$PATH:$HOME/bin:$PATH:/usr/local/lnmp/mysql/bin: $PATH:/usr/local/lnmp/nginx/sbin

[[email protected]
conf]# source ~/.bash_profile

[[email protected]
conf]# nginx (启动nginx)

[[email protected]
conf]# nginx -t ( 检测语法)

[[email protected]
conf]# nginx -s reload (重载主配置文件)

[[email protected]
conf]# nginx -s stop (关闭nginx)

访问server85.example.com能出现以下页面说明nginx安装并启动成功:

(2)配置(/etc/hosts下:192.168.122.185 server85.example.com)

[root@server85 ~]# useradd nginx

[root@server85 ~]# vim /usr/local/lnmp/nginx/conf/nginx.conf

user nginx nginx;

worker_processes 4;

[root@server85 ~]# nginx -t

nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful

[root@server85 ~]# nginx -s reload

[root@server85 ~]# ps ax

5922 ? Ss 0:00 nginx: master process nginx

5942 ? S 0:00 nginx: worker process

5943 ? S 0:00 nginx: worker process

5944 ? S 0:00 nginx: worker process

5945 ? S 0:00 nginx: worker process (进程数与配置的数目对应)

[root@server85
~]# vim /usr/local/lnmp/nginx/conf/nginx.conf

location /status {

stub_status
on;

access_log
off;

}

[root@server85
~]# nginx -s reload

访问server85.example.com出现以下页面说明配置成功:

HTTPS加密访问

[root@server85
~]# vim /usr/local/lnmp/nginx/conf/nginx.conf

server {

listen 443;

server_name
server85.example.com;

ssl
on;

ssl_certificate

nginx.pem;

ssl_certificate_key
nginx.pem;

ssl_session_timeout
5m;

ssl_protocols SSLv2
SSLv3 TLSv1;

ssl_ciphers
HIGH:!aNULL:!MD5;

ssl_prefer_server_ciphers
on;

location / {

root html;

index index.html
index.htm;

}

}

[root@server85
~]# cd /etc/pki/tls/certs/

[root@server85
certs]# make nginx.pem

Country
Name (2 letter code) [XX]:CN

State
or Province Name (full name) []:shannxi

Locality
Name (eg, city) [Default City]:xi‘an

Organization
Name (eg, company) [Default Company Ltd]:westos

Organizational
Unit Name (eg, section) []:linux

Common
Name (eg, your name or your server‘s hostname)
[]:server85.example.com

Email
Address []:root@server85.example.com

[root@server85
certs]# mv nginx.pem /usr/local/lnmp/nginx/conf/

[root@server85
certs]# nginx -s reload

访问https://server85.example.com时需要先下载证书说明配置成功。

虚拟主机

[root@server85 ~]# vim /usr/local/lnmp/nginx/conf/nginx.conf

log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘

‘$status $body_bytes_sent "$http_referer" ‘

‘"$http_user_agent" "$http_x_forwarded_for"‘;

server {

listen 80;

server_name www.linux.com;

access_log logs/linux.com.access.log main;

location / {

index index.html;

root /usr/local/lnmp/nginx/virtualhosts/linux;

}

}

server {

listen 80;

server_name www.westos.com;

access_log logs/westos.com.access.log main;

location / {

index index.html;

root /usr/local/lnmp/nginx/virtualhosts/westos;

}

}

[root@server85 ~]# cd /usr/local/lnmp/nginx/

[root@server85 nginx]# mkdir -p virtualhosts/linux

[root@server85 nginx]# mkdir -p virtualhosts/westos

[root@server85 nginx]# echo www.linux.com > virtualhosts/linux/index.html

[root@server85 nginx]# echo www.westos.com > virtualhosts/westos/index.html

[root@server85 nginx]# nginx -s reload

[root@server85 nginx]# vim /etc/hosts

192.168.122.185 www.linux.com www.westos.com

分别访问www.linux.com和www.westos.com能访问到不同的网页说明配置成功。

负载均衡

[root@server85
~]# vim /usr/local/lnmp/nginx/conf/nginx.conf

http
{

upstream
koen{

server
192.168.122.117:80;

server
192.168.122.1:80 ;

}

server
{

listen 80;

server_name
server85.example.com;

location / {

#
root html;

#
index index.html index.htm;

proxy_pass
http://koen ;

}

}

[root@server85
~]# nginx -s reload

访问server85.example.com,
刷新页面,两台机子上的页面循环出现说明配置成功.

至此nginx的安装及配置完毕!!!

3.安装php

libiconv
(加强系统对支持字符编码转换的功能)

[root@server85
kernel]# tar zxf libiconv-1.13.1.tar.gz

[root@server85
kernel]# cd libiconv-1.13.1

[root@server85
libiconv-1.13.1]# ./configure –libdir=/usr/local/lib64/

[root@server85
libiconv-1.13.1]# make && make install

libmcrypt
(php的加密算法扩展库)

[root@server85
kernel]# tar jxf libmcrypt-2.5.8.tar.bz2

[root@server85
kernel]# cd libmcrypt-2.5.8

[root@server85
libmcrypt-2.5.8]# ./configure –libdir=/usr/local/lib64/

[root@server85
libmcrypt-2.5.8]# make && make install

mhash
(php的加密算法扩展库)

[root@server85
kernel]# tar jxf mhash-0.9.9.9.tar.bz2

[root@server85
kernel]# cd mhash-0.9.9.9

[root@server85
mhash-0.9.9.9]# ./configure –libdir=/usr/local/lib64/

[root@server85
mhash-0.9.9.9]# make && make install

mcrypt

[root@server85
kernel]# tar zxf mcrypt-2.6.8.tar.gz

[root@server85
kernel]# cd mcrypt-2.6.8

[root@server85
mcrypt-2.6.8]# ./configure –libdir=/usr/local/lib64/

此时会出现如下错误:

configure:
error: *** libmcrypt was not found

解决方法如下:

[root@server85
mcrypt-2.6.8]# vim /etc/ld.so.conf

include
ld.so.conf.d/*.conf

/usr/local/lib64

[root@server85
mcrypt-2.6.8]# ldconfig

[root@server85
mcrypt-2.6.8]# make && make install

./configure时可能会报错:/bin/rm:cannot
remove ‘libtoolT‘:No Such file or directory直接忽略.

php

[root@server85
kernel]# tar jxf php-5.4.12.tar.bz2

[root@server85
kernel]# cd php-5.4.12

[root@server85
php-5.4.12]# yum install net-snmp-devel curl-devel libxml2-devel
libpng-devel libjpeg-devel freetype-devel gmp-devel -y

[root@server85
php-5.4.12]# ./configure --prefix=/usr/local/lnmp/php
--with-config-file-path=/usr/local/lnmp/php/etc
--with-mysql=/usr/local/lnmp/mysql/ --with-openssl --with-snmp
--with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir
--with-jpeg-dir --with-freetype-dir --with-pear --with-gettext
--with-gmp --enable-inline-optimization --enable-soap --enable-ftp
--enable-sockets --enable-mbstring
--with-mysqli=/usr/local/lnmp/mysql/bin/mysql_config --enable-fpm
--with-fpm-user=nginx --with-fpm-group=nginx --with-libdir=lib64
--with-mcrypt –with-mhash

此时会出现以下错误:

checking
for MySQL support... yes

checking
for specified location of the MySQL UNIX socket... no

configure:
error: Cannot find libmysqlclient under /usr/local/lnmp/mysql/.

Note
that the MySQL client library is not bundled anymore!

解决方法如下:

[root@server85
php-5.4.12]# cd /usr/local/lnmp/mysql/

[root@server85
mysql]# ln -s lib/ lib64

[root@server85
php-5.4.12]# make ZEND_EXTRA_LIBS=‘-liconv‘

[root@server85
php-5.4.12]# make install

[root@server85
kernel]# cd php-5.4.12/sapi/fpm/

[root@server85
fpm]# cp init.d.php-fpm /etc/init.d/php-fpm

[root@server85
~]# chmod +x /etc/init.d/php-fpm

[root@server85
~]# cd /usr/local/lnmp/php/etc/

[root@server85
etc]# cp php-fpm.conf.default php-fpm.conf

[root@server85
etc]# vim php-fpm.conf

pid
= run/php-fpm.pid

[root@server85
etc]# /etc/init.d/php-fpm start

[root@server85
etc]# ps ax

29876
? Ss 0:00 php-fpm: master process
(/usr/local/lnmp/php/etc/php-

29877
? S 0:00 php-fpm: pool www

29878
? S 0:00 php-fpm: pool www

[root@server85 etc]# vim /usr/local/lnmp/nginx/conf/nginx.conf

location
~ \.php$ {

root
html;

fastcgi_pass
127.0.0.1:9000;

fastcgi_index index.php;

#
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi.conf;

}

[root@server85
etc]# cd /usr/local/lnmp/nginx/html/

[root@server85
html]# vim index.php

<?php

phpinfo()

?>

[root@server85
html]# cd /root/kernel/php-5.4.12

[root@server85
php-5.4.12]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini

[root@server85
php-5.4.12]# vim /usr/local/lnmp/php/etc/php.ini

date.timezone
= Asia/Shanghai

[root@server85
php-5.4.12]# /etc/init.d/php-fpm restart

[root@server85
php-5.4.12]# nginx -s reload

访问server85.example.com/index.php可以看到以下页面说明配置成功:

至此php安装完毕!!!

4.发布Discuz论坛

[root@server85 kernel]# yum install unzip

[root@server85 kernel]# unzip Discuz_X2.5_SC_UTF8.zip -d /usr/local/lnmp/nginx/html/

[root@server85 kernel]# cd /usr/local/lnmp/nginx/html/

[root@server85 html]# rm -rf readme/ utility/

[root@server85 html]# mv upload/ bbs

[root@server85 html]# vim /usr/local/lnmp/nginx/conf/nginx.conf

location / {

root html;

index index.php index.html index.htm;

}

[root@server85 html]# nginx -s reload

访问server85.example.com/bbs出现以下画面,按“我同意”:

此时文件权限不满足要求:

解决方法如下:

[root@server85 bbs]# chown nginx -R /usr/local/lnmp/nginx/html/bbs/

至此Discuz论坛发布成功!!!

时间: 2024-10-13 07:32:40

Rhel6-lanmp架构配置文档的相关文章

OpenCV+VS2013+Win8+64位配置文档

配置环境 编程平台:VS2013 系统:Windows8 64位 X64架构 ? 安装OpenCV 1 下载OpenCV-2.4.9,下载网址 http://opencv.org/ 2 解压OpenCV到 D:\Program Files\OpenCV\opencv249 3 配置系统变量 添加OpenCV变量: D:\Program Files\OpenCV\opencv249\build 在Path后添加: D:\Program Files\OpenCV\opencv249\build\x6

终于有人把tomcat讲清楚了!阿里大牛推荐的tomcat架构解析文档

在目前流行的互联网架构中,对一个应用来说,Tomcat是首,SSM是中,JVM是尾,我们通常对于SSM是比较了解的,而忽略了首尾,而Tomcat在目前的网络编程中是举足轻重的,但是我们其实对Tomcat中很多原理性的东西不太了解,如果能够掌握Tomcat的原理,那么是非常有用的,比如: 如果我们能弄清楚Tomcat和Socket.Tcp之间的关系,我们就能明白Tomcat为什么会出现端口冲突.如果我们能准确的知道Tomcat中部署一个项目的N种方式,那么就能在工作中更加得心应手.Tomcat中热

Hadoop配置文档

预节 在这一节中,笔者主要向大家介绍了该配置文档中,所用到的Linux命令和Linux的帮助. 终端提示信息 在Linux中,终端的每一行都有提示信息,其包含了当前终端登录的用户,当前登录的主机,当前终端所在的目录. 如:[[email protected] ~]$其格式为:[[用户名]@[hosts主机名或主机ip [当前所在路径]]$解析后可以知道,例子给的提示,实际上代表的是:当前终端登录的主机为master,所有的操作都是针对master的,登录主机的用户为frank,当前终端cd命令进

Nginx配置文档具体解释

Nginx的配置文档具体解释.在这儿做个总结,以便以后使用的时间查看. 下面大部分自己整理.部分来自參考 #设置用户 #user  nobody; #启动进程数(一般和server的CPU同样) #能够使用 $ cat /proc/cpuinfo 查看内核数 worker_processes  2; #设置错误文件存放的路径 #error_log  logs/error.log; #error_log  logs/error.log  notice; #error_log  logs/error

IIS配置文档

IIS配置文档: 1.安装IIS.控制面板→程序→打开关闭Windows功能,Web管理服务和万维网服务都勾上. 2.部署网站:ASP.Net项目的发布:项目中点右键“发布”,选择“文件系统”,发布到一个文件夹下. 3.在IIS中新建网站,设定域名,这样多个域名可以放到一个IIS服务器上.需要绑定域名. 4.模拟域名,如果启用了UAC,则用管理员权限运行记事本,打开 C:\Windows\System32\drivers\etc下的hosts文件 做一下域名协议的欺骗.伪造一些域名出来. 5.如

【VMware虚拟化解决方案】VMware Horizon View Client 各平台配置文档

云桌面用户手册 XXXX部 2014年05月18日 文档版本 文档名称 XXXX公司云桌面用户手册 保密级别 商密 文档版本编号 1.0 制作人 制作日期 2014-04-24 复审人 复审日期 扩散范围 公司内部使用人员 变更记录 版本编号 版本日期 修改者 说明 文档说明 此文档为XXXX公司内部员工关于<云桌面用户手册>培训文档. 此文档只对公司内部员工传阅,并只针对公司内部员工问题给予解决. 目录 1.VMware Horizon View Client下载地址... 4 2.桌面连接

微信开发配置文档

微信开发配置文档 请求SDK接口 1, 绑定域名 公众号设置 菜单 --> 功能设置 绑定域名 : http://www.xxxxx.com2, 记录应用ID : AppID(应用ID)wxd9c94eba232190a1 应用密码: 8ff9f1fd268bdb643fc27354811d973a3, 找到开发者工具 --> 开发者文档 -->微信网页开发 -->JS-SDK说明文档 页面底部 下载 sample.php 示例DEMO 打开sample.php 设置 APPID

maven工程web层的web.xml配置文档内容

下面是web层,web.xml配置文档里面需要配置的东西: 1.lo4j配置 2.读取spring文件配置 3.设计路径变量值 4.spring字符集过滤器 5.登陆过滤器 6.springMVC核心配置 7.session过期时间 8.错误页面跳转 以下是实例: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSch

maven工程web层的spring配置文档

1.引入jdbc配置文档 2.扫描文件 3.上传文件的设置 下面是例子: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi