系统
yum -y install gcc gcc-c++ #给系统加装c++编译器
yum -y install libxml2
yum -y install libxml2-devel
wget http://nginx.org/download/nginx-1.2.6.tar.gz #获取nginx 1.2.6版本源码
wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-7/v7.0.35/bin/apache-tomcat-7.0.35.tar.gz #获取tomcat新版本
groupadd www #添加组www
useradd -s /sbin/nologin -M nginx -g www #添加用户 nginx,并且指定其所属的组是www
配置固定IP及DNS信息
vi /etc/sysconfig/network
NETWORKING=yes
GATEWAY=192.168.1.1
HOSTNAME=localhost.localdomain
vi /etc/resolv.conf
nameserver 192.168.1.1
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
IPADDR="192.168.1.202"
NETMASK="255.255.255.0"
DNS1="192.168.1.1"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
修改防火墙设置
vi /etc/sysconfig/iptables
#-A INPUT -m state --state NEW -m tcp -p tcp --dport 9000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
service iptables stop
service iptables start
chkconfig iptables on
service iptables status
JDK
chmod +x jdk-6u39-linux-x64.bin #给bin文件增加可执行属性
vi /etc/profile
在里面添加如下内容:
export JAVA_HOME=/usr/local/jdk
export JAVA_BIN=/usr/local/jdk/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
在里面添加如下内容:
export JAVA_HOME=/usr/local/jdk
export JAVA_BIN=/usr/local/jdk/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile 使刚才填加的生效
PHP
yum -install rabbitmq-c #给php添加消息队列协议的lib
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --with-zlib --enable-xml #编译php
cp php.ini-production /etc/php.ini
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
#下面两句添加随启动自动运行php-fastcgi模式
vi /etc/rc.d/rc.local
/usr/local/php/sbin/php-fpm &
resin
RESIN : 4.0.34
home : /usr/local/share/resin-4.0.34
root : /var/resin
conf : /etc/resin
log : /var/log/resin
plugins : common resin_os resin resinssl
init : /etc/init.d/resin
zeromq
RabbitMQ Server
http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.2/rabbitmq-server-3.0.2.tar.gz
http://www.rabbitmq.com/releases/rabbitmq-java-client/v3.0.2/rabbitmq-java-client-3.0.2.tar.gz
http://pecl.php.net/get/amqp-1.0.9.tgz
Nginx
yum -y install openssl-devel
./configure --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module
ldd $(which /usr/local/nginx/sbin/nginx) #检查nginx运行时所需的所有支持文件
ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
#整合fastcgi模式的PHP
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#或者负载均衡PHP :
location ~ \.php$ {
root html;
proxy_pass http://bakend_php_ipHash;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
upstream bakend_php_ipHash {
ip_hash;
server 192.168.1.203;
server 192.168.1.204;
}
#整合tomcat或其他监听8080端口的jsp解析容器,
#并采用IP_HASH模式的负载均衡
location ~ \.jsp$ {
root html;
proxy_pass http://bakend_ipHash;
}
upstream bakend_ipHash {
ip_hash;
server 192.168.1.203:8080;
server 192.168.1.204:8080;
}
最后启动nginx
vi /etc/rc.d/rc.local
/usr/local/nginx/sbin/nginx
注:重要的不是上面这些命令怎么记清楚、甚至倒背如流,而是要事先想好你架linux用来干什么,今后怎么扩展等问题。