一、Nginx安装(1.10.1)
mkdir -p /server/tools
mkdir -p /application/
yum install -y openssl openssl-devel pcre-devel tar wget gcc-c++ make
echo "install nginx..."
useradd -M -s /sbin/nologin nginx
cd /server/tools/
wget http://nginx.org/download/nginx-1.10.1.tar.gz
tar xf nginx-1.10.1.tar.gz
cd nginx-1.10.1
./configure --prefix=/application/nginx-1.10.1 --with-openssl=/application/openssl/ --with-pcre --with-http_stub_status_module --sbin-path=/application/nginx-1.10.1/sbin/nginx --conf-path=/application/nginx-1.10.1/conf/nginx.conf --error-log-path=/application/nginx-1.10.1/logs/error.log --http-log-path=/application/nginx-1.10.1/logs/access.log --pid-path=/application/var/run/nginx.pid --lock-path=/application/var/lock/nginx.lock --user=nginx --group=nginx
make && make install
ln -s /application/nginx-1.10.1/ /application/nginx
/application/nginx/sbin/nginx
ps -ef|grep nginx
nginx安装后关闭(防火墙),访问主机ip即可

二、安装Mysql(5.6.36)
yum install -y ncurses-devel libaio-devel ncurses-devel libaio-devel cmake gcc-c++ bison
useradd -s /sbin/nologin -M mysql
mkdir -p /server/tools
cd /server/tools
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.36.tar.gz
tar xf mysql-5.6.36.tar.gz
cd mysql-5.6.36
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.36 \
-DMYSQL_DATADIR=/application/mysql-5.6.36/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.36/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0
make && make install
ln -s /application/mysql-5.6.36/ /application/mysql
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql
mkdir -p /application/mysql/tmp
chmod 755 /application/mysql/tmp
chown -R mysql.mysql /application/mysql/*
yes|cp -r support-files/my*.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chkconfig mysqld on
chkconfig --list mysqld
/etc/init.d/mysqld start
chmod 755 /application/mysql-5.6.36/data/localhost.localdomain.err
/etc/init.d/mysqld restart
echo 'PATH=/application/mysql/bin/:$PATH' >>/etc/profile
source /etc/profile\
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
mysqladmin -u root password '123456'
mysql -uroot -p123456 -e"
use mysql;
GRANT USAGE ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;"
安装完以后手动source /etc/profile,然后mysql -uroot -p123456登录
三、安装php(5.6.31)
mkdir -p /server/tools
useradd -M -s /sbin/nologin www
yum -y install gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel
cd /server/tools
wget "http://cn2.php.net/get/php-5.6.31.tar.gz/from/this/mirror" -O php-5.6.31.tar.gz
tar xf php-5.6.31.tar.gz
cd php-5.6.31/
./configure --prefix=/application/php-5.6.31 --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --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 --with-gettext --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-opcache=no --enable-ftp
make && make install
cp /server/tools/php-5.6.31/php.ini-production /application/php-5.6.31/lib/php.ini
cp /application/php-5.6.31/etc/php-fpm.conf.default /application/php-5.6.31/etc/php-fpm.conf
ln -s /application/php-5.6.31 /application/php
/application/php/sbin/php-fpm
四、nginx和php建立连接
cd /application/nginx/html/
mkdir -p blog
chown -R www:www blog
#nginx配置文件
cat >/application/nginx/conf/nginx.conf<<EOF
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
# listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80 default;
return 500;
}
include server/*.conf;
}
EOF
nginx和php建立连接
cd /application/nginx/conf/
mkdir -p server
cat >/application/nginx/conf/server/blog.conf<<EOF
server {
listen 80;
server_name 192.168.1.200;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~* .*\.(php|php5)?$ {
root /application/nginx/html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
EOF
/application/nginx/sbin/nginx -s reload
echo '<?php phpinfo(); ?>' >/application/nginx/html/blog/test_info.php
访问ip/test_info.php测试页面(php测试页面)

来源:oschina
链接:https://my.oschina.net/u/4405743/blog/3843234
