700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 生产环境Centos LNMP编译安装nginx-1.6 MySQL-5.6 php-5.5

生产环境Centos LNMP编译安装nginx-1.6 MySQL-5.6 php-5.5

时间:2021-09-18 22:54:00

相关推荐

生产环境Centos LNMP编译安装nginx-1.6 MySQL-5.6 php-5.5

安装版本号:

Centos6.5 64位最小化安装 MySQL-5.6.19 php-5.5.14 nginx-1.6.0

cmake2.8.7 libiconv-1.14 libmcrypt-2.5.8 mhash-0.9.9 zlib-1.2.5 libpng-1.6.2 freetype-2.4.12 jpegsrc.v9 gettext-0.18.1.1 mcrypt-2.6.8 memcache-2.2.7 ImageMagick-6.8.8-9 imagick-3.1.2 pcre-8.35

php模块

pthreads.so,redis.so,map.so,memcache.so,imagick.so,opcache.so,mongo.so

服务重新加载

service nginx reload

service php-fpm reload

service mysqld restart

配置文件路径

nginx: /usr/local/nginx/conf/nginx.conf

php:

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

/usr/local/php/etc/php.ini

mysql:/etc/f

下面开始安装

安装包 下载地址/s/1sXpGj

Centos 6.5 64位CentOS-6.5-x86_64-minimal.iso最小化安装

关闭selinux SELINUX=disabled

shutdown -r now #不重启的话,更新ssh后下一次重启,ssh会启动失败

yum install -y gcc gcc-c++ vim wget lrzsz ntpdate sysstat vim-enhanced patch make flex bison file libtool libtool-libs autoconf libjpeg-devel libpng libpng-devel gd gd-devel freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel nano fonts-chinese gettext-devel gmp-devel pspell-devel unzip libcap apr* automake openssl openssl-devel perl compat* mpfr cpp glibc glibc-devel libgomp libstdc++-devel ppl cloog-ppl keyutils keyutils-libs-devel libcom_err-devel libsepol-devel krb5-devel libXpm* php-common php-gd pcre-devel libmcrypt-devel gd2 gd2-developenldap*

rm -rf /etc/localtime

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

ntpdate 0.asia. ;hwclock -w

cat >>/etc/security/limits.conf<<eof

* soft nproc 65535

* hard nproc 65535

* soft nofile 65535

* hard nofile 65535

eof

ulimit -SHn 65535

mkdir /data

cd /data/ #软件包都放此目录

编译安装MySQL5.6.19

安装cmake2.8.7 跨平台的安装(编译)工具

tar -zxf cmake-2.8.7.tar.gz

cd cmake-2.8.7

./configure

make&& make install

cd ..

编译安装mysql

tar zxf mysql-5.6.19.tar.gz

cd mysql-5.6.19

cmake -DCMAKE_BUILD_TYPE:STRING=Release -DMYSQL_USER=mysql -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

make -j4

make install

复制配置文件:

mv /etc/f /etc/f.bak

cpsupport-files/my-f /etc/f

vim +40 /etc/f

mysql5.6的配置文件可以参考下列几个

./mysql-test/include/f

vim ./mysql-test/include/f

默认的是./support-files/my-f

复制启动脚本 :

初始化数据库

编译安装php-5.5.14

编译安装所需组件

安装libiconv

安装libmcrypt

安装mhash

安装zlib

安装libpng

安装freetype

安装Jpeg

安装gettext

安装mcrypt

编译安装PHP(FastCGI模式)

cp -frp /usr/lib64/libldap* /usr/lib/

ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

tar zxf php-5.5.14.tar.gz

cd php-5.5.14/

./configure--prefix=/usr/local/php --with-fpm-user=www --with-fpm-group=www --with-config-file-path=/usr/local/php/etc --with-openssl --with-curl --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql--with-mysqli=mysqlnd--enable-mbstring=all --with-gd--with-freetype-dir=/usr/local/libs --with-jpeg-dir=/usr/local/libs --with-png-dir=/usr/local/libs --with-zlib-dir=/usr/local/libs --enable-mbstring --enable-sockets --with-iconv-dir=/usr/local/libs --enable-libxml --enable-soap --with-mcrypt=/usr/local/libs --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm--enable-gd-native-ttf --with-mhash --enable-pcntl --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-phar --without-pear --enable-ftp--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-maintainer-zts --disable-rpath --with-gettext --enable-opcache

make ZEND_EXTRA_LIBS='-liconv'

make install

cd ../

sed -i 's/;date\.timezone \=/date\.timezone \= Asia\/Shanghai/g' /usr/local/php/etc/php.ini

sed -i 's/expose_php = On/expose_php = Off/g' /usr/local/php/etc/php.ini

sed -i 's/disable_functions =.*/disable_functions =passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname/g' /usr/local/php/etc/php.ini

编译安装PHP扩展模块

安装pthreads扩展

安装memcache扩展

安装imagick扩展

安装IMAP的PHP扩展

安装phpredis扩展

安装mongo扩展

vim/usr/local/php/etc/php.ini

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-1212/"

extension = "pthreads.so"

extension = "redis.so"

extension = "imap.so"

extension = "memcache.so"

extension = "imagick.so"

extension = "mongo.so"

zend_extension =/usr/local/php/lib/php/extensions/no-debug-zts-1212/opcache.so

opcache.memory_consumption=128

opcache.interned_strings_buffer=8

opcache.max_accelerated_files=4000

opcache.revalidate_freq=60

opcache.fast_shutdown=1

opcache.enable_cli=1

安装Nginx

tar -zxf pcre-8.35.tar.gz

cd pcre-8.35

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

make&&make install

cd ../

groupadd www

useradd -g www www -s /sbin/nologin

tar -xzf nginx-1.6.0.tar.gz

cd nginx-1.6.0/

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre=/data/pcre-8.35 --with-http_realip_module --with-http_image_filter_module

#这里注意--with-pcre=path 是pcre解压的目录,而不是安装后的目录

make

make install

cd ../

wget -c /lnmp/ext/init.d.nginx

cp init.d.nginx /etc/init.d/nginx

chmod +x /etc/init.d/nginx

创建Nginx日志目录

mkdir -p /data/nginx/logs

chmod +w /data/nginx/logs

chown -R www:www /data/nginx/logs

修改nginx配置文件

修改nginx.conf文件:

mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak

vim /usr/local/nginx/conf/nginx.conf

user www www;

worker_processes auto;

error_log /var/log/nginx/nginx_error.log error;

pid /var/run/nginx.pid;

worker_rlimit_nofile 102400;

events {

use epoll;

worker_connections 102400;

multi_accept on;

}

http {

include mime.types;

default_type application/octet-stream;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 8m;

client_header_timeout 10;

client_body_timeout 10;

reset_timedout_connection on;

send_timeout 10;

sendfile on;

tcp_nopush on;

keepalive_timeout 10;

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 256k;

limit_conn_zone $binary_remote_addr zone=addr:5m;

limit_conn addr 100;

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-javascripttext/css application/xml;

gzip_vary on;

gzip_proxied expired no-cache no-store private auth;

gzip_disable "MSIE [1-6]\.";

open_file_cache max=102400 inactive=30s;

open_file_cache_valid 90s;

open_file_cache_min_uses 2;

open_file_cache_errors on;

server_tokens off;

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

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" $http_x_forwarded_for';

log_not_found off;

fastcgi_intercept_errors on;

include /usr/local/nginx/conf/server/*.conf;

}

vim /usr/local/nginx/conf/server/test.conf

server {

listen 80;

server_name ;

index index.php index.html index.htm;

root /var/www/;

access_log /data/log/nginx/test.log access;

error_page 404 = /404.html;

# redirect server error pages to the static page /50x.html

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

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

try_files $uri =404;

# fastcgi_pass 127.0.0.1:9000;

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

fastcgi_index index.php;

include fastcgi.conf;

}

location ~* \.(sql|bak|svn|old)$ {

return 403;

}

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

expires 7d;

}

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

expires 12h;

}

if ( $fastcgi_script_name ~ \..*\/.*php ) {

return 403;

}

#重定向在此添加

}

cp /usr/local/nginx/conf/fastcgi.conf /usr/local/nginx/conf/fcgi.conf

mkdir /var/www/

cat > /var/www/phpinfo.php << eof

<?php

phpinfo();

?>

eof

创建php-fpm配置文件

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

vim /usr/local/php/etc/php-fpm.conf

[global]

pid = /usr/local/php/var/run/php-fpm.pid

error_log = /usr/local/php/var/log/php-fpm.log

log_level = error

[www]

listen = /tmp/php-cgi.sock

;listen = 127.0.0.1:9000

user = www

group = www

listen.mode = 0666

;pm = dynamic

pm = static

pm.max_children = 30

pm.start_servers = 5

pm.min_spare_servers = 5

pm.max_spare_servers = 30

request_terminate_timeout = 60

request_slowlog_timeout = 60s

slowlog = /var/log/php-fpm.log.slow

pm.max_requests = 1024

phpinfo测试页面在附件里面,可以先查看 请把phpinfo().htm.txt改为phpinfo().htm

附件:/data/2364638

本文转自 bbotte 51CTO博客,原文链接:/bbotte/1437062,如需转载请自行联系原作者

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。