centos-最小安装系统下快速搭建环境步骤分享-6.3

教程大全 2026-01-08 13:56:05 浏览

1,初始化系统环境 完成系统根新,gcc编译环境,php安装依赖,系统内核优化

复制代码 代码如下:

lokkit --disabled --selinux=disabledyum update -yyum install -y telnet wget rsync subversion patchyum install -y system-config-network-tuiyum install -y bind-utilsyum install -y vim-enhancedyum install gcc gcc-c++ make automake autoconf -yyum install curl-devel libmcrypt-devel gd-devel libjpeg-devel libpng-devel libXpm-devel libxml2-devel libxslt-devel mhash-devel openssl-devel -ycat >> /etc/sysctl.conf <

net.ipv4.ip_local_port_range = 1024 65500net.core.netdev_max_backlog = 262144net.ipv4.tcp_syncookies = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_fin_timeout = 60net.ipv4.tcp_keepalive_time = 30net.ipv4.tcp_max_syn_backlog = 8192net.ipv4.tcp_max_tw_buckets = 4096EOF

2,配置ntp服务

复制代码 代码如下:yum install ntp -ycp /etc/ntp.conf /etc/ntp.conf.originalvim /etc/ntp.conf < /dev/null 2>&1:22,24s/^/#/:25,25s/^/\rserver 210.72.145.44\rserver 133.100.11.8\r/:wqVIMservice ntpd sTartchkconfig ntpd on

3,安装nginx

复制代码 代码如下:

groupadd -r wwwuseradd -r -g www -s /bin/false -M www

cat > /etc/yum.repos.d/nginx.repo <

yum search nginxyum install nginxchkconfig nginx onservice nginx start

ps:需要修改nginx使用用户为www,默认为nginx4,安装mysql

复制代码 代码如下:wgethttp://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.5/MySQL-client-5.5.25a-1.linux2.6.x86_64.rpmwgethttp://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.5/MySQL-shared-5.5.25a-1.el6.x86_64.rpmwget-y localinstall MySQL-*

5,安装php 在这有根据实际情况可以选择不同的版本。1>php-5.2.17

复制代码 代码如下:

wgethttp://museum.php.net/php5/php-5.2.17.tar.gz

tar zxvf php-5.2.17.tar.gzgzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1

cd php-5.2.17

./configure --prefix=/srv/php-5.2.17 \--with-config-file-path=/srv/php-5.2.17/etc \--with-config-file-scan-dir=/srv/php-5.2.17/etc/conf.d \--with-libdir=lib64 \--enable-fastcgi \--enable-fpm \--with-pear \--with-curl \--with-gd \--with-jpeg-dir \--with-png-dir \--with-freetype-dir \--with-zlib-dir \--with-iconv \--with-mcrypt \--with-mysql \--with-pdo-mysql \--with-mysql-sock=/var/lib/mysql/mysql.sock \--with-openssl=shared \--with-mhash=shared \--with-sqlite=shared \--with-pdo-sqlite=shared \--with-xsl=shared \--with-pear \--enable-sockets \--enable-soap \--enable-mbstring \--enable-magic-quotes \--enable-inline-optimization \--enable-gd-native-ttf \--enable-zip \--enable-xml \--enable-ftp \--enable-bcmath \--enable-calendar \--enable-sqlite-utf8 \--enable-shmop \--enable-dba \--enable-wddx \--enable-sysvsem \--enable-sysvshm \--enable-sysvmsg \--disable-debug

make && make install

cp php.ini-recommended /srv/php-5.2.17/etc/php.inicp /srv/php-5.2.17/etc/php-fpm.conf /srv/php-5.2.17/etc/php-fpm.conf.original

2>php-5.3.10

复制代码 代码如下:

wgetxf php-5.3.10.tar.gzcd php-5.3.10./configure --prefix=/srv/php-5.3.10 \--with-config-file-path=/srv/php-5.3.10 /etc \--with-config-file-scan-dir=/srv/php-5.3.10 /etc/conf.d \--with-libdir=lib64 \--enable-fastcgi \--enable-fpm \--with-pear \--with-curl \--with-gd \--with-jpeg-dir \--with-png-dir \--with-freetype-dir \--with-zlib-dir \--with-iconv \--with-mcrypt \--with-mysql \--with-pdo-mysql \--with-mysql-sock=/var/lib/mysql/mysql.sock \--with-openssl=shared \--with-mhash=shared \--with-sqlite=shared \--with-pdo-sqlite=shared \--with-xsl=shared \--without-pear \--enable-sockets \--enable-soap \--enable-mbstring \--enable-magic-quotes \--enable-inline-optimization \--enable-gd-native-ttf \--enable-zip \--enable-xml \--enable-ftp \--enable-bcmath \--enable-calendar \--enable-sqlite-utf8 \--enable-shmop \--enable-dba \--enable-wddx \--enable-sysvsem \--enable-sysvshm \--enable-sysvmsg \--disable-debug

make && make install

php优化拿php-5.3.10为列

复制代码 代码如下:cp php.ini-production /srv/php-5.3.10/etc/php.inicp /srv/php-5.3.10/etc/php-fpm.conf.default /srv/php-5.3.10/etc/php-fpm.confvim /srv/php-5.3.10/etc/php.ini < 附一个进过优化的nginx配置文件

复制代码 代码如下:

user www www;worker_processes 8;error_log /www/log/nginx_error.log crit;pid /usr/local/nginx/nginx.pid;worker_rlimit_nofile 204800;

events{use epoll;worker_connections 204800;}

http{include mime.types;default_type application/octet-Stream;

server_tokens off;

charset utf-8;

server_names_hash_bucket_size 128;client_header_buffer_size 2k;large_client_header_buffers 4 4k;client_max_body_size 8m;

sendfile on;tcp_nopush on;

keepalive_timeout 60;

最小系统下快速搭建环境步骤分享

fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2keys_zone=TEST:10minactive=5m;fastcgi_connect_timeout 300;fastcgi_send_timeout 300;fastcgi_read_timeout 300;fastcgi_buffer_size 16k;fastcgi_buffers 16 16k;fastcgi_busy_buffers_size 16k;fastcgi_temp_file_write_size 16k;fastcgi_cache TEST;fastcgi_cache_valid 200 302 1h;fastcgi_cache_valid 301 1d;fastcgi_cache_valid Any 1m;fastcgi_cache_min_uses 1;fastcgi_cache_use_stale error timeout invalid_header http_500;open_file_cache max=204800 inactive=20s;open_file_cache_min_uses 1;open_file_cache_valid 30s;

tcp_nodelay on;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;

server{listen 80;server_name www.myhack58.com;index index.php index.htm;root /www/html/;

location /status{stub_status on;}

location ~ .*\.(php|php5)?${fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fcgi.conf;}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)${expires 7d;}

location ~ .*\.(js|css)${expires 1h;}location ~ .*\.(html|htm){expires 15m;}location ~ .*\.log${deny all;}

log_format access '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" $http_x_forwarded_for';access_log /www/log/access.log access;}}

本文版权声明本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请联系本站客服,一经查实,本站将立刻删除。

发表评论

热门推荐