CentOS-6.6、NGINX-1.14.0、MySQL-5.5.32、PHP-5.5.38(NGINX、PHP一台主机,MySQ单独一台主机)


                            NGINX

1、创建用户

useradd nginx -s /sbin/nologin -M


2、安装依赖

yum -y install openssl openssl-devel pcre pcre-devel


3、编译安装

tar -xvf nginx-1.14.0.tar.gz

cd nginx-1.14.0

./configure --user=nginx --group=nginx --prefix=/application/nginx-1.14.0/ --with-http_stub_status_module --with-http_ssl_module --with-pcre

make

make install


ln -s /application/nginx-1.14.0/ /application/nginx


4、nginx配置文件管理

cd /application/nginx/conf/

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

mkdir extra

mkdir -p ../html/{www,blog}

touch extra/status.conf


<1>nginx.conf配置文件内容

worker_processes  1;

error_log  logs/error.log;

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/www.conf;

include extra/blog.conf;

include extra/status.conf;

}


<2>extra/www.conf配置文件内容

    server {

        listen       80;

        server_name  www.zoe.org;

        root  html/www;

        location / {

            index  index.html index.htm index.php;

        }

        

        location ~ .*\.(php|php5)?$ { 

                          root  html/www;

      fastcgi_pass 127.0.0.1:9000;

            fastcgi_index index.php;

            include fastcgi.conf;

        }

        access_log logs/access_www.log;

    }


<3>extra/blog.conf配置文件内容

    server {

        listen       80;

        server_name  blog.zoe.org;

        root  html/blog;

        location / {

            index  index.html index.htm index.php;

        }

        

        location ~ .*\.(php|php5)?$ { 

                          root  html/www;

      fastcgi_pass 127.0.0.1:9000;

            fastcgi_index index.php;

            include fastcgi.conf;

        }

        access_log logs/access_blog.log;

    }

<4>extra/status.conf配置文件内容

    server{

        listen  80;

        server_name  status.zoe.org;

        location / {

          stub_status  on;

          access_log   off;

        }

  }

5、启动NGINX

<1>检查配置文件

/application/nginx/sbin/nginx -t            


<2>启动

/application/nginx/sbin/nginx



                            PHP

1、安装依赖

yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libiconv-devel libmcrypt-devel mhash mcrypt bzip2-devel


2、编译安装libiconv

cd /home/tools/

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

tar -xvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure --prefix=/usr/local/libiconv

make

make install

cd ..


3、编译安装PHP

tar -xvf php-5.5.38.tar.gz 

cd php-5.5.38

./configure --prefix=/application/php-5.5.38 --with-config-file-path=/application/php-5.5.38/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64  --with-fpm-user=nginx --with-fpm-group=nginx --enable-bcmath

touch ext/phar/phar.phar

make

make install


ln -s /application/php-5.5.38/ /application/php


4、配置配置文件

cp php.ini-production /application/php/etc/php.ini

cd /application/php/etc/

cp php-fpm.conf.default php-fpm.conf


5、启动

/application/nginx/sbin/nginx

/application/php/sbin/php-fpm



                            MYSQL

1、安装依赖包

yum -y install ncurses-devel libaio-devel


2、安装cmake

tar -xvf cmake-2.8.8.tar.gz

cd cmake-2.8.8

./configure

gmake

gmake install

cd ..


3、安装MYSQL

useradd mysql -s /sbin/nologin -M

tar -xvf mysql-5.5.32.tar.gz

cd mysql-5.5.32

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 -DMYSQL_DATADIR=/application/mysql-5.5.32/data -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0


make

make install


ln -s /application/mysql-5.5.32/ /application/mysql


4、创建初始化目录

mkdir -p /data/3306/data

cd /data/3306/

ps:删除/etc/my.cnf,将my.cnf文件放入此目录下

chmod +x mysql

chown -R mysql.mysql /data

echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile

source /etc/profile

<1>初始化MYSQL数据库文件

cd /application/mysql/scripts/

./mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data/ --user=mysql


5、启动

/application/mysql/bin/mysqld_safe --defaults-file=/data/3306/my.cnf 2>&1 >/dev/null  &