lnmp(new)

lnmp搭建


基础包支持

尽量在安装系统时装好

gcc gcc-c++ autoconf automake bison flex freetype freetype-devel fontconfig-devel gettext-devel libjpeg libjpeg-devel libpng libpng-devel libxml2 libxml2-devel libtool libtool-ltdl libtool-ltdl-devel libtiff-devel libXpm-devel libicu libicu-devel libidn libidn-devel libxslt libxslt-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 openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre pcre-devel pam-devel vim-enhanced mysql-devel

http://ftp.gnu.org/pub/gnu/libiconvftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/;http://ncu.dl.sourceforge.net/project/mhash/mhash;http://ncu.dl.sourceforge.net/project/mcrypt/MCrypt

libmcrypt


./configure

make&&make install

/sbin/ldconfig

cd libltdl/

./configure --enable-ltdl-install

make

make install

装完hash后

ln -s /usr/local/lib/libmcrypt.[la|so|so.4|so.4.4.8] /usr/lib/libmcrypt.[la|so|so.4|so.4.4.8]

ln -s /usr/local/lib/libmhash.[a|la|so|so.2|so.2.0.1] /usr/lib/libmhash .[a|la|so|so.2|so.2.0.1]

/sbin/ldconfconfig



1、安装nginx

在安装nginx之前我们需要先安装pcre因为作者的lfs-7.1下没有安装pcre,作者就跟据blfs6.3的文档来安装pcre-7.6.tar.bz2

tar �Cxjvf pcre-7.6.tar.bz2

cd pcre-7.6

patch -Np1 -i ../pcre-7.6-abi_breakage-1.patch&&

patch -Np1 -i../pcre-7.6-security_fix-1.patch &&

./configure --prefix=/usr \

          --docdir=/usr/share/doc/pcre-7.6 \

          --enable-utf8 \

          --enable-pcregrep-libz \

          --enable-pcregrep-libbz2 &&

make


make install


下载nginx-1.3.2.tar.gz /soures目录下

tar �Cxzvf nginx-1.3.2.tar.gz

cd nginx-1.3.2

./configure �Cprefix=/usr/local/nginx

make

make install


/usr/local/nginx/sbin/nginx来运行nginx


2、安装cmake

tar �Cxjvf cmake-2.8.5

cd cmake-2.8.5

./boostarp

make

make install


3、安装mysql-5.5.24

tar �Cxzvf mysql-5.5.24.tar.gz

cd mysql-5.5.24

export PATH=$PATH:/usr/local/bin/cmake

makdir /data

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_unicode_ci \

-DWITH_READLINE=1 \

-DWITH_SSL=system \

-DWITH_EMBEDDED_SERVER=1 \

-DENABLED_LOCAL_INFILE=1 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_DEBUG=0


make


make install


# 复制配置文件
cp support-files/my-medium.cnf  /etc/my.cnf


# 设置权限
chmod +x /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql/data


# 配置开机自启动
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld


# 修改my.cnf配置
vim /etc/my.cnf

# [mysqld] 添加:
datadir=/usr/local/mysql/data
default-storage-engine=MyISAM
log-error =/usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp


# 初始化数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql--datadir=/usr/local/mysql/data &


# 启动MySQL
/usr/local/mysql/bin/mysqld_safe �Cdefaults-file=/etc/my.cnf &

或者:
/etc/init.d/mysql start service mysql start(一般用这个方法启动mysql)


# 测试MySQL是否启动

# 1)查看是否有进程mysql
ps -ef | grep mysql


三、安装php-5.4.4

先安装libevent

tar �Cxzvf libevent-2.0.19.stable.tar.gz

cd libevent-2.0.19.stable

./configure

make

makeinstll


tar �Cxzvf libxml2-2.6.23.tar.gz

cd libxml2

./configure

make

make install


tar �Cxzvf php-5.4.4.tar.gz

cd php-5.4.4.tar.gz

./configure --prefix=/usr/local/php \

--with-mysql=/usr/local/mysql \

--with-openssl \

--enable-fpm \

--with-libevent-dir=/usr/local \

--with-mysqli=/usr/local/mysql/bin/mysql_config\

--with-freetype-dir --with-zlib --with-iconv-dir=/usr/local


make

make install


cpphp.ini-production /usr/local/php/etc/php.ini

cd /data/apps/php5.3.6/etc/

cp php-fpm.conf.default php-fpm.conf


运行/usr/losal/php/sbin/php-fpm


最后修改nginx的配置文件

location ~ \.php$ {

          root           html;


          fastcgi_pass   127.0.0.1:9000;

          fastcgi_index  index.php;

          fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;

          include        fastcgi_params;

      }


Killall nginx

再启动nginx 命令/usr/local/nginx/sbin/nginx



创建一个 testmysql.php 文件,其内容如下:

<?php
$link=MySQL_connect(’MySQL服务器名’,'MySQL用户名’,'密码’);
if(!$link) echo "Error !";
else echo "Ok!";
MySQL_close();
?>


用浏览器打开 http://localhost/testmysql.php 如果看到输出 OK! 就说明配置正常。


你可能感兴趣的:(share,LNMP)