操作系统 Cent OS 5.x(32bit)
Nginx版本 0.8.52
PHP版本 5.2.13
MySQL版本 5.1.46
软件源代码包存放位置 /usr/local/src/lnmp
源码包编译安装位置(prefix) /usr/local/software_name
MySQL数据库data路径 /var/lib/mysql
网站文档父目录 /home/www/
Nginx和php-cgi运行用户 www:www
您可以选择使用我们编写的安装脚本进行自动安装,自动安装和您手工按本文中所写的方法安装效果是一样的。
执行下面的2条命令即可完成自动安装。
安装完成后所有的帐号信息会保存在/root/setup.txt中,同时也会包含一些必要的帮助信息。
wget http://wiki.diahosting.com/down/lnmp/install.sh chmod 700 install.sh ./install.sh
yum install -y gcc gcc-c++ glibc glibc-devel glib2 glib2-devel unzip make ncurses ncurses-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel bzip2 bzip2-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 xinetd patch
mkdir -p /usr/local/src/lnmp cd /usr/local/src/lnmp wget http://wiki.diahosting.com/down/lnmp/libiconv-1.13.tar.gz wget http://wiki.diahosting.com/down/lnmp/mhash-0.9.9.9.tar.gz wget http://wiki.diahosting.com/down/lnmp/pcre-7.9.tar.gz wget http://wiki.diahosting.com/down/lnmp/libmcrypt-2.5.8.tar.gz wget http://wiki.diahosting.com/down/lnmp/mysql-5.1.46.tar.gz wget http://wiki.diahosting.com/down/lnmp/php-5.2.13-fpm-0.5.14.diff.gz wget http://wiki.diahosting.com/down/lnmp/mcrypt-2.6.8.tar.gz wget http://wiki.diahosting.com/down/lnmp/nginx-0.8.52.tar.gz wget http://wiki.diahosting.com/down/lnmp/php-5.2.13.tar.gz wget http://wiki.diahosting.com/down/lnmp/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz wget http://wiki.diahosting.com/down/lnmp/eaccelerator-0.9.6.tar.gz wget http://wiki.diahosting.com/down/lnmp/phpMyAdmin.tar.gz wget http://wiki.diahosting.com/down/lnmp/pure-ftpd-1.0.29.tar.gz wget http://wiki.diahosting.com/down/lnmp/php-fpm.conf wget http://wiki.diahosting.com/down/lnmp/nginx.conf wget http://wiki.diahosting.com/down/lnmp/phpMyAdmin.conf wget http://wiki.diahosting.com/down/lnmp/default.conf wget http://wiki.diahosting.com/down/lnmp/nginx.init for FILE in ./*.tar.gz; do tar xvf $FILE; done
groupadd mysql useradd -s /sbin/nologin -M -g mysql mysql
cd /usr/local/src/lnmp/mysql-5.1.46 ./configure --prefix=/usr/local/mysql --enable-assembler --with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all --with-big-tables
make;make install
chown -R mysql:mysql /usr/local/mysql
cp support-files/my-medium.cnf /etc/my.cnf
[mysqld] basedir=/usr/local/mysql datadir=/var/lib/mysql
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/var/lib/mysql --user=mysql
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld
/etc/init.d/mysqld start
注意替换root-password为您自己的MySQL root密码。
/usr/local/mysql/bin/mysqladmin -u root password root-password
chkconfig mysqld on
ln -s /usr/local/mysql/bin/myisamchk /usr/bin/ ln -s /usr/local/mysql/bin/mysql /usr/bin/ ln -s /usr/local/mysql/bin/mysqldump /usr/bin/
cd /usr/local/src/lnmp/libiconv-1.13/ ./configure --prefix=/usr/local make make install cd /usr/local/src/lnmp/libmcrypt-2.5.8/ ./configure --exec-prefix=/usr make make install /sbin/ldconfig cd libltdl/ ./configure --enable-ltdl-install make make install cd /usr/local/src/lnmp/mhash-0.9.9.9/ ./configure --prefix=/usr make make install cd /usr/local/src/lnmp/mcrypt-2.6.8/ /sbin/ldconfig ./configure make make install
cd /usr/local/src/lnmp/ gzip -cd php-5.2.13-fpm-0.5.14.diff.gz | patch -d php-5.2.13 -p1 cd php-5.2.13/ ./configure --prefix=/usr/local/php --with-config-file-path=/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 --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --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 --with-pear=/usr/local/php/pear make ZEND_EXTRA_LIBS='-liconv' make install cp php.ini-recommended /etc/php.ini
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"#' /etc/php.ini sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 32M/g' /etc/php.ini sed -i 's/short_open_tag = Off/short_open_tag = On/g' /etc/php.ini sed -i 's/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php.ini
cd /usr/local/src/lnmp/ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp mkdir -p /usr/local/ZendOptimizer/ cp ZendOptimizer.so /usr/local/ZendOptimizer/ZendOptimizer.so
在/etc/php.ini的末尾加入下面的内容
[Zend Optimizer] zend_optimizer.optimization_level=1 zend_extension="/usr/local/ZendOptimizer/ZendOptimizer.so"
cd /usr/local/src/lnmp/eaccelerator-0.9.6 /usr/local/php/bin/phpize ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config make make install mkdir /tmp/eaccelerator chmod 0777 /tmp/eaccelerator
在/etc/php.ini的末尾加入下面的内容
[eAccelerator] extension="eaccelerator.so" eaccelerator.shm_size="16" eaccelerator.cache_dir="/tmp/eaccelerator" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="0" eaccelerator.shm_prune_period="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9"
ln -s /usr/local/php/bin/php /usr/bin/php ln -s /usr/local/php/sbin/php-fpm /usr/bin/phpfpm ln -s /usr/local/php/bin/pear /usr/bin/pear ln -s /usr/local/php/bin/pecl /usr/bin/pecl
/usr/sbin/groupadd www /usr/sbin/useradd -s /sbin/nologin -g www www
cp -f /usr/local/src/lnmp/php-fpm.conf /usr/local/php/etc/php-fpm.conf
phpfpm start
echo "/usr/local/php/sbin/php-fpm start" >> /etc/rc.local
cd /usr/local/src/lnmp/pcre-7.9/ ./configure make && make install
cd /usr/local/src/lnmp/nginx-0.8.52/ ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module make && make install
mkdir -p /usr/local/nginx/conf/vhost/ cp -f /usr/local/src/lnmp/nginx.conf /usr/local/nginx/conf/nginx.conf cp -f /usr/local/src/lnmp/nginx-0.8.52/conf/fastcgi.conf /usr/local/nginx/conf/fcgi.conf
cp /usr/local/src/lnmp/default.conf /usr/local/nginx/conf/vhost/default.conf mkdir /home/www/default chown -R www:www /home/www/default
cp /usr/local/src/lnmp/phpMyAdmin.conf /usr/local/nginx/conf/vhost/phpMyAdmin.conf cp -r /usr/local/src/lnmp/phpMyAdmin /home/www/ chown -R www:www /home/www/phpMyAdmin
安装之后可以用下面的地址来访问phpMyAdmin
http://您的IP地址:999
cp /usr/local/src/lnmp/nginx.init /etc/init.d/nginx
service nginx start
chkconfig nginx on
cd /usr/local/src/lnmp/pure-ftpd-1.0.29 ./configure --prefix=/usr/local/pureftpd --with-language=simplified-chinese make install-strip
编辑/etc/xinetd.d/pureftpd,加入下面的内容。
service ftp { socket_type = stream server = /usr/local/pureftpd/sbin/pure-ftpd server_args = -A -E -I 2 -l unix -p 40000:50000 -w protocol = tcp user = root wait = no disable = no }
重启Xinetd
service xinetd restart
passwd www
输入要设置的密码,然后重复输入一次进行确认。注意Linux下输入的密码不会回显星号。
设置之后即可使用用户名www登录FTP了,密码即为刚刚设置的密码。
cd /usr/local/src/lnmp wget http://wiki.diahosting.com/down/lnmp/cgiwrap-fcgi.pl wget http://wiki.diahosting.com/down/lnmp/perl_fcgi.conf wget http://wiki.diahosting.com/down/lnmp/monitorix.conf cp -f /usr/local/src/lnmp/cgiwrap-fcgi.pl /usr/local/nginx/sbin/cgiwrap-fcgi.pl chmod 755 /usr/local/nginx/sbin/cgiwrap-fcgi.pl cp -f /usr/local/src/lnmp/perl_fcgi.conf /usr/local/nginx/conf/perl_fcgi.conf cp -f /usr/local/src/lnmp/monitorix.conf /usr/local/nginx/conf/vhost/monitorix.conf
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt cd /usr/local/src/lnmp wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm rpm -i rpmforge-release-0.5.1-1.el5.rf.i386.rpm yum install -y rrdtool rrdtool-perl perl perl-libwww-perl vixie-cron cd /usr/local/src/lnmp wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz tar zxvf FCGI-0.67.tar.gz cd FCGI-0.67 perl Makefile.PL make make install cd /usr/local/src/lnmp wget http://www.cpan.org/modules/by-module/FCGI/FCGI-ProcManager-0.18.tar.gz tar zxvf FCGI-ProcManager-0.18.tar.gz cd FCGI-ProcManager-0.18 perl Makefile.PL make make install
/usr/local/nginx/sbin/cgiwrap-fcgi.pl echo "/usr/local/nginx/sbin/cgiwrap-fcgi.pl" >> /etc/rc.local
cd /usr/local/src/lnmp wget http://www.monitorix.org/monitorix-1.5.2-1.noarch.rpm rpm -ivh monitorix-1.5.2-1.noarch.rpm service monitorix start
sed -i 's/cgi-bin/monitorix/g' /usr/sbin/monitorix.pl sed -i 's/ENABLE_NGINX = "N/ENABLE_NGINX = "Y/g' /etc/monitorix.conf sed -i 's/ENABLE_INT = "Y/ENABLE_INT = "N/g' /etc/monitorix.conf sed -i 's/NGINX_PORT = "80/NGINX_PORT = "998/g' /etc/monitorix.conf sed -i 's/cgi-bin/monitorix/g' /var/www/html/monitorix/index.html cp /var/www/cgi-bin/monitorix.cgi /var/www/html/monitorix/monitorix.cgi echo '<? header("location:/monitorix/index.html") ?>' > /var/www/html/index.php
service crond start service nginx restart service monitorix restart
启动Nginx
service nginx start
重启Nginx
service nginx restart
重新加载Nginx配置文件(不重启)
service nginx reload
停止Nginx
service nginx stop
启动PHP
phpfpm start
重启PHP
phpfpm restart
重新加载PHP配置文件(不重启)
phpfpm reload
停止PHP
phpfpm stop
启动MySQL
service mysqld start
重启MySQL
service mysqld restart
停止Nginx
service mysqld stop