CentOS6.6x86_64 部署 Nginx1.62+MySQL5.6.20+PHP5.6.4
准备工作
切换到管理员身份
su -
安装编译扩展
yum install -y gcc-c++
创建数据库目录、代码目录
mkdir /mnt/data /mnt/www
安装Nginx 1.6.2
进入应用下载目录
cd /usr/local/src
下载Nginx软件包及依赖包
yum install -y openssl-devel pcre-devel zlib-devel
wget http://nginx.org/download/nginx-1.6.2.tar.gz
添加用户及用户组
useradd www
编译安装Nginx
./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_flv_module --user=www --group=www --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ make -j5 install
创建启动脚本
vi /etc/init.d/nginx
#!/bin/sh
#
# nginx Startup script for nginx
#
# chkconfig: - 85 15
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# description: nginx is an HTTP and reverse proxy server
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop nginx
### END INIT INFO # Source function library.
. /etc/rc.d/init.d/functions if [ -L $0 ]; then
initscript=`/bin/readlink -f $0`
else
initscript=$0
fi sysconfig=`/bin/basename $initscript` if [ -f /etc/sysconfig/$sysconfig ]; then
. /etc/sysconfig/$sysconfig
fi nginx=${NGINX-/usr/sbin/nginx}
prog=`/bin/basename $nginx`
conffile=${CONFFILE-/etc/nginx/nginx.conf}
lockfile=${LOCKFILE-/var/lock/subsys/nginx}
pidfile=${PIDFILE-/var/run/nginx.pid}
SLEEPMSEC=${SLEEPMSEC-200000}
UPGRADEWAITLOOPS=${UPGRADEWAITLOOPS-5}
RETVAL=0 start() {
echo -n $"Starting $prog: " daemon --pidfile=${pidfile} ${nginx} -c ${conffile}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
} stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} ${prog}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
} reload() {
echo -n $"Reloading $prog: "
killproc -p ${pidfile} ${prog} -HUP
RETVAL=$?
echo
} upgrade() {
oldbinpidfile=${pidfile}.oldbin configtest -q || return
echo -n $"Starting new master $prog: "
killproc -p ${pidfile} ${prog} -USR2
echo for i in `/usr/bin/seq $UPGRADEWAITLOOPS`; do
/bin/usleep $SLEEPMSEC
if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then
echo -n $"Graceful shutdown of old $prog: "
killproc -p ${oldbinpidfile} ${prog} -QUIT
RETVAL=$?
echo
return
fi
done echo $"Upgrade failed!"
RETVAL=1
} configtest() {
if [ "$#" -ne 0 ] ; then
case "$1" in
-q)
FLAG=$1
;;
*)
;;
esac
shift
fi
${nginx} -t -c ${conffile} $FLAG
RETVAL=$?
return $RETVAL
} rh_status() {
status -p ${pidfile} ${nginx}
} # See how we were called.
case "$1" in
start)
rh_status >/dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
status)
rh_status
RETVAL=$?
;;
restart)
configtest -q || exit $RETVAL
stop
start
;;
upgrade)
rh_status >/dev/null 2>&1 || exit 0
upgrade
;;
condrestart|try-restart)
if rh_status >/dev/null 2>&1; then
stop
start
fi
;;
force-reload|reload)
reload
;;
configtest)
configtest
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}"
RETVAL=2
esac exit $RETVAL
chmod +x /etc/init.d/nginx
编辑配置
vi /etc/nginx/nginx.conf
修改访问用户
# line:2
user www;
修改网站目录并开启PHP支持
# line:43-46
location / {
root /mnt/www;
index index.html index.htm index.php;
}
# line:65-71
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /mnt/www$fastcgi_script_name;
include fastcgi_params;
}
启动Nginx
service nginx start
安装MySQL 5.6.20
准备工作
查找、删除系统中的MySQL
rpm -qa | grep mysql
# > mysql-libs-5.1.73-3.el6_5.x86_64
rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps
安装编译工具
yum install -y cmake
下载MySQL源码包
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.21.tar.gz
编译安装MySQL
tar zxf mysql-5.6.21.tar.gz
cd mysql-5.6.21 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mnt/data/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci make -j5 install
创建MySQL用户
groupadd -g 27 -r mysql
useradd -r -u 27 -g mysql -s /sbin/nologin -d /root -c "MySQL" mysql
修改目录权限
chown -R mysql.mysql /usr/local/mysql
初始化安装数据库
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/mnt/data/mysql --user=mysql
查看MySQL启动顺序、放置MySQL配置文件
mysql --verbose --help | grep -A 1 'Default options'
mv /usr/local/mysql/my.cnf /etc
启动MySQL(报错注意关闭seLinux)
ln -s /usr/local/mysql/bin/mysql /bin/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
service mysql start
修改密码
推荐方式:
/usr/local/mysql/bin/mysql_secure_installation
备用方式:
mysql -u root -ph8znVjtSES17d_pg SET PASSWORD=password('admin888');
GRANT all privileges on *.* TO 'root'@'%' identified by 'admin888' WITH GRANT OPTION;
FLUSH PRIVILEGES;
\q
重新编译时,需要清除旧的对象文件和缓存信息。
# make clean
# rm -f CMakeCache.txt
# rm -rf /etc/my.cnf
安装PHP 5.6.4
安装编译使用的扩展
yum install -y gcc gcc-c++
安装依赖库
安装libmcrypt
下载页面:http://sourceforge.net/projects/mcrypt/files/Libmcrypt/
cd /usr/local/src
tar zxf /usr/local/src/libmcrypt-2.5.8.tar.gz
cd /usr/local/src/libmcrypt-2.5.8/
./configure; make -j5 install
安装mhash
cd /usr/loacl/src
tar zxvf /usr/local/src/mhash-0.9.9.9.tar.gz
cd /usr/local/src/mhash-0.9.9.9/
./configure; make -j5 install
配置运行库
vi /etc/ld.so.conf line:2 加入
/usr/local/lib ldconfig
如果报错执行:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
安装mcrypt
tar zxf /usr/local/src/mcrypt-2.6.8.tar.gz
cd /usr/local/src/mcrypt-2.6.8
./configure; make -j5 install
安装PHP扩展
yum install -y libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel gd gd-devel glib2 glib2-devel ncurses ncurses-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel libcurl libcurl-devel
安装PHP
下载并解压
tar jxf /usr/local/src/php-5.6.4.tar.bz2
cd /usr/local/src/php-5.6.4
编译
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql --with-mysqli --with-pdo-mysql --with-curl --with-mcrypt --with-mhash --with-gd --with-openssl --with-xmlrpc --with-zlib --with-libxml-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --enable-inline-optimization --enable-bcmath --enable-mbstring --enable-mbregex --enable-sockets --enable-zip --enable-debug --enable-maintainer-zts --enable-sysvsem --enable-shmop --enable-xml --enable-sysvsem --enable-sysvshm --enable-gd-native-ttf --enable-pcntl --enable-soap --enable-opcache --disable-rpath
安装,注意&&
make -j5 && make install
移动配置文件
cp /usr/local/src/php-5.6.4/php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
添加php-fpm到service
开启php-fpm.pid
vi /usr/local/php/etc/php-fpm.conf line:25 开启pid,改为
pid = /var/run/php-fpm.pid
新建服务脚本
vi /etc/init.d/php-fpm
----------------------- #!/bin/bash
#
# Startup script for the PHP-FPM server.
#
# chkconfig: 345 85 15
# description: PHP is an HTML-embedded scripting language
# processname: php-fpm
# config: /usr/local/php/etc/php.ini # Source function library.
. /etc/rc.d/init.d/functions PHP_PATH=/usr/local/php
DESC="php-fpm daemon"
NAME=php-fpm
# php-fpm路径
DAEMON=$PHP_PATH/sbin/$NAME
# 配置文件路径
CONFIGFILE=$PHP_PATH/etc/php-fpm.conf
# PID文件路径(在php-fpm.conf设置)
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0 rh_start() {
$DAEMON -y $CONFIGFILE || echo -n " already running"
} rh_stop() {
kill -QUIT `cat $PIDFILE` || echo -n " not running"
} rh_reload() {
kill -USR2 `cat $PIDFILE` || echo -n " can't reload"
} case "$1" in
start)
echo -n "Starting $DESC: $NAME"
rh_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
rh_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
rh_reload
echo "reloaded."
;;
restart)
echo -n "Restarting $DESC: $NAME"
rh_stop
sleep 1
rh_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
exit 3
;;
esac
exit 0
添加执行权限
chmod +x /etc/init.d/php-fpm
启动php-fmp
service php-fpm start
添加自启动
chkconfig --add php-fpm
chkconfig php-fpm on
chkconfig nginx on
chkconfig mysql on
CentOS6.6x86_64 部署 Nginx1.62+MySQL5.6.20+PHP5.6.4的更多相关文章
- CentOS6.9部署Redis3.2.9+FastDFS_4.06+Nginx1.5.0
CentOS6.9部署Redis3.2.9+FastDFS_4.06+Nginx1.5.0 原文链接:https://www.toutiao.com/i6481931577499582990/ 一.上 ...
- centos6.8 Mysql-5.7.20 升级 mysql-8.0.14-1
Mysql-5.7.20 升级 mysql-8.0.14-1 操作前建议先查阅以下网页初步了解Mysql版本升级信息 https://blog.csdn.net/u012946310/artic ...
- centos6.8 Mysql5.6.22 升级 mysql-5.7.20
一.检查系统环境 二.备份数据库 mysqldump –all-databases > allbackupfile.sql (建议:有条件的话可使用图形化界面备份,操作灵活) 三.下载安装文件 ...
- CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13
CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.132013-10-24 15:31:12标签:服务器 防火墙 file 配置文件 written 一.配置好I ...
- Centos6.6部署Redis集群
Centos6.6部署Redis集群 1环境准备 1环境安装redis 1安装ruby 2配置redis主从环境 3部署redis sentinel服务器 5集群使用 13当前集群环境说明 13测试功 ...
- MySQL5.7.20报错Access denied for user 'root'@'localhost' (using password: NO)
在centos6.8上源码安装了MySQL5.7.20,进入mysql的时候报错如下: 解决办法如下: 在mysql的配置文件内加入: vim /etc/my.cnf skip-grant-tabl ...
- CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境
准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...
- [svc]centos6上部署openvpn+gg二步认证
最近又发现个新的vpn: wireguard 为了满足员工在家办公的需求.需要 openvpn+gg方案 在centos6上部署openvpn 参考 1.安装前准备 wget -O /etc/yum. ...
- CentOS7.2编译配置LNMP环境(MySQL5.7.20,PHP7.0.24)
一, 查看系统版本及内核版本 二, 编译安装nginx 1, 新建nginx用户 useradd -s /sbin/nologin -M nginx 2, ...
随机推荐
- ASP.NET 安全认证
一. 新建一个测试项目 新建一个测试项目,包含三张页面(Default.aspx.Login.aspx.UserInfo.aspx). 二. 修改 Web.config 1.把<authen ...
- frameset iframe用来分页
frameset用来分大的框架 iframe用来在frame分框架之后,内嵌分割. <FRAMESET border=1 frameSpacing=1 borderColor=#47478d r ...
- Android NetWorkUtil
package com.android.hcframe.netdisc.util; import java.io.BufferedReader; import java.io.InputStreamR ...
- 动态规划——I 记忆化搜索
Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michael想知道 ...
- 动态规划——C编辑最短距离
C - 编辑距离 时间限制: 1000女士 内存限制: 65536KB 64位输入输出格式: %I64d & %I64u 提交 状态 描述 Let x and y be two strings ...
- [Sequence Alignment Methods] Cross-Recurrent Plot (CRP)
A recurrence plot (RP) is a straightforward way to visualize characteristics of similar system state ...
- [转]stringstream的用法
使用stringstream对象简化类型转换C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性.类型安全和可扩展性.在本文中, ...
- PHP 生命周期,Opcode 缓存。
1.php 执行的生命周期. 用户发出请求---->.php--->词典扫描--->解析--->创建Opcode--->处理opcode--->响应 这就是php的 ...
- java中字节流和字符流的区别
流分类: 1.Java的字节流 InputStream是所有字节输入流的祖先,而OutputStream是所有字节输出流的祖先.2.Java的字符流 Reader是所有读取字符串输入流的祖先,而 ...
- Mongodb query查询
Query.All("name", "a", "b");//通过多个元素来匹配数组Query.And(Query.EQ("name ...