编译安装lnmp步骤
来源:互联网 发布:鼎力测试软件下载 编辑:程序博客网 时间:2024/05/17 20:29
生产环境软件版本:
php-5.3.8
nginx-1.0.12
mysql-5.5.18
0、安装编译环境
yum install autoconf
Autoconf is a tool for configuring source code and Makefiles,Autoconf is only required for the generation of the scripts.
yum install gcc gcc-c++
yum install cmake
yum -y install autoconf gcc gcc-c++ cmake
安装编译php时依赖的开发包
yum install libxml2 libxml2-devel
yum install openssl-devel
yum install curl-devel
yum install openldap-devel
yum -y install libxml2 libxml2-devel openssl-devel curl-devel openldap-devel
安装SVN
yum -y install subversion
安装php的依赖包
cd /root/soft/rpm
rpm -e --allmatches --nodeps freetype-2.2.1-28.el5_7.2
rpm -e --allmatches --nodeps libjpeg-6b-37
rpm -e --allmatches --nodeps libpng-1.2.10-7.1.el5_7.5
rpm -ivh libjpeg-*
rpm -ivh libpng-*
rpm -ivh freetype-*
rpm -ivh *.rpm
#安装libmcrypt
cd /home/software
tar -xzvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
/sbin/ldconfig
cd libltdl
./configure --enable-ltdl-install
make
make install
安装php时需要mysql支持
configure: error: Cannot find MySQL header files under /usr/local/mysql.
#安装MySQL
tar -xzvf mysql-5.5.18.tar.gz
cd mysql-5.5.18
添加mysql组
groupadd mysql
useradd -r -g mysql mysql
安装mysql支持包
yum -y install ncurses-devel
yum -y install bison-devel bison
cmake -DCMAKE_INSTALL_JPREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DENABLE_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DMYSQL_TCP_PORT=3306 \
-DWITH_DEBUG=OFF \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_SSL=system \
-DENABLE_DTRACE=OFF
make
make install
配置mysql
cd /usr/local/mysql/
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
vim /etc/my.cnf #上传
bin/mysqld_safe --user=mysql &
bin/mysql_secure_installation
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chown root:root /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
chkconfig --level 5 mysqld on
# chkconfig --list mysqld
# service mysqld status|start|stop|restart
1、安装php5.3.8
安装php之前先安装依赖包
#libiconv
cd /home/software
tar -xzvf libiconv-1.13.tar.gz
cd libiconv-1.13
./configure --prefix=/usr/local
make
make install
[root@vm211 soft]# tar xzvf php-5.3.8.tar.gz
[root@vm211 soft]# cd php-5.3.8
[root@vm211 php-5.3.8]# ./buildconf --force
[root@vm211 php-5.3.8]#./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-iconv-dir=/usr/local \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--enable-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
make ZEND_EXTRA_LIBS='-liconv'
make install
vim /usr/local/php/etc/php.ini #上传
#安装php扩展模块
#PHP Memcache extension
cd /home/software
tar -xzvf memcache-2.2.5.tgz
cd memcache-2.2.5
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
#Installing shared extensions: /usr/local/php/lib/php/extensions/nodebug-
non-zts-20090626/
#PHP PDO_MYSQL extension
cd /home/software
tar -xzvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdomysql=/usr/local/mysql
php编译安装时,configure: error: Cannot find MySQL header files under
解决办法:
ln -s /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config
make
make install
#Installing shared extensions: /usr/local/php/lib/php/extensions/nodebug-
non-zts-20090626/
#PHP MongoDB extension
cd /home/software
tar -xzvf PHP-mongo-1.1.4.tgz
cd mongo-1.1.4/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
#Installing shared extensions: /usr/local/php/lib/php/extensions/nodebug-
non-zts-20090626/
#PHP Redis extension
cd /home/software/
unzip nicolasff-phpredis-2.1.3-119-gc991437.zip
cd nicolasff-phpredis-c991437/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
#Installing shared extensions: /usr/local/php/lib/php/extensions/nodebug-
non-zts-20090626/
#PHP eAccelerator
cd /home/software/
unzip eaccelerator-0.9.6.1.zip
cd eaccelerator-0.9.6.1/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
mkdir -p /usr/local/eaccelerator_cache
groupadd www
useradd -g www www
mkdir /var/www
chown -R www:www /var/www/
cd /usr/local/php/etc
vi php-fpm.conf #上传
mkdir -p /var/run/php-fpm/
mkdir -p /var/log/php-fpm/
/usr/local/php/sbin/php-fpm
#Pcre
cd /home/software
tar -xzvf pcre-8.02.tar.gz
cd pcre-8.02
./configure
make
make install
##安装nginx
下载最新nginx
wget http://nginx.org/download/nginx-1.0.12.tar.gz
cd /home/software
tar -xzvf nginx-1.0.12.tar.gz
cd nginx-1.0.12
把server信息由nginx修改为wws(Weiboyi Web Server)
# vim src/core/nginx.h
#define nginx_version 2000012
#define NGINX_VERSION "2.0.12"
#define NGINX_VER "WWS/" NGINX_VERSION
./configure --user=www \
--group=www \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module
make
make install
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.bak
vi /usr/local/nginx/conf/nginx.conf #上传
mkdir -p /var/log/nginx/
vi /usr/local/nginx/conf/fcgi.conf #上传
ulimit -SHn 65535
/usr/local/nginx/sbin/nginx
增加nginx启动脚本
[root@vm211 soft]# more /etc/init.d/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="/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
php-fpm启动脚本
[root@vm211 soft]# more /etc/init.d/php-fpm
#!/bin/sh
#
# php-fpm - this script starts and stops the php-fpm daemin
#
# chkconfig: - 85 15
# processname: php-fpm
# config: /usr/local/php/etc/php-fpm.conf
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="php-fpm daemon"
NAME=php-fpm
DAEMON=/usr/local/php/sbin/$NAME #这里设成自己的目录
CONFIGFILE=/usr/local/php/etc/php-fpm.conf #这里设成自己的目录
PIDFILE=/var/run/php-fpm/$NAME.pid #这里设成自己的目录
SCRIPTNAME=/etc/init.d/$NAME #这里设成自己的目录
# If the daemon file is not found, terminate the script.
test -x $DAEMON || exit 0
d_start(){
$DAEMON -y $CONFIGFILE || echo -n " already running"
}
d_stop(){
kill -QUIT `cat $PIDFILE` || echo -n " no running"
}
d_reload(){
kill -HUP `cat $PIDFILE` || echo -n " could not reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
d_reload
echo "Reloaded."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
# Sleep for two seconds before starting again, this should give the nginx daemon
some time to perform a graceful stop
sleep 2
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload)" >&2
exit 3
;;
esac
exit 0
安全措施:
修改php.ini隐藏php版本信息expose_php = Off
内核参数调优
vi /etc/rc.local
#底部增加
#######
ulimit -SHn 65535
/usr/local/php/sbin/php-fpm
/usr/local/nginx/sbin/nginx
#######
vi /etc/sysctl.conf
#底部增加
#######
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000
#######
/sbin/sysctl -p
- 编译安装lnmp步骤
- CentOS5 编译安装LNMP步骤
- CentOS6 编译安装LNMP步骤
- 源码编译安装LNMP
- lnmp编译安装
- ubuntu编译安装lnmp
- Ubuntu 编译安装LNMP
- 编译安装lnmp环境
- LNMP编译安装
- LNMP源码编译安装
- 编译安装LNMP配置
- LNMP--编译安装--教程
- 编译安装LNMP环境
- LNMP编译安装教程
- LNMP 源码编译安装
- LNMP的编译安装
- CentOS6编译安装LNMP
- LNMP编译安装常见问题
- icinga 添加http service
- 通过iptables限制并发连接数20130515
- 给定一个集合,输出它的所有子集(JAVA实现)
- 初学者必读 MySQL 数据库常见问题汇总
- Nginx动静分离经典案例配置
- 编译安装lnmp步骤
- ACM参考算法集
- ORA-12505: TNS: 监听程序当前无法识别连接描述符中所给出的SID等错误解决方法
- socket编程指南
- lvm动态扩展硬盘
- 【Linux】Linux环境下用过的C/C++编辑器或IDE
- Android中ListView分页加载数据
- 扎克伯格:Facebook Home和人类沟通的未来
- centos_openssh_server6.1_chroot配置文档