LNMP安裝配置

centos下安裝LNMPjavascript

臨時關閉selinux php

[root@test-web ~]# getenforce css

Enforcinghtml

[root@test-web ~]# setenforce 0java

[root@test-web ~]# getenforce node


關於yum安裝報錯以下解決辦法mysql

warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEYlinux

執行以下命令nginx

[root@test-web /]# rpm --import /etc/pki/rpm-gpg/RPM*c++


1.安裝mysql-5.6.14

tar zxvf mysql-5.6.14.tar.gz

yum -y install cmake ncurses  ncurses-devel gcc gcc-c++ make

[root@test-web src]# mkdir -p /usr/local/mysql

[root@test-web src]# groupadd mysql

[root@test-web src]# useradd -g mysql -s /sbin/nologin mysql

[root@test-web src]# chown -R mysql.mysql /usr/local/mysql

[root@test-web src]# id mysql

uid=500(mysql) gid=500(mysql) groups=500(mysql)

cd mysql-5.6.14

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/data/mysql \

-DSYSCONFDIR=/usr/local/mysql \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci  \

-DEXTRA_CHARSETS=all \

-DENABLED_LOCAL_INFILE=1

make

make install


啓動腳本

[root@test-web mysql-5.6.14]# cp support-files/mysql.server /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld


初始化mysql

/usr/local/mysql/scripts/mysql_install_db  --basedir=/usr/local/mysql/ --datadir=/data/mysql --user=mysql

啓動mysql

/usr/local/mysql/bin/mysqld_safe &


加入環境變量

PATH=$PATH:/usr/local/mysql/bin/


修改mysql配置文件

報錯

#啓動下面報錯,然來是改了這個參數後須要關閉MYSQLSQL刪除ib_logfile0, ib_logfile1這些文件,再啓動MYSQL。

2013-12-01 02:04:04 28604 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 4864 pages (rounded down to MB) than specified in the .cnf file: initial 16384 pages, max 0 (relevant if non-zero) pages!

2013-12-01 02:04:04 28604 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!

2013-12-01 02:04:04 28604 [ERROR] Plugin 'InnoDB' init function returned error.

2013-12-01 02:04:04 28604 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.


#下面報錯我把table_cache=614這一項禁用

2013-12-01 02:04:04 28604 [ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'table_cache=614'  

2013-12-01 02:04:04 28604 [ERROR] Aborting



2.安裝nginx

yum install openssl*

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 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 make

yum -y install gd gd2 gd-devel gd2-devel

[root@test-web src]# groupadd www

[root@test-web src]# useradd -g www -s /sbin/nologin www

[root@test-web src]# id www

uid=501(www) gid=501(www) groups=501(www)


root@test-web pcre-8.32]# tar zxvf pcre-8.32.tar.gz

[root@test-web pcre-8.32]# cd pcre-8.32

[root@test-web pcre-8.32]# ./configure --prefix=/usr/local/pcre

[root@test-web pcre-8.32]# make && make install



# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-pcre=/usr/src/pcre-8.20 --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_p_w_picpath_filter_module

安裝nginx提示錯誤

checking for GD library ... not found

checking for GD library in /usr/local/ ... not found

checking for GD library in /usr/pkg/ ... not found

checking for GD library in /opt/local/ ... not found


[root@test-web nginx-1.5.6]# rpm -qa|grep gd

gdbm-1.8.0-36.el6.i686

eggdbus-0.6-3.el6.i686

gd-2.0.35-10.el6.i686

gdb-7.1-29.el6.i686

應該是缺乏gd-devel-2.0.35-10.el6.i686.rpm 在網上找了很長時間都沒有找到這個包

後來下載源碼包後不報錯


[root@open2 nginx-1.5.6]# /usr/local/app/lbnginx/sbin/nginx -s reload

nginx: [error] invalid PID number "" in "/usr/local/app/lbnginx/logs/nginx.pid"

解決辦法


[root@open2 nginx-1.5.6]# /usr/local/app/lbnginx/sbin/nginx -c /usr/local/app/lbnginx/conf/nginx.conf

[root@open2 nginx-1.5.6]# /usr/local/app/lbnginx/sbin/nginx -s reload



報錯

[root@open-source conf]# /usr/local/app/nginx/sbin/nginx

/usr/local/app/nginx/sbin/nginx: error while loading shared libraries: libgd.so.2: cannot open shared object file: Error 40

解決辦法

在/etc/ld.so.conf文件中添加文件所在的目錄就行,試了一下,直接vi打開/etc/ld.so.conf文件,添加「/usr/local/lib」

ldconfig


查安裝的lib庫,看nginx啊 ldd $(which /usr/local/nginx/sbin/nginx)

後來編譯是報pcre錯誤,檢查一遍安裝對了,後來去google去查了下原來不是指定安裝目錄,要指定源代碼目錄,就是你解壓的目錄

mkdir -p /var/logs/nginx/ #錯誤日誌目錄

mkdir -p /var/run/nginx/ #pid存放目錄

mkdir -p /data/logs/ #access 日誌目錄

mkdir -p /data/www/ #站點目錄


nginx.conf

[root@test-web conf]# cat nginx.conf

user  www www;


worker_processes 2;


error_log  /var/logs/nginx/nginx_error.log  crit;


pid        /var/run/nginx/nginx.pid;


#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 65535;


events

{

 use epoll;

 worker_connections 65535;

}


http

{

 include       mime.types;

 default_type  application/octet-stream;


 #charset  gb2312;


 server_names_hash_bucket_size 128;

 client_header_buffer_size 32k;

 large_client_header_buffers 4 32k;

 client_max_body_size 8m;


 sendfile on;

 tcp_nopush     on;


 keepalive_timeout 60;


 tcp_nodelay on;


 fastcgi_connect_timeout 300;

 fastcgi_send_timeout 300;

 fastcgi_read_timeout 300;

 fastcgi_buffer_size 64k;

 fastcgi_buffers 4 64k;

 fastcgi_busy_buffers_size 128k;

 fastcgi_temp_file_write_size 128k;


 gzip on;

 gzip_min_length  1k;

 gzip_buffers     4 16k;

 gzip_http_version 1.0;

 gzip_comp_level 2;

 gzip_types       text/plain application/x-javascript text/css application/xml;

 gzip_vary on;


 #limit_zone  crawler  $binary_remote_addr  10m;


   log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '

             '$status $body_bytes_sent "$http_referer" '

             '"$http_user_agent" $http_x_forwarded_for';

 server

 {

   listen       80;

   server_name  blog.mytest.com;

   index index.html index.htm index.php;

   root  /data/www/blog;


   #limit_conn   crawler  20;    


   location ~ .*\.(php|php5)?$

   {      

     #fastcgi_pass  unix:/tmp/php-cgi.sock;

     fastcgi_pass  127.0.0.1:9000;

     fastcgi_index index.php;

     include fcgi.conf;

   }


   location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

   {

     expires      30d;

   }


   location ~ .*\.(js|css)?$

   {

     expires      1h;

   }    


   access_log  /data/logs/access.log  access;

     }


   log_format  wwwlogs  '$remote_addr - $remote_user [$time_local] "$request" '

              '$status $body_bytes_sent "$http_referer" '

              '"$http_user_agent" $http_x_forwarded_for';

 server

 {

   listen       80;

   server_name  www.mytest.com;

   index index.html index.htm index.php;

   root  /data/htdocs/www;


   location ~ .*\.(php|php5)?$

   {      

     #fastcgi_pass  unix:/tmp/php-cgi.sock;

     fastcgi_pass  127.0.0.1:9000;

     fastcgi_index index.php;

     include fcgi.conf;

   }


   access_log  /data/logs/wwwlogs.log  wwwlogs;

 }


 server

 {

   listen  80;

   server_name  status.blog.mytest.com;


   location / {

   stub_status on;

   access_log   off;

   }

 }

}


粘貼張宴博客的配置文件

報錯以下

root@test-web conf]# /usr/local/nginx/sbin/nginx -s reload

nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/nginx/conf/nginx.conf:84

nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/nginx/conf/nginx.conf:105

google了一下原來是版本的問題,我安裝的是nginx-1.5.6得把日誌切割放到server的外面


[root@test-web conf]# cat fcgi.conf

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;

fastcgi_param  SERVER_SOFTWARE    nginx;


fastcgi_param  QUERY_STRING       $query_string;

fastcgi_param  REQUEST_METHOD     $request_method;

fastcgi_param  CONTENT_TYPE       $content_type;

fastcgi_param  CONTENT_LENGTH     $content_length;


fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

fastcgi_param  REQUEST_URI        $request_uri;

fastcgi_param  DOCUMENT_URI       $document_uri;

fastcgi_param  DOCUMENT_ROOT      $document_root;

fastcgi_param  SERVER_PROTOCOL    $server_protocol;


fastcgi_param  REMOTE_ADDR        $remote_addr;

fastcgi_param  REMOTE_PORT        $remote_port;

fastcgi_param  SERVER_ADDR        $server_addr;

fastcgi_param  SERVER_PORT        $server_port;

fastcgi_param  SERVER_NAME        $server_name;


# PHP only, required if PHP was built with --enable-force-cgi-redirect

fastcgi_param  REDIRECT_STATUS    200;





3.安裝PHP

3.1安裝依賴庫

mkdir -p /usr/local/libs/

wget http://www.ijg.org/files/jpegsrc.v9.tar.gz    

tar zxvf jpegsrc.v9.tar.gz

cd jpeg-9/

./configure --prefix=/usr/local/libs --enable-shared --enable-static --prefix=/usr/local/libs

make

make install

cd ../


wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.2.tar.gz

tar zxvf libpng-1.6.2.tar.gz

cd libpng-1.6.2/

./configure --prefix=/usr/local/libs

make

make install

cd ../


wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.12.tar.gz

tar zxvf freetype-2.4.12.tar.gz

cd freetype-2.4.12/

./configure --prefix=/usr/local/libs

make

make install

cd ../



wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?big_mirror=0"

wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?big_mirror=0"

wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?big_mirror=0"



tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8/

./configure --prefix=/usr/local/libs

make

make install

cd libltdl/

./configure --prefix=/usr/local/libs --enable-ltdl-install

make

make install

cd ../../



tar zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9/

./configure --prefix=/usr/local/libs

make

make install

cd ../



vi /etc/ld.so.conf


添加:

/usr/local/libs/lib


而後:

ldconfig


tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

export LDFLAGS="-L/usr/local/libs/lib -L/usr/lib"

export CFLAGS="-I/usr/local/libs/include -I/usr/include"

touch malloc.h

./configure --prefix=/usr/local/libs --with-libmcrypt-prefix=/usr/local/libs

make

make install

cd ../


安裝php

tar zxvf php-5.5.5.tar.gz

cd php-5.5.5

export LIBS="-lm -ltermcap -lresolv"

export DYLD_LIBRARY_PATH="/usr/local/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"

export LD_LIBRARY_PATH="/usr/local/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"


./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 --with-freetype-dir=/usr/local/libs \

--with-jpeg-dir=/usr/local/libs --with-png-dir=/usr/local/libs --with-zlib --with-libxml-dir=/usr --enable-xml \

--disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl \

--enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/usr/local/libs --with-gd --enable-gd-native-ttf \

--with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache \

--with-pdo-mysql --enable-maintainer-zts --enable-fpm


make && make install


[root@test-web src]# mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp php.ini-development /usr/local/php/etc/php.ini


[root@open-source etc]# vim /usr/local/php/etc/php.ini

date.timezone = Asia/Shangha

max_execution_time = 300

post_max_size = 32M

max_input_time=300

memory_limit = 128M

mbstring.func_overload = 2



啓動php-fpm

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


安裝php擴展

eaccelerator 不兼容php5.5

相關文章
相關標籤/搜索