共计 12047 个字符,预计需要花费 31 分钟才能阅读完成。
近期公司打算从 lamp 更换到 lnmp 平台,所以研究了一下 lnmp 的安装。将这个整理成了一个脚本. 后面会附带给大家的,脚本写的很烂,基本没有什么判断,希望大家能够谅解. 可以提出意见 我尽力改正。
LNMP 脚本下载:
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是 www.linuxidc.com
具体下载目录在 /2013 年资料 /11 月 / 7 日 /CentOS 6.4 下的 LNMP 生产环境搭建及安装脚本
下载方法见 http://www.linuxidc.com/Linux/2013-07/87684.htm
————————————– 分割线 ————————————–
软件版本:
libiconv-1.13.tar.gz
libmcrypt-2.5.8.tar.gz
mcrypt-2.6.8.tar.gz
mhash-0.9.9.9.tar.gz
memcache-2.2.5.tgz
PDO_MySQL-1.0.2.tgz
imagick-3.1.2.tgz
pcre-8.21.tar.gz
mysql-5.5.30.tar.gz
ImageMagick.tar.gz
php-5.4.21.tar.gz
nginx-1.4.0.tar.gz
eaccelerator-eaccelerator-42067ac.tar.gz (为 1.0-dev 版)
系统安装需求:
centos 6.4 *86_64 mini 安装,关闭 selinux,iptables
1 安装解决依赖关系:
yum install -y wget gcc gcc-c++ autoconf libjpeg libjpeg-devel perl perl* perl-CPAN 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 png jpeg autoconf gcc cmake make gcc-c++ gcc ladp ldap* ncurses ncurses-devel zlib zlib-devel zlib-static pcre pcre-devel pcre-static openssl openssl-devel perl libtoolt openldap-devel libxml2-devel ntpdate cmake gd* gd2 ImageMagick-devel jpeg jpeg* pcre-dev* fontconfig libpng libxml2 zip unzip gzip
2 下载所有使用到的软件:
wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.13.tar.gz
wget http://lcmp.googlecode.com/files/libmcrypt-2.5.8.tar.gz
wget http://jaist.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
wget http://jaist.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget http://vps.googlecode.com/files/memcache-2.2.5.tgz
wget http://vps.googlecode.com/files/PDO_MYSQL-1.0.2.tgz
wget http://pecl.php.net/get/imagick-3.1.2.tgz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
wget http://netcologne.dl.sourceforge.net/project/mysql.mirror/MySQL%205.5.30/mysql-5.5.30.tar.gz
wget http://mynginx.googlecode.com/files/ImageMagick.tar.gz
wget http://us3.php.net/get/php-5.4.21.tar.gz/from/cn2.php.net/mirror
wget https://lnamp-web-server.googlecode.com/files/eaccelerator-eaccelerator-42067ac.tar.gz
wget http://nginx.org/download/nginx-1.4.0.tar.gz
更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2013-11/92428p2.htm
相关阅读:
Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm
CentOS 5.9 下编译安装 LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm
RedHat 5.4 下 Web 服务器架构之源码构建 LAMP 环境及应用 PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm
LAMP 源码环境搭建 WEB 服务器 Linux+Apache+MySQL+PHP http://www.linuxidc.com/Linux/2013-05/84882.htm
3 安装 MySQL-5.5.0
groupadd mysql
useradd mysql -g mysql
tar -zxvf mysql-5.5.30.tar.gz
cd mysql-5.5.30
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql/ \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
make && make install
mkdir -p /data/mysql
chown mysql.mysql -R /data/mysql
mv /etc/my.cnf /etc/my.cnf-old
cp support-files/my-medium.cnf /etc/my.cnf
chmod 755 scripts/mysql_install_db
scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/data/mysql/
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig mysqld on
service mysqld start
设置 mysql 的 root 密码为 123456
/usr/local/mysql/bin/mysqladmin -u root password ‘123456’
4 安装 php 的扩展库:libiconv
tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure –prefix=/usr/local
make && make install
5 安装 php 扩展库:libmcrypt
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
6 安装 php 扩展库:mhash
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make && make install
7 做库的软连接:
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
ln -s /usr/lib64/libldap* /usr/lib/
8 安装 php 扩展包:mcrypt
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make && make install
9 安装 php-5.4.21:
tar -zxvf php-5.4.21.tar.gz
cd php-5.4.21
./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 –with-zlib –with-gd –enable-gd-native-ttf –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-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap –without-pear
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
make ZEND_EXTRA_LIBS=’-liconv’
make install
cp -f php.ini-production /usr/local/php/etc/php.ini
ln -s /usr/local/php/etc/php.ini /usr/local/php/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
10 安装 php 扩展库:memcache
tar zxvf 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
11 安装 php 加速:eaccelerator
tar -zxvf eaccelerator-eaccelerator-42067ac.tar.gz
cd eaccelerator-eaccelerator-42067ac
/usr/local/php/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config
make && make install
近期公司打算从 lamp 更换到 lnmp 平台,所以研究了一下 lnmp 的安装。将这个整理成了一个脚本. 后面会附带给大家的,脚本写的很烂,基本没有什么判断,希望大家能够谅解. 可以提出意见 我尽力改正。
LNMP 脚本下载:
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是 www.linuxidc.com
具体下载目录在 /2013 年资料 /11 月 / 7 日 /CentOS 6.4 下的 LNMP 生产环境搭建及安装脚本
下载方法见 http://www.linuxidc.com/Linux/2013-07/87684.htm
————————————– 分割线 ————————————–
软件版本:
libiconv-1.13.tar.gz
libmcrypt-2.5.8.tar.gz
mcrypt-2.6.8.tar.gz
mhash-0.9.9.9.tar.gz
memcache-2.2.5.tgz
PDO_MySQL-1.0.2.tgz
imagick-3.1.2.tgz
pcre-8.21.tar.gz
mysql-5.5.30.tar.gz
ImageMagick.tar.gz
php-5.4.21.tar.gz
nginx-1.4.0.tar.gz
eaccelerator-eaccelerator-42067ac.tar.gz (为 1.0-dev 版)
系统安装需求:
centos 6.4 *86_64 mini 安装,关闭 selinux,iptables
1 安装解决依赖关系:
yum install -y wget gcc gcc-c++ autoconf libjpeg libjpeg-devel perl perl* perl-CPAN 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 png jpeg autoconf gcc cmake make gcc-c++ gcc ladp ldap* ncurses ncurses-devel zlib zlib-devel zlib-static pcre pcre-devel pcre-static openssl openssl-devel perl libtoolt openldap-devel libxml2-devel ntpdate cmake gd* gd2 ImageMagick-devel jpeg jpeg* pcre-dev* fontconfig libpng libxml2 zip unzip gzip
2 下载所有使用到的软件:
wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.13.tar.gz
wget http://lcmp.googlecode.com/files/libmcrypt-2.5.8.tar.gz
wget http://jaist.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
wget http://jaist.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget http://vps.googlecode.com/files/memcache-2.2.5.tgz
wget http://vps.googlecode.com/files/PDO_MYSQL-1.0.2.tgz
wget http://pecl.php.net/get/imagick-3.1.2.tgz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
wget http://netcologne.dl.sourceforge.net/project/mysql.mirror/MySQL%205.5.30/mysql-5.5.30.tar.gz
wget http://mynginx.googlecode.com/files/ImageMagick.tar.gz
wget http://us3.php.net/get/php-5.4.21.tar.gz/from/cn2.php.net/mirror
wget https://lnamp-web-server.googlecode.com/files/eaccelerator-eaccelerator-42067ac.tar.gz
wget http://nginx.org/download/nginx-1.4.0.tar.gz
更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2013-11/92428p2.htm
相关阅读:
Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm
CentOS 5.9 下编译安装 LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm
RedHat 5.4 下 Web 服务器架构之源码构建 LAMP 环境及应用 PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm
LAMP 源码环境搭建 WEB 服务器 Linux+Apache+MySQL+PHP http://www.linuxidc.com/Linux/2013-05/84882.htm
12 修改 php.ini 增加 memcache,ea 等软件信息
添加 memcache 库的位置:
vim /usr/local/php/php.ini
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525”
extension = “memcache.so”
extension = “pdo_MySQL.so”
extension = “imagick.so”
添加 eaccelerator 库的位置信息:
;eaccelerator
[eaccelerator]
zend_extension=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/eaccelerator.so”
eaccelerator.shm_size=”1″
eaccelerator.cache_dir=”/usr/local/eaccelerator_cache”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
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.keys = “disk_only”
eaccelerator.sessions = “disk_only”
eaccelerator.content = “disk_only”
mkdir -p /usr/local/eaccelerator_cache
chmod 0777 /usr/local/eaccelerator_cache
13:安装 php 扩展库:PDO_MYSQL
tar zxvf 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
ln -s /usr/local/mysql/include/* /usr/local/include/
make && make install
14 : 安装 php 扩展库:ImageMagick
123 tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure && make && make install
15:安装 php 扩展库:imagick
tar zxvf imagick-3.1.2.tgz
cd imagick-3.1.2/
/usr/local/php/bin/phpize
ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagick
./configure –with-php-config=/usr/local/php/bin/php-config
make && make install
16:添加 WWW 用户,为系统运行 nginx 专用用户:
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
mkdir -p /var/log/nginx
chmod +w /var/log/nginx
chown -R www:www /var/log/nginx
mkdir -p /data0/www
chmod +w /data0/www
chown -R www:www /data0/www
17:修改 php-fpm.conf 的配置:
vim /usr/local/php/etc/php-fpm.conf
# 去掉 / 更改 配置文件中的;
pm.max_children = 64
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 1024
user = www
group = www
# 检查语法是否正确
/usr/local/php/sbin/php-fpm -t
NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful
看到上面的信息 证明 php 配置文件正常,可以启动了。
18: 添加环境变量:
echo “export PATH=\$PATH:/usr/local/php/sbin/” >>/etc/profile
echo “export PATH=\$PATH:/usr/local/php/bin/” >>/etc/profile
. /etc/profile
19:安装 nginx 的 pcre
tar -zxvf pcre-8.21.tar.gz
cd pcre-8.21 && ./configure && make && make install
20:编译安装 nginx
tar -zxvf nginx-1.4.0.tar.gz
cd nginx-1.4.0/
./configure –user=www –group=www –prefix=/usr/local/nginx –sbin-path=/usr/local/nginx/sbin/nginx –conf-path=/usr/local/nginx/conf/nginx.conf –with-http_stub_status_module –with-http_ssl_module –with-pcre=/usr/local/src/pcre-8.21 –lock-path=/var/run/nginx.lock –pid-path=/var/run/nginx.pid
make && make install
21:修改 nginx 配置文件
vim /usr/local/nginx/conf/nginx.conf
# 修改一些参数, 别直接替换文件, 这只是一部分
user www;
events {
use epoll;
worker_connections 1024;
}
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;
}
22:写一个 php 的测试文件:phpinfo
cat >>/usr/local/nginx/html/index.php<<EOF
<?php
phpinfo();
?>
EOF
23:添加开机启动:
echo “/usr/local/supper/php/sbin/php-fpm” >> /etc/rc.local
echo “/usr/local/nginx/sbin/nginx” >> /etc/rc.local
echo “/etc/init.d/MySQLd restart” >> /etc/rc.local
24:浏览器访问:
访问之前建议先关闭 selinux,iptables
看到以上信息可以确定我们的 lnmp 环境初步搭建完成。关于优化的事情,待研究之后再次释出。
附件有一个 lnmp 的初始安装脚本,仅在 CentOS 6.4 ×86_64 位下测试成功。其他未经测试,小心使用
更多 Oracle 相关信息见 Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12