uykjgfh 发表于 2015-7-31 09:15:01

LNMP源码安装

1、nginx安装下载nginx的源码包cd /usr/src   #一般软件的源码包都放在这个目录下wget http://nginx.org/download/nginx-1.0.13.tar.gz#下载nginx会有几个依赖包,在这里我们提前安装yuminstall zlib-devel pcre-devel openssl-devel –y首先解压nginx的源码包tar -zxvf nginx-1.0.13.tar.gz编译./configure --prefix=/usr/local/nginx\   # 指定安装目录为/usr/local/nginx--with-openssl=/usr/include/openssl\# 启用ssl--with-pcre\                        # 启用正规表达式--with-http_stub_status_module      # 安装可以查看nginx状态的程序预编译完成以后Make    make install完成以后,检查nginx是否安装成功并启动ls /usr/local/nginx   #查看安装目录/usr/local/nginx/sbin/nginx   #启动nginx可以通过查看端口判断nginx是否启动,端口为80netstat-natlp |grep 80然后通过ip访问!2、mysql安装下载mysql源码包wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.95.tar.gz安装依赖包yuminstall ncurses-devel-y创建mysql用户useradd -M -s /sbin/nologin mysql# -M不创建home目录,-s指定shell为不登录然后进行安装tar -zxvf mysql-5.0.95.tar.gzcd mysql-5.0.95./configure --prefix=/usr/local/mysql \--without-debug \                           # 取消调试模式提高性能--with-extra-charsets=utf8,gbk \            # 仅仅指定需要的默认字符集提高性能--enable-assembler \                        # 使用汇编模式提高性能--with-mysqld-ldflags=-all-static \         # 以静态方式编译提高性能--with-client-ldflags=-all-static \--with-unix-socket-path=/tmp/mysql.sock \   # 使用unix socket提高性能--with-sslmakemake install安装完成后复制配置文件和启动脚本:cp support-files/my-medium.cnf /etc/my.cnf         # 复制配置文件cp support-files/mysql.server /etc/init.d/mysqld   # 复制启动脚本chmod +x /etc/init.d/mysqld         # 给启动脚本执行权限为了以后方便我们为所有的二进制可执行文件和动态链接库文件做一个软连接:ln -s /usr/local/mysql/bin/* /usr/local/bin/      # 为可执行的二进制文件做软连接ln -s /usr/local/mysql/lib/mysql/lib* /usr/lib/# 为动态链接库做一个软连接然后我们初始化数据库:mysql_install_db--user=mysql   #用mysql用户安装数据库为了mysql能正常使用我们需要更改一下mysql安装目录和mysql的数据库目录的属主和属组chown –R root:mysql /usr/local/mysql#更改安装目录属主为root,组为mysqlchown-R mysql:mysql /usr/local/mysql/var #更改数据库目录属主和组为mysql配置完成启动mysql/etc/init.d/mysqld restart连接数据库的命令/usr/local/mysql/bin/mysql3、安装PHP首先来安装几个源码的依赖包wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2和http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2# 这两个包安装完成后要把动态链接库做一个软连接到/usr/lib,以为接下来的mcrypt依赖于这两个包ln -s /usr/local/lib/libmcrypt*/usr/libln -s /usr/local/lib/libmhash.*/usr/lib/ln -s /usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config###########################################################wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz报错:configure: error: *** libmcrypt was not found 执行以下命令
export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH
下载PHP源码包
wget http://cn2.php.net/get/php-5.4.0.tar.bz2
安装依赖包
yum install libxml2libxml2-devellibpnglibpng-devel curl-devel
openldapopenldap-devel-y
iconv函数库能够完成各种字符集间的转换,是php编程中不可缺少的基础函数库。
1、下载libiconv函数库 http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz;
2、解压缩tar -zxvf libiconv-1.9.2.tar.gz;
3、安装libiconv
       #configure --prefix=/usr/local/iconv
       #make
       #make installphp安装./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc -enable-zip --enable-soap --with-config-file-path=/usr/local/php/etc --with-iconv=/usr/local/ makemake install到这里整个LNMP已经安装完成.下面我们就配置php和nginx能运行php网站:
首先为php创建配置文件:cp php.ini-production /usr/local/php/etc/php.ini                               # 如果是开发就复制php.ini-developmentcp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confln -s /usr/local/php/bin/php /usr/bin/配置php-fpm,编辑php-fpm.confvi /usr/local/php/etc/php-fpm.conf找到listen那一行,修改成如下内容:listen = /var/run/php-fpm/php-fpm.sock   # 使用unix socket启动php-fpmmkdir /var/run/php-fpm启动:/usr/local/php/sbin/php-fpm然后配置nginx,编辑nginx配置文件vi /usr/local/nginx/conf/nginx.conf修改nginx配置文件支持php:server {      listen       80;      server_namelocalhost;      #charset koi8-r;      #access_loglogs/host.access.logmain;      location / {            root   html;            indexindex.php index.html index.htm;         # 添加index.php的首页文件      }      # 添加下面内容      location ~ \.php$ {            fastcgi_pass      unix:/var/run/php-fpm/php-fpm.sock;            fastcgi_index       index.php;            fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;            include fastcgi_params;            include fastcgi.conf;      }修改完毕后保存退出重启nginx:pkill -9 nignx/usr/local/nginx/sbin/nginx然后在/usr/local/nginx/html下创建index.php,vi /usr/local/nginx/html/index.php添加下面内容:<?phpphpinfo();?>报错解决:安装php时出现make: *** 错误 1解决方法1、如果不需要mcrypt,配置(configure) php 时去掉该选项
2、如果需要mcrypt,那么需要安装libltdl,方法有
libltdl在libmcrypt软件包中就有ldconfig –p |grep ltdlcd /software/libmcrypt-2.5.8/libltdl./configure –enable-ltdl-installMakeMake install或者cd /usr/share/libtool/libltdl./configure –prefix=/usrMake   ;
页: [1]
查看完整版本: LNMP源码安装