创建screen会话,执行
screen -s lemp
如果screen命令不存在,执行
apt-get install screen
如果网络掉线,重新连接,执行
screen -r lemp
修改源文件:在原有源的基础上加入新的源
vi /etc/apt/sources.list
在文件底部加入如下内容:
deb http://packages.dotdeb.org squeeze all deb-src http://packages.dotdeb.org squeeze all
增加新加源的证书
wget http://www.dotdeb.org/dotdeb.gpg cat dotdeb.gpg | apt-key add -
删除不用组件
apt-get --purge -y remove apache2-* bind9-* xinetd samba-*
更新源数据
apt-get update apt-get upgrade
安装nginx
apt-get install nginx
配置nginx
mkdir -p /etc/nginx/vhost mkdir -p /home/www/default mkdir -p /home/log rm -fr /etc/nginx/conf.d rm -fr /etc/nginx/sites-available rm -fr /etc/nginx/sites-enabled rm -f /etc/nginx/nginx.conf
vi /etc/nginx/nginx.conf
user www-data; worker_processes 1; error_log /home/log/nginx.log crit; pid /var/run/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } 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 50m; 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 256k; 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 log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; include vhost/*.conf; }
vi /etc/nginx/fcgi.conf
fastcgi_param gateway_interface cgi/1.1; fastcgi_param server_software nginx/$nginx_version; 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;
vi /etc/nginx/vhost/default.conf
server { listen 80; server_name _; rewrite ^(.*) http://koryi.com permanent; } server { listen 80; server_name 198.23.243.205; index index.html index.htm index.php; root /home/www/default; location ~ .*.(php|php5)?$ { try_files $uri = 404; 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 12h; } #error_page 404 /404.html; #error_page 500 502 503 504 /50x.html; #location = /50x.html { # root /var/www/nginx-default; #} access_log /home/log/default.log access; }
启动nginx
/etc/init.d/nginx start
测试html:vi /home/www/default/index.html
domain sale
安装php
apt-get install php5-cli php5-cgi php5-mcrypt php5-curl php5-gd build-essential wget psmisc spawn-fcgi
设置php.ini
sed -i 's#output_buffering = off#output_buffering = on#' /etc/php5/cgi/php.ini sed -i 's/post_max_size = 8m/post_max_size = 50m/g' /etc/php5/cgi/php.ini sed -i 's/upload_max_filesize = 2m/upload_max_filesize = 50m/g' /etc/php5/cgi/php.ini sed -i 's/;date.timezone =/date.timezone = prc/g' /etc/php5/cgi/php.ini sed -i 's/short_open_tag = off/short_open_tag = on/g' /etc/php5/cgi/php.ini sed -i 's/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php5/cgi/php.ini sed -i 's/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g' /etc/php5/cgi/php.ini sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php5/cgi/php.ini
启动php
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -c 6 -u www-data -g www-data -f /usr/bin/php5-cgi
测试php:vi /home/www/default/p.php
安装mysql
apt-get install mysql-server php5-mysql
安全设置
mysql_secure_installation
如果要重设密码,执行
dpkg-reconfigure mysql-server-5.0
重启php
killall -9 php5-cgi /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -c 6 -u www-data -g www-data -f /usr/bin/php5-cgi
安装phpmyadmin
apt-get install phpmyadmin
注意会提示你选择apache或者lighttpd,我们用的是nginx,所以这里按esc退出选择,然后会提示你输入一次mysql数据库密码,两次phpmyadmin密码
安装完成后,phpmyadmin所有代码文件都默认位于/usr/share/phpmyadmin路径下,假设我们的web主路径位于/home/www/default/phpmyadmin下,接下来做个链接就可以了:
ln -s /usr/share/phpmyadmin /home/www/default/phpmyadmin