安装Nginx

1、安装Nginx所需的pcre库

#yum -y install pcre pcre-devel

2、安装所需依赖包

#yum -y install openssl openssl-devel

3、创建用户

#useradd -s /sbin/nologin -Mnginx
#useradd -s /sbin/nologin -M www

4、开始安装Nginx

#wget -q 
http://nginx.org/download/nginx-1.6.3.tar.gz

#tar xf nginx-1.6.3.tar.gz
#cd nginx-1.6.3
./configure \
--user=nginx \
--group=nginx \
--prefix=/application/nginx-1.6.3/ \
--with-http_stub_status_module \
--with-http_ssl_module
#make && make install
#ln -s /application/nginx-1.6.3/ /application/nginx
#/application/nginx/sbin/nginx
#echo"/application/nginx/sbin/nginx" >>/etc/rc.local
#cd /application/nginx/conf/

egrep -v "#|^$"nginx.conf.default >nginx.conf

配置访问日志

# sed -n '21,23s/#//gp' nginx.conf.default
   log_format  main  '$remote_addr - $remote_user [$time_local]"$request" '
                      '$status $body_bytes_sent"$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for"';

将上述内容放置到nginx.confhttp标签内部

#vim nginx.conf
worker_processes  1;
events {
   worker_connections  1024;
}
http {
   include       mime.types;
   default_type application/octet-stream;
    log_format  main '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent"$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for"';
   sendfile        on;
   keepalive_timeout  65;
include extra/blog.conf;
include extra/bbs.conf;
}

 

#vim extra/blog.conf
#blog virtualhost by xiaoxin
       server {
       listen       80;
       server_name  blog.sdjx.org sdjx.org;
       location / {
           root   html/blog;
           index  index.php index.html index.htm;
        }
       location ~ .*\.(php|php5)?$ {
           root   html/blog;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           include fastcgi.conf;
        }
       access_log logs/access_blog.log main;
        }

 

vim bbs.conf
#bbs virtualhost by xiaoxin
       server {
       listen       80;
       server_name  bbs.sdjx.org;
       location / {
           root   html/bbs;
           index  index.php index.htmlindex.htm;
        }
        location~ .*\.(php|php5)?$ {
           root   html/bbs;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           include fastcgi.conf;
}
        access_log logs/access_bbs.log main;
        }

 

mkdir blog bbs
echo"http://blog.sdjx.org" >>blog/index.html
echo"http://bbs.sdjx.org" >>bbs/index.html
/application/nginx/sbin/nginx –t
/application/nginx/sbin/nginx -s reload

配置PHP

安装所需依赖包

yum install zlib-devellibxml2-devel libjpeg-devel libjpeg-turbo-devel freetype-devel \
libpng-develgd-devel libcurl-devel libxslt-devel -y
wget 
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
wget -O /etc/yum.repos.d/epel.repo 
http://mirrors.aliyun.com/repo/epel-6.repo
yum install libmcrypt-devel mhash mcrypt -y

下载地址:

http://cn.php.net/
http://cn2.php.net/
tar xf php-5.5.32.tar.gz
cd php-5.5.32
./configure \
--prefix=/application/php5.5.32 \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--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-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--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-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp \
--enable-opcache=no
touch ext/phar/phar.phar
make && make install
ln -s /application/php5.5.32//application/php
cd /home/data/tools/php-5.5.32
cp php.ini-production/application/php/lib/php.ini
cd /application/php/etc/
cp php-fpm.conf.defaultphp-fpm.conf
/application/php/sbin/php-fpm
echo"/application/php/sbin/php-fpm" >>/etc/rc.local
cd /application/nginx/html/blog/
echo"<?php phpinfo(); ?>" >test_info.php

windows下域名解析

C:\Windows\System32\drivers\etc\hosts

打开浏览器输入:

http://blog.sdjx.org/test_info.php


mysql数据库搭建:

参考:

http://zhanghongxin.blog.51cto.com/11255031/1847048


http://zhanghongxin.blog.51cto.com/11255031/1847059

数据库端执行命令:

ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/