您的位置:晶晶的博客>Linux>微软云虚拟机:centos6.3下nginx1.5.5、PHP5.5.4、mysql5.6.14环境安装笔记

微软云虚拟机:centos6.3下nginx1.5.5、PHP5.5.4、mysql5.6.14环境安装笔记

把刚申请到的azure中国区试用虚拟机给重置了,然后源码编译nginx、php、mysql所有最新版玩玩,以下是编译安装笔记。

安装基本约定以及基本软件包下载:

mkdir /server
mkdir /server/src
mkdir /server/apps
mkdir /serverlibs
mkdir /server/data
mkdir /server/data/mysql
mkdir /server/data/mysql/data

cd /server/src

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz
wget http://nginx.org/download/nginx-1.5.5.tar.gz
wget http://cn2.php.net/distributions/php-5.5.4.tar.gz

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz
wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.2.tar.gz
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.12.tar.gz

wget "https://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?big_mirror=0"
wget "https://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?big_mirror=0"
wget "https://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?big_mirror=0"
wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz

一、Azure的yum配置修改,默认不允许安装kernel内核相关的内容

vi /etc/yum.conf

# exclude=kernel* #exclude=kernel*

二、yum更新必须的lib工具库

yum -y install openssl* gd gd2 gd-devel gd2-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make

三、安装nginx

cd /server/src
tar zxvf pcre-8.32.tar.gz
cd pcre-8.32
./configure --prefix=/server/libs
make && make install
cd ..

/usr/sbin/groupadd nginx
/usr/sbin/useradd -g nginx nginx
ulimit -SHn 65535

tar zxvf nginx-1.5.5.tar.gz
cd nginx-1.5.5
./configure --user=nginx --group=nginx --prefix=/server/apps/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/server/src/pcre-8.32 --with-http_realip_module --with-http_image_filter_module
make && make install

四、安装mysql

cd ..

#本mysql

tar zxvf mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.14-linux-glibc2.5-x86_64 /server/apps/mysql

/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql

#yum install libaio #azure该lib

#

cp ./support-files/my-default.cnf /etc/my.cnf

vi /etc/my.cnf

#将basedir datasir
basedir = /server/apps/mysql
datadir = /server/data/mysql/data

#mysql 使 service mysql start|restart|stop理mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
vi /etc/rc.d/init.d/mysqld
改basedir、datadir

#化mysql
/server/apps/mysql/scripts/mysql_install_db --basedir=/server/apps/mysql --datadir=/server/data/mysql/data --user=mysql

sed -i "s#/usr/local/mysql#/server/apps/mysql#g" /server/apps/mysql/bin/mysqld_safe


#改mysql化root 际mysql的root

/server/apps/mysql/bin/mysqladmin -u root -p password # root

#mysql mysql -u root -p入mysql
vi /etc/profile
#
export PATH=$PATH:/server/apps/mysql/bin

#使
source /etc/profile

五、安装PHP依赖库

#装php
tar zxvf jpegsrc.v9.tar.gz
cd jpeg-9/
./configure --prefix=/server/libs --enable-shared --enable-static --prefix=/server/libs
make && make install
cd ../

tar zxvf libpng-1.6.2.tar.gz
cd libpng-1.6.2/
./configure --prefix=/server/libs
make && make install
cd ../

tar zxvf freetype-2.4.12.tar.gz
cd freetype-2.4.12/
./configure --prefix=/server/libs
make && make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure --prefix=/server/libs
make
make install
cd libltdl/
./configure --prefix=/server/libs --enable-ltdl-install
make
make install
cd ../../

tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure --prefix=/server/libs
make
make install
cd ../

#辑lib
vi /etc/ld.so.conf
#
/server/libs/lib
#使
ldconfig

tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
export LDFLAGS="-L/server/libs/lib -L/usr/lib"
export CFLAGS="-I/server/libs/include -I/usr/include"
touch malloc.h
./configure --prefix=/server/libs --with-libmcrypt-prefix=/server/libs
make
make install
cd ../

六、安装PHP

tar zxvf php-5.5.4.tar.gz
cd php-5.5.4

export LIBS="-lm -ltermcap -lresolv"
export DYLD_LIBRARY_PATH="/server/apps/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
export LD_LIBRARY_PATH="/server/apps/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"

./configure --prefix=/server/apps/php --with-config-file-path=/server/apps/php/etc --with-config-file-scan-dir=/server/apps/php/etc/ini --with-mysql=/server/apps/mysql --with-mysqli=/server/apps/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir=/server/libs --with-jpeg-dir=/server/libs --with-png-dir=/server/libs --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=/server/libs --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql

make

make test

make install

#译php 要6(4心cpu、7G 台1G心cpu了15

#加php
mkdir /server/apps/php/etc/ini
4核cpu、7G内存 make编译php时top状态

七、PHP、PHP-FPM、nginx支持php配置

#贝php
cp php.ini-production /server/apps/php/etc/php.ini
#制php-fpm如service php-fpm start|restart|stop
# 使
cp ./sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm

#
chmod +x /etc/rc.d/init.d/php-fpm #
chkconfig php-fpm on #置php过nginx的php-fpm

#ps充mysql
chmod +x /etc/rc.d/init.d/mysqld #mysql加mysql
chkconfig mysqld on #置mysql

#php-fpm
cd /server/apps/php/etc
cp php-fpm.conf.default php-fpm.conf

vi php-fpm.conf
#(php-fpm与nginx
user = nginx
group = nginx

#nginx持php-fpm
cd /server/apps/nginx/conf
vi nginx.conf
#
user nginx nginx;
pid /server/data/nginx.pid
#index 的位置添加 index.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;

}

八、nginx启动文件、启动nginx、mysql、php-fpm

笔者是个service xx start|stop|restart狂,所以在nginx没有启动文件的情况下,自己书写一个。

#nginx
vi /etc/init.d/nginx
#[]

chmod 755 /etc/init.d/nginx
#者chmod +x /etc/rc.d/init.d/nginx
#Server nginx - this script starts and stops the nginx daemon
# By www.jjonline.cn
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /server/apps/nginx/conf/nginx.conf
# pidfile: /server/data/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/server/apps/nginx/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/server/apps/nginx/conf/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}

start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
#configtest || return $?
stop
sleep 1
start
}

reload() {
#configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}

force_reload() {
restart
}

configtest() {
$nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}

case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
test)
configtest || exit 0
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac

或者您可以点击下载这个nginx启动管理脚本:【下载

nginx启动管理脚本的效果示意图

启动nginx、mysql、php-fpm,太简单了:

service mysqld start
service nginx start
service php-fpm start

九、部分问题解决

启动php-fpm时提示“Starting php-fpm /server/apps/php/sbin/php-fpm: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory  failed”

做个文件连接即可:

ln -s /server/apps/mysql/lib/mysql /usr/lib64/mysql 
ln -s /server/apps/mysql/include/mysql /usr/include/mysql
ln -s /server/apps/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18 #意64和32

本次配置安装好后的,在线地址:https://42.159.4.81/ (因为是试用,预计10月25号以后该地址即将失效)

安装完毕的phpinfo信息
转载请注明本文标题和链接:《微软云虚拟机:centos6.3下nginx1.5.5、PHP5.5.4、mysql5.6.14环境安装笔记

相关推荐

哟嚯,本文评论功能关闭啦~