指引网

当前位置: 主页 > 服务器 > Nginx >

centos5.6+nginx1.04+mysql5.5.14+php5.3.6(LNMP)一键安装脚本

来源:网络 作者:佚名 点击: 时间:2017-08-31 00:40
[摘要] 一键安装脚本,乖乖,仅是听到这几个字都春心荡荡,呵呵。centos5.6+nginx1.04+mysql5.5.14+php5.3.6一键安装脚本...

一键安装脚本,乖乖,仅是听到这几个字都春心荡荡,呵呵。
centos5.6+nginx1.04+mysql5.5.14+php5.3.6一键安装脚本,文章后附有相关注解,并提供完整脚本文件下载,不容错过哦。

复制代码 代码如下:

#!/bin/bash

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 gli
b2-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

tar zxf lnmp.tar.gz ###软件包放在目录/usr/local/src

cd lnmp

tar zxf libiconv-1.13.tar.gz
cd libiconv-1.13
./configure --prefix=/usr/local
make
make install
cd ../

tar zxvf 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
cd ../../

tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure && make && make install
cd ../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure && make && make install
cd ../

tar zxf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./bootstrap
gmake
gmake install
cd ../

tar zxvf bison-2.5.tar.gz
cd bison-2.5
./configure && make && make install
cd ../

/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxf mysql-5.5.14.tar.gz
cd mysql-5.5.14
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING
=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
make && make install

cd /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
cp support-files/my-medium.cnf /etc/my.cnf
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp support-files/mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start
/etc/init.d/mysqld stop

cd /usr/local/src/lnmp
tar zxf php-5.3.6.tar.gz
cd php-5.3.6
./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-ico
nv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath  --enable-safe-mode --enable-bcmat
h --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex  --enable-fpm  --enable-mbstring --with-mcrypt --with-g
d --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-production /usr/local/php/etc/php.ini
cd ../

tar zxf memcache-2.2.6.tgz
cd memcache-2.2.6
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../

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
cd ../

tar zxf 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-pdo-mysql=/usr/local/mysql
make && make install
cd ../

tar zxf ImageMagick-6.7.0-10.tar.gz
cd ImageMagick-6.7.0-10
./configure
make && make install
cd ../

tar zxf imagick-3.0.1.tgz
cd imagick-3.0.1
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

cd ../

sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"nextension = "memcache.so"nextension = "pdo_mysql.so"ne
xtension = "imagick.so"n#' /usr/local/php/etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/php/etc/php.ini

mkdir -p  /var/cache/eaccelerator_cache
chmod 777 /var/cache/eaccelerator_cache
cat >>/usr/local/php/etc/php.ini<<EOF
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/var/cache/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
EOF

mv  /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

sed -i 's/user = nobody/user = www/g' /usr/local/php/etc/php-fpm.conf

sed -i 's/group = nobody/group = www/g' /usr/local/php/etc/php-fpm.conf

sed -i 's/;pm.start_servers/pm.start_servers/g' /usr/local/php/etc/php-fpm.conf

sed -i 's/;pm.min_spare_servers/pm.min_spare_servers/g' /usr/local/php/etc/php-fpm.conf

sed -i 's/;pm.max_spare_servers/pm.max_spare_servers/g' /usr/local/php/etc/php-fpm.conf
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www

unzip pcre-8.12.zip
cd pcre-8.12
./configure
make
make install
cd ../

tar zxf nginx-1.0.4.tar.gz
cd nginx-1.0.4
./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.conf.bak

cp /usr/local/src/software/nginx.conf /usr/local/nginx/conf
cd ../

/usr/local/nginx/sbin/nginx

/usr/local/php/sbin/php-fpm

注1:lnmp.tar.gz包含以下源码包:

复制代码 代码如下:
bison-2.5.tar.gz
cmake-2.8.4.tar.gz
eaccelerator-0.9.6.1.zip
ImageMagick-6.7.0-10.tar.gz
imagick-3.0.1.tgz
libiconv-1.13.tar.gz
libmcrypt-2.5.8.tar.gz
mcrypt-2.6.8.tar.gz
memcache-2.2.6.tgz
mhash-0.9.9.9.tar.gz
mysql-5.5.14.tar.gz
nginx-1.0.4.tar.gz
pcre-8.12.zip
PDO_MYSQL-1.0.2.tgz
php-5.3.6.tar.gz

nginx.conf ####配置以下内容
注2:简单配置 nginx.conf
 

复制代码 代码如下:
user  www;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  192.168.179.130; ###根据实际情况修改访问地址
        location / {
            root   html;
            index  index.php index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ .php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fastcgi.conf;
        }
    }
}

注3:
在centos5.6(32位)上编译php的时候,出现错误提示:
configure:error:wrong mysql library version or lib not found

查看config.log, 主要的报错信息是:
“/usr/bin/ld: cannot find -lprobes_mysql”

解决方法:
在编译mysql的时候,把ENABLE_DTRACE设置为OFF(默认为ON),然后重新安装mysql和php。
ccmake . 进入图形配置界面,选中按回车键设置,配置好按c键完成,q键退出。

配图如下:
lnmp-img1
附:脚本下载。

------分隔线----------------------------