在本文中,我们将给您介绍关于CentOS7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14的详细内容,并且为您解答编译安装nginx启动命令的相关问题,此外,我们还将为您提
在本文中,我们将给您介绍关于CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14的详细内容,并且为您解答编译安装nginx启动命令的相关问题,此外,我们还将为您提供关于Centos 5.5 64位 安装nginx1.4+php5.5+mysql+5.6笔记、CentOS 6 yum安装 Nginx1.6 + MySQL5.5 + PHP5.6、CentOS 6.0(X64)下编译安装LNMP平台( Nginx1.0.10 + PHP5.3.8 +_MySQL、CentOS 6.3 纯编译安装Nginx+MySQL+PHP的知识。
本文目录一览:- CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14(编译安装nginx启动命令)
- Centos 5.5 64位 安装nginx1.4+php5.5+mysql+5.6笔记
- CentOS 6 yum安装 Nginx1.6 + MySQL5.5 + PHP5.6
- CentOS 6.0(X64)下编译安装LNMP平台( Nginx1.0.10 + PHP5.3.8 +_MySQL
- CentOS 6.3 纯编译安装Nginx+MySQL+PHP
CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14(编译安装nginx启动命令)
CentOS 7.0编译安装Nginx1.6.0+MysqL5.6.19+PHP5.5.14
2014年07月08日 ⁄ LNMP ⁄ 评论数 2 ⁄ 被围观 87,910次+
准备篇:
CentOS 7.0系统安装配置图解教程
http://www.osyunwei.com/archives/7829.html
一、配置防火墙,开启80端口、3306端口
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、安装iptables防火墙
yum install iptables-services #安装
vi /etc/sysconfig/iptables #编辑防火墙配置文件
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出
systemctl restart iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
二、关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
三 、系统约定
软件源代码包存放位置:/usr/local/src
源码包编译安装位置:/usr/local/软件名字
四、下载软件包
1、下载Nginx(目前稳定版)
http://Nginx.org/download/Nginx-1.6.0.tar.gz
2、下载MysqL
http://cdn.MysqL.com/archives/mysql-5.6/mysql-5.6.19.tar.gz
3、下载PHP
http://cn2.PHP.net/distributions/PHP-5.5.14.tar.gz
4、下载pcre (支持Nginx伪静态)
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
5、下载openssl(Nginx扩展)
http://www.openssl.org/source/openssl-1.0.1h.tar.gz
6、下载zlib(Nginx扩展)
http://zlib.net/zlib-1.2.8.tar.gz
7、下载cmake(MysqL编译工具)
http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
8、下载libmcrypt(PHP扩展)
http://nchc.dl.sourceforge.net/project/mcrypt/libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
9、下载yasm(PHP扩展)
http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
10、t1lib(PHP扩展)
ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz
11、下载gd库安装包
https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
12、libvpx(gd库需要)
https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
13、tiff(gd库需要)
http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gz
14、libpng(gd库需要)
ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.12.tar.gz
15、freetype(gd库需要)
http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.3.tar.gz
16、jpegsrc(gd库需要)
http://www.ijg.org/files/jpegsrc.v9a.tar.gz
以上软件包使用WinSCP工具上传到/usr/local/src目录
WinSCP下载地址:http://winscp.net/download/winscp554.zip
系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链
五、安装编译工具及库文件(使用yum命令安装)
yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libxml* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl PHP-common PHP-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
安装篇
以下是用putty工具远程登录到服务器,在命令行下面操作的
一、安装MysqL
1、安装cmake
cd /usr/local/src
tar zxvf cmake-2.8.11.2.tar.gz
cd cmake-2.8.11.2
./configure
make
make install
2、安装MysqL
groupadd MysqL #添加MysqL组
useradd -g MysqL MysqL -s /bin/false #创建用户MysqL并加入到MysqL组,不允许MysqL用户直接登录系统
mkdir -p /data/MysqL #创建MysqL数据库存放目录
chown -R MysqL:MysqL /data/MysqL #设置MysqL数据库存放目录权限
mkdir -p /usr/local/MysqL #创建MysqL安装目录
cd /usr/local/src #进入软件包存放目录
tar zxvf mysql-5.6.19.tar.gz #解压
cd mysql-5.6.19 #进入目录
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DMysqL_DATADIR=/data/MysqL -DSYSconfdIR=/etc #配置
make #编译
make install #安装
rm -rf /etc/my.cnf #删除系统默认的配置文件(如果默认没有就不用删除)
cd /usr/local/MysqL #进入MysqL安装目录
./scripts/MysqL_install_db --user=MysqL --basedir=/usr/local/MysqL --datadir=/data/MysqL #生成MysqL系统数据库
ln -s /usr/local/MysqL/my.cnf /etc/my.cnf #添加到/etc目录的软连接
cp ./support-files/MysqL.server /etc/rc.d/init.d/MysqLd #把MysqL加入系统启动
chmod 755 /etc/init.d/MysqLd #增加执行权限
chkconfig MysqLd on #加入开机启动
vi /etc/rc.d/init.d/MysqLd #编辑
basedir=/usr/local/MysqL #MysqL程序安装路径
datadir=/data/MysqL #MysqL数据库存放目录
:wq!#保存退出
service MysqLd start #启动
vi /etc/profile #把MysqL服务加入系统环境变量:在最后添加下面这一行
export PATH=$PATH:/usr/local/MysqL/bin
:wq!#保存退出
source /etc/profile #使配置立刻生效
下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定MysqL的库文件地址。
ln -s /usr/local/MysqL/lib/MysqL /usr/lib/MysqL
ln -s /usr/local/MysqL/include/MysqL /usr/include/MysqL
mkdir /var/lib/MysqL #创建目录
ln -s /tmp/MysqL.sock /var/lib/MysqL/MysqL.sock #添加软链接
MysqL_secure_installation #设置MysqL密码,根据提示按Y 回车输入2次密码
二、安装Nginx
1、安装pcre
cd /usr/local/src
mkdir /usr/local/pcre
tar zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure --prefix=/usr/local/pcre
make
make install
2、安装openssl
cd /usr/local/src
mkdir /usr/local/openssl
tar zxvf openssl-1.0.1h.tar.gz
cd openssl-1.0.1h
./config --prefix=/usr/local/openssl
make
make install
vi /etc/profile
export PATH=$PATH:/usr/local/openssl/bin
:wq!
source /etc/profile
3、安装zlib
cd /usr/local/src
mkdir /usr/local/zlib
tar zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib
make
make install
4、安装Nginx
groupadd www
useradd -g www www -s /bin/false
cd /usr/local/src
tar zxvf Nginx-1.6.0.tar.gz
cd Nginx-1.6.0
./configure --prefix=/usr/local/Nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35
注意:--with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35指向的是源码包解压的路径,而不是安装的路径,否则会报错
make
make install
/usr/local/Nginx/sbin/Nginx #启动Nginx
设置Nginx开机启动
vi /etc/rc.d/init.d/Nginx #编辑启动文件添加下面内容
系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链
############################################################
#!/bin/sh
#
# Nginx - this script starts and stops the Nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server,HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: Nginx
# config: /etc/Nginx/Nginx.conf
# config: /usr/local/Nginx/conf/Nginx.conf
# pidfile: /usr/local/Nginx/logs/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="/usr/local/Nginx/sbin/Nginx"
prog=$(basename $Nginx)
Nginx_CONF_FILE="/usr/local/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
;;
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
############################################################
系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链
:wq! #保存退出
chmod 775 /etc/rc.d/init.d/Nginx #赋予文件执行权限
chkconfig Nginx on #设置开机启动
/etc/rc.d/init.d/Nginx restart #重启
在浏览器中打开服务器IP地址,会看到下面的界面,说明Nginx安装成功。
三、安装PHP
1、安装yasm
cd /usr/local/src
tar zxvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
make install
2、安装libmcrypt
cd /usr/local/src
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
3、安装libvpx
cd /usr/local/src
tar xvf libvpx-v1.3.0.tar.bz2
cd libvpx-v1.3.0
./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
make
make install
4、安装tiff
cd /usr/local/src
tar zxvf tiff-4.0.3.tar.gz
cd tiff-4.0.3
./configure --prefix=/usr/local/tiff --enable-shared
make
make install
5、安装libpng
cd /usr/local/src
tar zxvf libpng-1.6.12.tar.gz
cd libpng-1.6.12
./configure --prefix=/usr/local/libpng --enable-shared
make
make install
6、安装freetype
cd /usr/local/src
tar zxvf freetype-2.5.3.tar.gz
cd freetype-2.5.3
./configure --prefix=/usr/local/freetype --enable-shared
make #编译
make install #安装
7、安装jpeg
cd /usr/local/src
tar zxvf jpegsrc.v9a.tar.gz
cd jpeg-9a
./configure --prefix=/usr/local/jpeg --enable-shared
make #编译
make install #安装
8、安装libgd
cd /usr/local/src
tar zxvf libgd-2.1.0.tar.gz #解压
cd libgd-2.1.0 #进入目录
./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx #配置
make #编译
make install #安装
9、安装t1lib
cd /usr/local/src
tar zxvf t1lib-5.1.2.tar.gz
cd t1lib-5.1.2
./configure --prefix=/usr/local/t1lib --enable-shared
make without_doc
make install
10、安装PHP
注意:如果系统是64位,请执行以下两条命令,否则安装PHP会出错(32位系统不需要执行)
\cp -frp /usr/lib64/libltdl.so*/usr/lib/
\cp -frp /usr/lib64/libXpm.so* /usr/lib/
cd /usr/local/src
tar -zvxf PHP-5.5.14.tar.gz
cd PHP-5.5.14
export LD_LIBRARY_PATH=/usr/local/libgd/lib
./configure --prefix=/usr/local/PHP --with-config-file-path=/usr/local/PHP/etc --with-MysqL=/usr/local/MysqL --with-MysqLi=/usr/local/MysqL/bin/MysqL_config --with-MysqL-sock=/tmp/MysqL.sock --with-pdo-MysqL=/usr/local/MysqL --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype #配置
make #编译
make install #安装
cp PHP.ini-production /usr/local/PHP/etc/PHP.ini #复制PHP配置文件到安装目录
rm -rf /etc/PHP.ini #删除系统自带配置文件
ln -s /usr/local/PHP/etc/PHP.ini /etc/PHP.ini #添加软链接到/etc目录
cp /usr/local/PHP/etc/PHP-fpm.conf.default /usr/local/PHP/etc/PHP-fpm.conf #拷贝模板文件为PHP-fpm配置文件
ln -s /usr/local/PHP/etc/PHP-fpm.conf /etc/PHP-fpm.conf #添加软连接到/etc目录
vi /usr/local/PHP/etc/PHP-fpm.conf #编辑
user = www #设置PHP-fpm运行账号为www
group = www #设置PHP-fpm运行组为www
pid = run/PHP-fpm.pid #取消前面的分号
:wq! #保存退出
设置 PHP-fpm开机启动
cp /usr/local/src/PHP-5.5.14/sapi/fpm/init.d.PHP-fpm /etc/rc.d/init.d/PHP-fpm #拷贝PHP-fpm到启动目录
chmod +x /etc/rc.d/init.d/PHP-fpm #添加执行权限
chkconfig PHP-fpm on #设置开机启动
vi /usr/local/PHP/etc/PHP.ini #编辑配置文件
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_PHP = On
修改为:expose_PHP = Off #禁止显示PHP版本的信息
找到:short_open_tag = Off
修改为:short_open_tag = ON #支持PHP短标签
找到opcache.enable=0
修改为opcache.enable=1 #PHP支持opcode缓存
找到:opcache.enable_cli=1 #PHP支持opcode缓存
修改为:opcache.enable_cli=0
在最后一行添加:zend_extension=opcache.so #开启opcode缓存功能
:wq! #保存退出
配置Nginx支持PHP
vi /usr/local/Nginx/conf/Nginx.conf
修改/usr/local/Nginx/conf/Nginx.conf 配置文件,需做如下修改
user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/PHP/etc/PHP-fpm.conf中的user,group配置相同,否则PHP运行出错
index index.html index.htm index.PHP; #添加index.PHP
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;
}
#取消FastCGI server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
/etc/init.d/Nginx restart #重启Nginx
service PHP-fpm start #启动PHP-fpm
测试篇
cd /usr/local/Nginx/html/ #进入Nginx默认网站根目录
rm -rf /usr/local/Nginx/html/* #删除默认测试页
vi index.PHP #新建index.PHP文件
<?PHP
PHPinfo();
?>
:wq! #保存退出
chown www.www /usr/local/Nginx/html/ -R #设置目录所有者
chmod 700 /usr/local/Nginx/html/ -R #设置目录权限
在浏览器中打开服务器IP地址,会看到下面的界面
至此,CentOS 7.0编译安装Nginx1.6.0+MysqL5.6.19+PHP5.5.14教程完成。
» 本文链接:https://www.osyunwei.com/archives/7891.html
» 订阅本站:https://www.osyunwei.com/feed
» 转载请注明来源:系统运维 » CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14
Centos 5.5 64位 安装nginx1.4+php5.5+mysql+5.6笔记
一、安装必要的软件yum install -y update
yum install pcre
yum install openssl*
yum -y install 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
yum -y install gd gd2 gd-devel gd2-devel cmake bison ncurses
mdkir /data/software
cd /data/software
二、安装pcrewget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
tar zxvf pcre-8.33.tar.gz
cd pcre-8.33
./configure -prefix=/data/webserver/pcre
make && make install
cd ../
三、安装nginx
/usr/sbin/groupadd www
/usr/sbin/useradd www -g www -M -s /sbin/nologin
wget http://nginx.org/download/nginx-1.4.2.tar.gz
tar zxvf nginx-1.4.2.tar.gz
cd nginx-1.4.2
./configure --user=www --group=www --prefix=/data/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/data/software/pcre-8.33 --with-http_realip_module --with-http_image_filter_module
make
make install
cd ../
四、安装 MySQL:
#创建账号
/usr/sbin/groupadd mysql
/usr/sbin/useradd mysql -g mysql -M -s /sbin/nologin
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz
tar zxvf mysql-5.6.13.tar.gz
cd mysql-5.6.13
cmake \
-DCMAKE_INSTALL_PREFIX=/data/webserver/mysql \
-DMYSQL_DATADIR=/data/webserver/mysql/data \
-DSYSCONFDIR=/data/webserver/mysql \ #my.cnf路径
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \ #快捷键功能
-DMYSQL_UNIX_ADDR=/tmp/mysqld.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
make install
cd /data/webserver/mysql
chown -R mysql:mysql . #为了安全安装完成后请修改权限给mysql用户
scripts/mysql_install_db --user=mysql #先进行这一步再做如下权限的修改
chown -R root:mysql . #将权限设置给root用户,并设置给mysql组, 取消其他用户的读写执行权限,仅留给mysql "rx"读执行权限,其他用户无任何权限
chown -R mysql:mysql ./data #给数据库存放目录设置成mysql用户mysql组,并赋予chmod -R ug+rwx 读写执行权限,其他用户权限一律删除仅给mysql用户权限
cp support-files/my-default.cnf /data/webserver/mysql/my.cnf
#将mysql的启动服务添加到系统服务中
cp support-files/mysql.server /etc/init.d/mysql
#现在可以使用下面的命令启动mysql
service mysql start
#停止mysql服务
service mysql stop
#重启mysql服务
service mysql restart
#开机启动
chkconfig --add mysql
#修改默认root账户密码,默认密码为空
cd /data/webserver/mysql
./bin/mysqladmin -u root password
五、安装PHP依赖库:
mkdir -p /data/webserver/libs/
wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
tar zxvf jpegsrc.v9.tar.gz
cd jpeg-9/
./configure --prefix=/data/webserver/libs/ --enable-shared --enable-static --prefix=/data/webserver/libs
make
make install
cd ../
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.2.tar.gz
tar zxvf libpng-1.6.2.tar.gz
cd libpng-1.6.2/
./configure --prefix=/data/webserver/libs
make
make install
cd ../
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.12.tar.gz
tar zxvf freetype-2.4.12.tar.gz
cd freetype-2.4.12/
./configure --prefix=/data/webserver/libs
make && make install
cd ../
wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?big_mirror=0"
wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?big_mirror=0"
wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?big_mirror=0"
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure --prefix=/data/webserver/libs
make
make install
cd libltdl/
./configure --prefix=/data/webserver/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=/data/webserver/libs
make && make install
cd ../
vi /etc/ld.so.conf
/data/webserver/libs/lib
ldconfig
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
export LDFLAGS="-L/data/webserver/libs/lib -L/usr/lib"
export CFLAGS="-I/data/webserver/libs/include -I/usr/include"
touch malloc.h
./configure --prefix=/data/webserver/libs --with-libmcrypt-prefix=/data/webserver/libs
make
make install
cd ../
六、安装 php5.5:
wget http://us2.php.net/distributions/php-5.5.3.tar.gz
tar zxvf php-5.5.3.tar.gz
cd php-5.5.3
#export LIBS="-lm -ltermcap -lresolv"
#export CFLAGS=;export LIBS=
export DYLD_LIBRARY_PATH="/data/webserver/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
export LD_LIBRARY_PATH="/data/webserver/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
./configure --prefix=/data/webserver/php --with-config-file-path=/data/webserver/php/etc --with-mysql=/data/webserver/mysql --with-mysqli=/data/webserver/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir=/data/webserver/libs --with-jpeg-dir=/data/webserver/libs --with-png-dir=/data/webserver/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=/data/webserver/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 install
cp php.ini-development /data/webserver/php/etc/php.ini
cd ../
七、编译安装PHP扩展
wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar zxvf autoconf-latest.tar.gz
cd autoconf-2.69/
./configure --prefix=/data/webserver/libs
make
make install
cd ../
wget http://pecl.php.net/get/memcache-2.2.7.tgz
tar zxvf memcache-2.2.7.tgz
cd memcache-2.2.7/
export PHP_AUTOCONF="/data/webserver/libs/bin/autoconf"
export PHP_AUTOHEADER="/data/webserver/libs/bin/autoheader"
/data/webserver/php/bin/phpize
./configure --with-php-config=/data/webserver/php/bin/php-config
make
make install
cd ../
vi /data/webserver/php/etc/php.ini
#查找 ; extension_dir = "ext"
#在其后增加一行:
extension = "memcache.so"
CentOS 6 yum安装 Nginx1.6 + MySQL5.5 + PHP5.6
CentOS 6.8 yum安装 Nginx
下载nginx yum源
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
安装
rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm //得到yum源文件nginx.repo
显示结果 yum list | grep nginx
nginx-release-centos.noarch 6-0.el6.ngx installed
nginx.x86_64 1.16.0-1.el6.ngx nginx
nginx-debug.x86_64 1.8.0-1.el6.ngx nginx
nginx-debuginfo.x86_64 1.16.0-1.el6.ngx nginx
nginx-module-geoip.x86_64 1.16.0-1.el6.ngx nginx
nginx-module-geoip-debuginfo.x86_64 1.16.0-1.el6.ngx nginx
nginx-module-image-filter.x86_64 1.16.0-1.el6.ngx nginx
nginx-module-image-filter-debuginfo.x86_64 1.16.0-1.el6.ngx nginx
nginx-module-njs.x86_64 1.16.0.0.3.2-1.el6.ngx nginx
nginx-module-njs-debuginfo.x86_64 1.16.0.0.3.2-1.el6.ngx nginx
nginx-module-perl.x86_64 1.16.0-1.el6.ngx nginx
nginx-module-perl-debuginfo.x86_64 1.16.0-1.el6.ngx nginx
nginx-module-xslt.x86_64 1.16.0-1.el6.ngx nginx
nginx-module-xslt-debuginfo.x86_64 1.16.0-1.el6.ngx nginx
nginx-nr-agent.noarch 2.0.0-12.el6.ngx nginx
pcp-pmda-nginx.x86_64 3.10.9-9.el6 base
安装nginx
yum install nginx.x86_64
启动
service nginx start
Nginx 配置 php
server {
listen 80;
server_name localhost;
root /www/video; #放在外面
index index.php;
charset utf-8;
error_log /root/nginx.error.log error;
access_log /root/nginx.access.log main;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$; #开启path_info
fastcgi_param PATH_INFO $fastcgi_path_info; #开启path_info
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
include /etc/nginx/maccms.conf; #开启伪静态
}
CentOS 6.5下yum安装 MySQL5.5
检查是否安装过
1. rpm -qa|grep mysql 是否安装过mysql5.1有就卸载.
2. 卸载命令:rpm -e mysql-libs --nodeps
添加repo(需要增加两个repo)
//下载
wget http://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
//添加
rpm -Uvh http://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
检查是否增加成功
yum --enablerepo=remi,remi-test list mysql mysql-server
安装MySQL5.5
yum --enablerepo=remi,remi-test install mysql mysql-server
启动一下MySQL
/etc/init.d/mysqld start
开机自启动
chkconfig --levels 345 mysqld on
启用MySQL安全设置
/usr/bin/mysql_secure_installation
验证一下MySQL是否安装成功
mysql -uroot -p12345
配置my.ini
vi /etc/my.cnf
Centos 6.x/7.x yum安装php5.6
检查当前安装的PHP包
yum list installed | grep php
如果有安装的PHP包,先删除他们
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
配置yum源
//以下是CentOS 6的源。
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
//以下是CentOS 7.0的源。
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
使用yum list命令查看可安装的包(Packege)。
yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
安装PHP5.6.x
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-gd php-redis
安装PHP-fpm
yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm
安装GD库
yum --enablerepo=remi-php56 install php-gd
CentOS 6.0(X64)下编译安装LNMP平台( Nginx1.0.10 + PHP5.3.8 +_MySQL
LNMPCentOSNginx
bitsCN.comcentos 6.0(x64)下编译安装lnmp平台( nginx1.0.10 + php5.3.8 + mysql5.5.18 )
一、CentOS 6安装
1.1 使用VMware 虚拟机进行安装,进行安装界面
(分配内存必须大于1G,否则不会显示图型安装界面,网络设置使用“桥接模式” 即"Bridged"模式)
立即学习“PHP免费学习笔记(深入)”;
1.2 选择 Install or upgrade an existing system
1.3 在"Disc found" 框 选择 "skip"
1.4 next 选择 "chinese(simplified)(中文(简介 )) next
1.5 选择 "美国英语式" 下一步
1.6 选择 "基本 存储设备" 下一步
1.7 弹出"警告"框时,选择"重新初始化所有"
1.8 主机名可以保留默认,点击”配置网络“ 弹出“网络连接” 双击“System eth0"
1.9 弹出“正在编辑 System eth0" 选择"自动连接" 点击"应用“ ,点击”关闭“ 关闭”网络连接“框 下一步
1.10 不要选择“系统时钟使用UTC时间” 下一步
1.11 输入并确认 ”根密码“ 下一步
1.12 选择"替换现有Linux系统 " 下一步 “将修改写入磁盘"
1.13 选择"Basic Server" 下一步
1.14 大概一共590个软件包,复制安装完成后,点击“重新引导”,重新启动计算机
1.15 (安装完成后,可以将虚拟机内存由1G,改为512M)
二、更新centos6
2.1 更新
yum update -y
2.2 查看版本,确认为"CentOS Linux release 6.0 (Final)"
lsb_release -a
2.2 安装编译器
yum install -y gcc gcc-c++
三、安装Google-perftools (使用tcmalloc 加速 mysql 和 nginx)
3.1下载需要的文件
下载 libunwind-1.0.1.tar.gz 到 /usr/local/src
3.2 安装libunwind
cd /usr/local/src/
tar zvxf libunwind-1.0.1.tar.gz
cd libunwind-1.0.1
./configure --enable-shared
make && make install
3.3 安装google-perftools
cd /usr/local/src/
tar zvxf google-perftools-1.8.3.tar.gz
cd google-perftools-1.8.3
./configure --enable-shared --enable-frame-pointers
make && make install
3.4 更新,使动态链接库能够被系统共享
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
四、安装mysql
4.1.下载文件
下载 ncurses-5.9.tar.gz到/usr/local/src
下载 bison-2.5.tar.gz到/usr/local/src
下载 cmake-2.8.6.tar.gz到/usr/local/src
下载 mysql-5.5.18.tar.gz到/usr/local/src
4.2 安装ncurses
yum install ncurses-devel -y
cd /usr/local/src/
tar zvxf ncurses-5.9
./configure
make && make install
4.3 安装cmake
cd /usr/local/src/
tar zvxf cmake-2.8.6.tar.gz
cd cmake-2.8.6
./bootstrap
make && make install
4.4 安装bison
cd /usr/local/src/
tar zvxf bison-2.5.tar.gz
cd bison-2.5
./configure
make && make install
4.5 创建mysql需要的目录、配置用户和用户组
groupadd mysql
useradd -g mysql mysql
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
4.6.安装mysql (需要 cmake ncurses-devel bison 库)
4.6.1 安装
cd /usr/local/src/
tar zvxf mysql-5.5.18.tar.gz
cd mysql-5.5.18
cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/data/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/ -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on
make && make install
4.6.2 创建软连接
ln -s /opt/mysql/lib/lib* /usr/lib/
4.6.3 配置mysql数据库
cd /opt/mysql
./scripts/mysql_install_db --basedir=/opt/mysql/ --datadir=/data/mysql/ --user=mysql
4.6.4 复制配置文件
cp ./support-files/my-large.cnf /etc/my.cnf
4.6.5 修改配置文件,设置默认使用utf8编码
vim /etc/my.cnf
在[client]下添加一行
default-character-set = utf8
在[mysqld]下添加一行
character-set-server = utf8
4.6.6 设置mysql开机自动启动服务
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
4.6.7 修改服务配置文件
vim /etc/rc.d/init.d/mysqld
根据设定需要,修改mysqld文件中的下面两项
basedir=/opt/mysql
datadir=/data/mysql
4.6.8 启动mysqld服务
service mysqld start
4.6.9 数据库初始化及修改root密码(root初始密码为空)
./bin/mysql_secure_installation
根据提示操作
4.6.10 软连接mysql
ln -s /opt/mysql/bin/mysql /bin
4.6.11 重启centos后,尝试用root连接mysql
mysql -u root -p
成功登录后查看状态
status;
4.6.12 使用tcmalloc优化mysql ( 需要安装google-perftools)
修改MySQL启动脚本(根据你的MySQL安装位置而定)
vim /opt/mysql/bin/mysqld_safe
在# executing mysqld_safe的下一行,加上:
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
4.6.13 重启服务,查看tcmalloc是否生效 (第二条命令显示即生效)
service mysqld restart
lsof -n | grep tcmalloc
如果显示以下类似的信息,即表示tcmalloc生效
[root@localhost mysql]# lsof -n|grep tcmalloc
mysqld 30347 mysql mem REG 253,0 2177570 544322 /usr/local/lib/libtcmalloc.so.0.2.2
五、安装Nginx
5.1.准备安装
下载 pcre-8.20.tar.gz到/usr/local/src
下载 nginx-1.0.10.tar.gz到/usr/local/src
5.2 更新包
yum install zlib* openssl* -y
5.3 安装Pcre
cd /usr/local/src/
tar zvxf pcre-8.20.tar.gz
cd pcre-8.20
./configure
make && make install
5.4 创建www用户和组,创建www虚拟主机使用的目录,以及Nginx使用的日志目录,并且赋予他们适当的权限
groupadd www
useradd -g www www
mkdir -p /data/www
chmod +w /data/www
chown -R www:www /data/www
为tcmalloc添加目录,并且赋予适当权限
mkdir -p /tmp/tcmalloc/
chown -R www:www /tmp/tcmalloc/
5.1 安装Nginx (需要 pcre google-perftools 库)
5.5.1 安装
cd /usr/local/src/
tar zvxf nginx-1.0.10.tar.gz
伪装服务器信息(可以不修改)
cd nginx-1.0.10/src/core
vim ./src/core/nginx.h
修改NGINX_VERSION为你希望显示的版号
修改NGINX_VER为你希望显示的名称
修改NGINX_VAR 为你希望显示的名称
保存
开始安装
./configure --user=www --group=www --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-google_perftools_module
make && make install
5.4.2 修改 nginx.conf ,令nginx可以 google-perftools实现加速
vim /opt/nginx/conf/nginx.conf
修改前面几行为:
user www www;
worker_processes 8;
error_log logs/error.log crit;
pid logs/nginx.pid;
google_perftools_profiles /tmp/tcmalloc/;
events{
use epoll;
worker_connections 65535;
}
5.4.3 测试和运行
cd /opt/nginx
./sbin/nginx -t
如果显示下面信息,即表示配置没问题
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
输入代码运行nginx服务
./sbin/nginx
ps au|grep nginx
如果显以类似下面的信息,即表示nginx已经启动
root 2013 0.0 0.0 103156 856 pts/0 S+ 03:22 0:00 grep nginx
输入代码检测是否支持加速
lsof -n | grep tcmalloc
如果显示类似下面的信息,即表示支持tcmalloc加速 (mysqld和nginx两个线程都支持)
mysqld 20818 mysql mem REG 253,0 2177570 281050 /usr/local/lib/libtcmalloc.so.0.2.2
nginx 29454 www 25w REG 253,0 0 288399 /tmp/tcmalloc/.29454
nginx 29455 www 27w REG 253,0 0 288403 /tmp/tcmalloc/.29455
5.5.4 打开防火墙80端口
写入规则,保存并重启服务
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart
查看防火墙信息
/etc/init.d/iptables status
如果显示以下类似信息,即表示已经打开了80端口
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
5.5.5 编写nginx 启动服务
cd /etc/init.d
vim nginx
输入以下代码并保存
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse /
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/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="/opt/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/opt/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
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
killall -9 nginx
}
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
;;
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
保存后,设置权限,并添加到启动服务列表中
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig --level nginx
service nginx start
六、安装PHP
6.1 准备安装
下载php-5.3.6.tar.gz到/usr/local/src
下载 libiconv-1.14.tar.gz到/usr/local/src
下载 libmcrypt-2.5.8.tar.gz到/usr/local/src
下载mcrypt-2.6.8.tar.gz到/usr/local/src
下载mhash-0.9.9.9.tar.gz到/usr/local/src
下载libmcrypt-2.5.8.tar.gz到/usr/local/src
yum -y install 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 libXpm* gcc gcc-c++
5.2 安装libiconv (加强系统对支持字符编码转换的功能)
cd /usr/local/src/
tar zvxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make && make install
5.3 安装libmcrypt(加密算法库,PHP扩展mcrypt功能对此库有依耐关系,要使用mcrypt必须先安装此库)
5.3.1 安装libmcrypt
cd /usr/local/src/
tar zvxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
5.3.2安装libltdl
cd libltdl/
./configure --enable-ltdl-install
make && make install
5.3.3 更新共享
ln -sf /usr/local/lib/libmcrypt.* /usr/lib64/
ln -sf /usr/local/bin/libmcrypt-config /usr/lib64/
#ln -sf /usr/local/lib/libiconv.so.2 /usr/lib64/
ldconfig
5.4 安装mhash(hash加密算法库)
5.4.1 安装mhash
cd /usr/local/src/
tar zvxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make && make install
5.4.2更新共享
ln -sf /usr/local/lib/libmhash.* /usr/lib64/
ldconfig
5.5 安装mcrypt
cd /usr/local/src/
tar zvxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
ldconfig
./configure
make && make install
5.6 安装php
5.6.1 创建mysql软连接、ldap软连接
mkdir -p /opt/mysql/include/mysql
ln -s /opt/mysql/include/* /opt/mysql/include/mysql/
ln -s /usr/lib64/libldap* /usr/lib
5.6.2 安装
cd /usr/local/src/
tar zvxf php-5.3.8.tar.gz
cd php-5.3.8
./configure --prefix=/opt/php --with-config-file-path=/opt/php/etc --with-mysql=/opt/mysql --with-mysqli=/opt/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --disable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS=''-liconv''
make install
5.6.3 复制配置文件
cp php.ini-production /opt/php/etc/php.ini
5.6.4 安装memcache扩展(已经安装PHP)
cd /usr/local/src/
tar zvxf memcache-2.2.6.tar.gz
cd memcache-2.2.6
/opt/php/bin/phpize
cd memcache-2.2.6
ldconfig
./configure --with-php-config=/opt/php/bin/php-config
make && make install
修改php配置文件,支持memcache
vim /opt/php/etc/php.ini
在文件中搜索extension_dir、extension ,在相应位置添加下面两行
extension_dir = "/opt/php/lib/php/extensions/no-debug-non-zts-20090626/"
extension = "memcache.so"
5.6.5 安装eaccelerator扩展(已经安装PHP)
cd /usr/local/src/
tar jxvf eaccelerator-0.9.6.1.tar.bz2
/opt/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/opt/php/bin/php-config
make && make install
修改php配置文件,支持eaccelerator
vim /opt/php/etc/php.ini
在文件尾加入以下代码
[eaccelerator]
zend_extension="/opt/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="32"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file = "/opt/php/var/log/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
增加eaccelerator目录
mkdir -p /tmp/eaccelerator
5.6.5 安装php-fpm
cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf
vim /opt/php/etc/php-fpm.conf
修改以下地方
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5s
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
[www]
user = www
group = www
5.6.6 修改nginx,支持php
vim /opt/nginx/conf/nginx.conf
找到并修改以下代码
location ~ /.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
include fastcgi_params;
}
5.6.7将php-fpm 作为服务运行
cd /usr/local/src/php-5.3.8
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 700 /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig --level 345 php-fpm on
服务方式启动php-fpm
service php-fpm restart
5.6.8 编写测试页面
vim /data/www/index.php
输入代码
5.6.8 打开浏览器进行测试
bitsCN.com
CentOS 6.3 纯编译安装Nginx+MySQL+PHP
说明:操作系统:CentOS 6.3 32位
准备篇:
一、配置好IP、DNS 、网关,确保使用远程连接工具能够连接服务器
二、配置防火墙,开启80端口、3306端口
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口通过防火墙
特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面
添加好之后防火墙规则如下所示:
#########################################################
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
#########################################################
/etc/init.d/iptables restart #最后重启防火墙使配置生效
三、关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq 保存,关闭
shutdown -r Now #重启系统
四 、系统约定
软件源代码包存放位置:/usr/local/src
源码包编译安装位置:/usr/local/软件名字
五、下载软件包
1、下载Nginx(目前稳定版)
http://Nginx.org/download/Nginx-1.2.2.tar.gz
2、下载pcre (支持Nginx伪静态)
ftp://ftp.csx.cam.ac.uk/pub/soft ... re/pcre-8.31.tar.gz
4、下载MysqL
http://cdn.MysqL.com/Downloads/MysqL-5.5/MysqL-5.5.25a.tar.gz
5、下载PHP
http://cn.PHP.net/distributions/PHP-5.4.5.tar.gz
6、下载cmake(MysqL编译工具)
http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
7、下载libmcrypt(PHPlibmcrypt模块)
http://nchc.dl.sourceforge.net/p ... mcrypt-2.5.8.tar.gz
以上软件包使用工具上传到/usr/local/src目录
六、安装编译工具及库文件(使用CentOS yum命令安装)
yum install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* PHP-common PHP-gd ncurses* libtool* libxml2 libxml2-devel patch
安装篇
以下是用putty工具远程登录到服务器,在命令行下面操作的
一、安装cmake
cd /usr/local/src
tar zxvf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure
make #编译
make install #安装
二、安装MysqL
groupadd MysqL #添加MysqL组
useradd -g MysqL MysqL -s /bin/false #创建用户MysqL并加入到MysqL组,不允许MysqL用户直接登录系统
mkdir -p /data/MysqL #创建MysqL数据库存放目录
chown -R MysqL:MysqL /data/MysqL #设置MysqL数据库目录权限
mkdir -p /usr/local/MysqL #创建MysqL安装目录
cd /usr/local/src
tar zxvf MysqL-5.5.25a.tar.gz #解压
cd MysqL-5.5.25a
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DMysqL_DATADIR=/data/MysqL -DSYSconfdIR=/etc #配置
make #编译
make install #安装
cd /usr/local/MysqL
cp ./support-files/my-huge.cnf /etc/my.cnf #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
vi /etc/my.cnf #编辑配置文件,在 [MysqLd] 部分增加下面一行
datadir = /data/MysqL #添加MysqL数据库路径
:wq! #保存退出
./scripts/MysqL_install_db --user=MysqL #生成MysqL系统数据库
cp ./support-files/MysqL.server /etc/rc.d/init.d/MysqLd #把MysqL加入系统启动
chmod 755 /etc/init.d/MysqLd #增加执行权限
chkconfig MysqLd on #加入开机启动
vi /etc/rc.d/init.d/MysqLd #编辑
basedir = /usr/local/MysqL #MysqL程序安装路径
datadir = /data/MysqL #MysqL数据库存放目录
service MysqLd start #启动
vi /etc/profile #把MysqL服务加入系统环境变量:在最后添加下面这一行
export PATH=$PATH:/usr/local/MysqL/bin
:wq! #保存退出
下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定MysqL的库文件地址。
ln -s /usr/local/MysqL/lib/MysqL /usr/lib/MysqL
ln -s /usr/local/MysqL/include/MysqL /usr/include/MysqL
shutdown -r Now #需要重启系统,等待系统重新启动之后继续在终端命令行下面操作
MysqL_secure_installation #设置MysqL密码
根据提示按Y 回车
然后输入2次密码
继续按Y 回车,直到设置完成
或者直接修改密码/usr/local/MysqL/bin/MysqLadmin -u root -p password "123456" #修改密码
service MysqLd restart #重启
到此,MysqL安装完成!
三、安装pcre
cd /usr/local/src
mkdir /usr/local/pcre #创建安装目录
tar zxvf pcre-8.31.tar.gz
cd pcre-8.31
./configure --prefix=/usr/local/pcre #配置
make
make install
四、安装 Nginx
cd /usr/local/src
groupadd www #添加www组
useradd -g www www -s /bin/false #创建Nginx运行账户www并加入到www组,不允许www用户直接登录系统
tar zxvf Nginx-1.2.2.tar.gz
cd Nginx-1.2.2
./configure --prefix=/usr/local/Nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.31
注意:--with-pcre=/usr/local/src/pcre-8.31指向的是源码包解压的路径,而不是安装的路径,否则会报错
make
make install
/usr/local/Nginx/sbin/Nginx #启动Nginx
设置Nginx开启启动
vi /etc/rc.d/init.d/Nginx #编辑启动文件添加下面内容
=======================================================
#!/bin/bash
# Nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features,but it's not for everyone.
# processname: Nginx
# pidfile: /var/run/Nginx.pid
# config: /usr/local/Nginx/conf/Nginx.conf
Nginxd=/usr/local/Nginx/sbin/Nginx
Nginx_config=/usr/local/Nginx/conf/Nginx.conf
Nginx_pid=/usr/local/Nginx/logs/Nginx.pid
RETVAL=0
prog="Nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $Nginxd ] || exit 0
# Start Nginx daemons functions.
start() {
if [ -e $Nginx_pid ];then
echo "Nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $Nginxd -c ${Nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/Nginx
return $RETVAL
}
# Stop Nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $Nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/Nginx /usr/local/Nginx/logs/Nginx.pid
}
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${Nginx_pid}`
killproc $Nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL
=======================================================
:wq! #保存退出
chmod 775 /etc/rc.d/init.d/Nginx #赋予文件执行权限
chkconfig Nginx on #设置开机启动
/etc/rc.d/init.d/Nginx restart #重启
service Nginx restart
五、安装libmcrypt
cd /usr/local/src
tar zxvf libmcrypt-2.5.8.tar.gz #解压
cd libmcrypt-2.5.8 #进入目录
./configure #配置
make #编译
make install #安装
六、安装PHP
cd /usr/local/src
tar -zvxf PHP-5.4.5.tar.gz
cd PHP-5.4.5
mkdir -p /usr/local/PHP5 #建立PHP安装目录
./configure --prefix=/usr/local/PHP5 --with-config-file-path=/usr/local/PHP5/etc --with-MysqL=/usr/local/MysqL --with-MysqLi=/usr/local/MysqL/bin/MysqL_config --with-MysqL-sock=/tmp/MysqL.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl #配置
make #编译
make install #安装
cp PHP.ini-production /usr/local/PHP5/etc/PHP.ini #复制PHP配置文件到安装目录
rm -rf /etc/PHP.ini #删除系统自带配置文件
ln -s /usr/local/PHP5/etc/PHP.ini /etc/PHP.ini #添加软链接
cp /usr/local/PHP5/etc/PHP-fpm.conf.default /usr/local/PHP5/etc/PHP-fpm.conf #拷贝模板文件为PHP-fpm配置文件
vi /usr/local/PHP5/etc/PHP-fpm.conf #编辑
user = www #设置PHP-fpm运行账号为www
group = www #设置PHP-fpm运行组为www
pid = run/PHP-fpm.pid #取消前面的分号
设置 PHP-fpm开机启动
cp /usr/local/src/PHP-5.4.5/sapi/fpm/init.d.PHP-fpm /etc/rc.d/init.d/PHP-fpm #拷贝PHP-fpm到启动目录
chmod +x /etc/rc.d/init.d/PHP-fpm #添加执行权限
chkconfig PHP-fpm on #设置开机启动
vi /usr/local/PHP5/etc/PHP.ini #编辑配置文件
找到:disable_functions =
修改为:
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_PHP = On
修改为:expose_PHP = OFF #禁止显示PHP版本的信息
找到:short_open_tag = Off
修改为:short_open_tag = ON #支持PHP短标签
七、配置Nginx支持PHP
vi /usr/local/Nginx/conf/Nginx.conf #编辑配置文件,需做如下修改
user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/PHP5/etc/PHP-fpm.conf中的user,group配置相同,否则PHP运行出错
index index.PHP index.html index.htm; #添加index.PHP
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;
}
#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
/etc/init.d/Nginx restart #重启Nginx
测试篇
cd /usr/local/Nginx/html/ #进入Nginx默认网站根目录
rm -rf /usr/local/Nginx/html/* #删除默认测试页
vi index.PHP #编辑
<?PHP
PHPinfo();
?>
:wq! #保存退出
chown www.www /usr/local/Nginx/html/ -R #设置目录所有者
chmod 700 /usr/local/Nginx/html/ -R #设置目录权限
shutdown -r Now #重启系统
在浏览器中打开服务器IP地址,会看到下面的界面,配置成功
服务器相关操作命令
service Nginx restart #重启Nginx
service MysqLd restart #重启MysqL
/usr/local/PHP5/sbin/PHP-fpm #启动PHP-fpm
/etc/rc.d/init.d/PHP-fpm restart #重启PHP-fpm
/etc/rc.d/init.d/PHP-fpm stop #停止PHP-fpm
/etc/rc.d/init.d/PHP-fpm start #启动PHP-fpm
#############################################################################
备注:
Nginx默认站点目录是:/usr/local/Nginx/html/
权限设置:chown www:www /usr/local/Nginx/html/ -R
MysqL数据库目录是:/data/MysqL
权限设置:chown MysqL.MysqL -R /data/MysqL
至此,CentOS 6.3编译安装Nginx1.2.2+MysqL5.5.25a+PHP5.4.5完成
今天关于CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14和编译安装nginx启动命令的介绍到此结束,谢谢您的阅读,有关Centos 5.5 64位 安装nginx1.4+php5.5+mysql+5.6笔记、CentOS 6 yum安装 Nginx1.6 + MySQL5.5 + PHP5.6、CentOS 6.0(X64)下编译安装LNMP平台( Nginx1.0.10 + PHP5.3.8 +_MySQL、CentOS 6.3 纯编译安装Nginx+MySQL+PHP等更多相关知识的信息可以在本站进行查询。
本文标签: