安装LNMP架构
dgdggcghechengchen'g安裝LNMP架構(gòu)
安裝mysql:
1、下載
cd?/usr/local/src? wget?http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-i686-icc-glibc23.tar.gz2、解壓
tar?-zxvf?/usr/local/src/mysql-5.1.40-i686-icc-glibc23.tar.gz3、解壓后移動到/usr/local/mysql
mv?mysql-5.1.40-i686-icc-glibc23.tar.gz???/usr/local/mysql4、建立mysql用戶
useradd?-s?/sbin/nologin?mysql5、初始化數(shù)據(jù)庫
cd?/usr/local/mysql mkdir?-p?/data/mysql?;?chown?-R?mysql:mysql?/data/mysql ./scripts/mysql_install_db?--user=mysql?--datadir=/data/mysql6、拷貝配置文件
cp?support-files/my-large.cnf?/etc/my.cnf7、拷貝啟動腳本,賦予755權(quán)限&創(chuàng)建數(shù)據(jù)目錄
cp?support-files/mysql.server?/etc/init.d/mysqld chmod?755?/etc/init.d/mysqld mkdir?-p?/data/mysql8、修改啟動腳本
vim?/etc/init.d/mysqld把datadir= 后面加上/data/mysql
9、把啟動腳本加入開機啟動項,設(shè)置開機啟動,啟動mysql服務(wù)
chkconfig?--add?mysqld chkconfig?mysqld?on service?mysqld?start10、檢測有否啟動mysql
ps?aux|grep?mysqld安裝php
1、下載
cd?/usr/local/src? wget?http://am1.php.net/distributions/php-5.3.27.tar.gz2、解壓
tar?-zxvf?php-5.3.27.tar.gz3、創(chuàng)建php賬戶
useradd?-s?/sbin/nologin?php-fpm4、配置編譯參數(shù)
cd?php-5.3.27./configure?\ --prefix=/usr/local/php?\ --with-config-file-path=/usr/local/php/etc?\ --enable-fpm?\ --with-fpm-user=php-fpm?\ --with-fpm-group=php-fpm?\ --with-mysql=/usr/local/mysql?\ --with-mysql-sock=/tmp/mysql.sock?\ --with-libxml-dir?\ --with-gd?\ --with-jpeg-dir?\ --with-png-dir?\ --with-freetype-dir?\ --with-iconv-dir?\ --with-zlib-dir?\ --with-mcrypt?\ --enable-soap?\ --enable-gd-native-ttf?\ --enable-ftp?\ --enable-mbstring?\ --enable-exif?\ --disable-ipv6?\ --with-pear?\ --with-curl?\ --with-openssl5、編譯
make6、安裝
make?install7、修改配置文件
cp?php.ini-production???/usr/local/php/etc/php.ini vim?/usr/local/php/etc/php.ini把以下內(nèi)容寫入該文件
[global] pid?=?/usr/local/php/var/run/php-fpm.pid error_log?=?/usr/local/php/var/log/php-fpm.log [www] listen?=?/tmp/php-fcgi.sock user?=?php-fpm group?=?php-fpm pm?=?dynamic pm.max_children?=50 pm.start_servers?=?20 pm.min_spare_servers?=?5 pm.max_spare_servers?=?35 pm.max_requests?=?500 rlimit_files?=?1024保存配置文件后,檢驗配置是否正確
/usr/local/php/sbin/php-fpm?-t8、啟動php-fpm
cp?/usr/local/src/php-5.3.27/sapi/fpm/init.d.php-fpm??/etc/init.d/php-fpm chmod?755?/etc/init.d/php-fpm chkconfig?php-fpm?on service?php-fpm?start9、檢測有否啟動
ps?aux|grep?php-fpm大概有20個進程
?
?
安裝nginx
1、下載
cd?/usr/local/src wget?http://nginx.org/download/nginx-1.4.4.tar.gz2、解壓
tar?-zxvf?nginx-1.4.4.tar.gz3、配置編譯參數(shù)
cd?/nginx-1.4.4 ./configure?\ --prefix=/usr/local/nginx?\ --with-http_realip_module?\ --with-http_sub_module?\ --with-http_gzip_static_module?\ --with-http_stub_status_module??\ --with-pcre4、編譯
make5、安裝nginx
make?install6、編寫nginx啟動腳本,加入系統(tǒng)服務(wù)
vim?/etc/init.d/nginx寫入以下內(nèi)容:
#!/bin/bash #?chkconfig:?-?30?21 #?description:?http?service. #?Source?Function?Library .?/etc/init.d/functions #?Nginx?SettingsNGINX_SBIN="/usr/local/nginx/sbin/nginx" NGINX_CONF="/usr/local/nginx/conf/nginx.conf" NGINX_PID="/usr/local/nginx/logs/nginx.pid" RETVAL=0 prog="Nginx"start()?{echo?-n?$"Starting?$prog:?"mkdir?-p?/dev/shm/nginx_tempdaemon?$NGINX_SBIN?-c?$NGINX_CONFRETVAL=$?echoreturn?$RETVAL }stop()?{echo?-n?$"Stopping?$prog:?"killproc?-p?$NGINX_PID?$NGINX_SBIN?-TERMrm?-rf?/dev/shm/nginx_tempRETVAL=$?echoreturn?$RETVAL }reload(){echo?-n?$"Reloading?$prog:?"killproc?-p?$NGINX_PID?$NGINX_SBIN?-HUPRETVAL=$?echoreturn?$RETVAL }restart(){stopstart }configtest(){$NGINX_SBIN?-c?$NGINX_CONF?-treturn?0 }case?"$1"?instart)start;;stop)stop;;reload)reload;;restart)restart;;configtest)configtest;;*)echo?$"Usage:?$0?{start|stop|reload|restart|configtest}"RETVAL=1 esacexit?$RETVAL保存
chmod?755?/etc/init.d/nginx chkconfig?--add?nginx chkconfig?nginx?on7、更改nginx配置
>?/usr/local/nginx/conf/nginx.conf???#">"?重定向,可用于快速清空文檔。寫入以下內(nèi)容
user?nobody?nobody; worker_processes?2; error_log?/usr/local/nginx/logs/nginx_error.log?crit; pid?/usr/local/nginx/logs/nginx.pid; worker_rlimit_nofile?51200;events {use?epoll;worker_connections?6000; }http {include?mime.types;default_type?application/octet-stream;server_names_hash_bucket_size?3526;server_names_hash_max_size?4096;log_format?combined_realip?'$remote_addr?$http_x_forwarded_for?[$time_local]''$host?"$request_uri"?$status''"$http_referer"?"$http_user_agent"';sendfile?on;tcp_nopush?on;keepalive_timeout?30;client_header_timeout?3m;client_body_timeout?3m;send_timeout?3m;connection_pool_size?256;client_header_buffer_size?1k;large_client_header_buffers?8?4k;request_pool_size?4k;output_buffers?4?32k;postpone_output?1460;client_max_body_size?10m;client_body_buffer_size?256k;client_body_temp_path?/usr/local/nginx/client_body_temp;proxy_temp_path?/usr/local/nginx/proxy_temp;fastcgi_temp_path?/usr/local/nginx/fastcgi_temp;fastcgi_intercept_errors?on;tcp_nodelay?on;gzip?on;gzip_min_length?1k;gzip_buffers?4?8k;gzip_comp_level?5;gzip_http_version?1.1;gzip_types?text/plain?application/x-javascript?text/css?text/htm?application/xml;server {listen?80;server_name?localhost;index?index.html?index.htm?index.php;root?/usr/local/nginx/html;location?~?\.php$?{include?fastcgi_params;fastcgi_pass?unix:/tmp/php-fcgi.sock;fastcgi_index?index.php;fastcgi_param?SCRIPT_FILENAME?/usr/local/nginx/html$fastcgi_script_name;}}}保存
/usr/local/nginx/sbin/nginx?-t??#檢測配置文件是否正確8、啟動
service?nginx?start9、檢測有否啟動
ps?aux|grep?nginx10、測試是否解析php文件
vim?/usr/local/nginx/html/2.php寫入
<?php echo?“abcABC123一二三”; ?>測試
curl?localhost/2.php轉(zhuǎn)載于:https://blog.51cto.com/12117863/1878345
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
- 上一篇: [转载]Google Guava官方教程
- 下一篇: sendmail邮件服务搭建详细解