EShop网上商城项目(一)
一、项目简介
该项目由Irving提出,有Irving、wang.cheng、laoda、syh0307 四人开发,开发环境:LNMP。
该项目软件为四个程序员的兄弟连二期项目,不做任何商业用途。
码云:https://git.oschina.net/include_yx/lamp.git || git@git.oschina.net:include_yx/lamp.git
二、搭建服务器环境
1. 服务器选择:LNMP(Linux+Nginx+MySQL+PHP)
2.Linux安装:CentOS-6.3-i386-bin-DVD1.iso
3.LNMP集成环境安装
1 [root@iZ287mhoky1Z ~]# wget -c http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz && tar zxf lnmp1.2-full.tar.gz && cd lnmp1.2-full && ./install.sh lnmp 2 --2016-08-11 16:13:45-- http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz 3 Resolving soft.vpser.net... 50.93.201.152, 2600:3c01::f03c:91ff:fe96:d57a 4 Connecting to soft.vpser.net|50.93.201.152|:80... connected. 5 HTTP request sent, awaiting response... 200 OK 6 Length: 326745420 (312M) [application/octet-stream] 7 Saving to: “lnmp1.2-full.tar.gz” 8 9 100%[======================================================================================>] 326,745,420 2.05M/s in 2m 10s 10 11 2016-08-11 16:15:56 (2.39 MB/s) - “lnmp1.2-full.tar.gz” saved [326745420/326745420] 12 +------------------------------------------------------------------------+ 13 | LNMP V1.2 for CentOS Linux Server, Written by Licess | 14 +------------------------------------------------------------------------+ 15 | A tool to auto-compile & install LNMP/LNMPA/LAMP on Linux | 16 +------------------------------------------------------------------------+ 17 | For more information please visit http://www.lnmp.org | 18 +------------------------------------------------------------------------+ 19 Please setup root password of MySQL.(Default password: root) 20 Please enter: ****** 21 MySQL root password:****** 22 =========================== 23 Do you want to enable or disable the InnoDB Storage Engine? 24 Default enable,Enter your choice [Y/n]: y 25 You will enable the InnoDB Storage Engine 26 =========================== 27 You have 5 options for your DataBase install. 28 1: Install MySQL 5.1.73 29 2: Install MySQL 5.5.42 (Default) 30 3: Install MySQL 5.6.23 31 4: Install MariaDB 5.5.42 32 5: Install MariaDB 10.0.17 33 Enter your choice (1, 2, 3, 4 or 5): 3 34 You will Install MySQL 5.6.23 35 =========================== 36 You have 5 options for your PHP install. 37 1: Install PHP 5.2.17 38 2: Install PHP 5.3.29 39 3: Install PHP 5.4.41 (Default) 40 4: Install PHP 5.5.25 41 5: Install PHP 5.6.9 42 Enter your choice (1, 2, 3, 4 or 5): 5 43 You will install PHP 5.6.9 44 =========================== 45 You have 3 options for your Memory Allocator install. 46 1: Don't install Memory Allocator. (Default) 47 2: Install Jemalloc 48 3: Install TCMalloc 49 Enter your choice (1, 2 or 3): 1 50 You will install not install Memory Allocator. 51 . 52 . 53 . 54 ============================== Check install ============================== 55 Checking ... 56 Nginx: OK 57 MySQL: OK 58 PHP: OK 59 PHP-FPM: OK 60 +------------------------------------------------------------------------+ 61 | LNMP V1.2 for CentOS Linux Server, Written by Licess | 62 +------------------------------------------------------------------------+ 63 | For more information please visit http://www.lnmp.org | 64 +------------------------------------------------------------------------+ 65 | lnmp status manage: lnmp {start|stop|reload|restart|kill|status} | 66 +------------------------------------------------------------------------+ 67 | phpMyAdmin: http://IP/phpmyadmin/ | 68 | phpinfo: http://IP/phpinfo.php | 69 | Prober: http://IP/p.php | 70 +------------------------------------------------------------------------+ 71 | Add VirtualHost: lnmp vhost add | 72 +------------------------------------------------------------------------+ 73 | Default directory: /home/wwwroot/default | 74 +------------------------------------------------------------------------+ 75 | MySQL/MariaDB root password: 123456 | 76 +------------------------------------------------------------------------+ 77 +-------------------------------------------+ 78 | Manager for LNMP, Written by Licess | 79 +-------------------------------------------+ 80 | http://lnmp.org | 81 +-------------------------------------------+ 82 nginx (pid 14442 14440) is running... 83 php-fpm is runing! 84 SUCCESS! MySQL running (14859) 85 Active Internet connections (only servers) 86 Proto Recv-Q Send-Q Local Address Foreign Address State 87 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 88 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 89 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 90 Install lnmp V1.2 completed! enjoy it.
lnmp1.2-full.tar.gz
Linux => CentOS-6.3
Nginx => Nginx1.2
MySQL => MySQL5.6.23
PHP => PHP5.6.8
3.1 相关软件安装目录:
Nginx 目录: /usr/local/nginx/
MySQL 目录 : /usr/local/mysql/
MySQL数据库所在目录:/usr/local/mysql/var/
PHP目录 : /usr/local/php/
PHPMyAdmin目录 : /home/wwwroot/default/phpmyadmin/
默认网站目录 : /home/wwwroot/default/
Nginx日志目录:/home/wwwlogs/
3.2 LNMP相关配置文件位置:
Nginx主配置文件:/usr/local/nginx/conf/nginx.conf
MySQL配置文件:/etc/my.cnf
PHP配置文件:/usr/local/php/etc/php.ini
php-fpm配置文件:/usr/local/php/etc/php-fpm.conf
3.3 LNMP状态管理命令:
LNMP 状态管理: lnmp {start|stop|reload|restart|kill|status}
LNMP 各个程序状态管理: lnmp {nginx|mysql|mariadb|php-fpm|pureftpd} {start|stop|reload|restart|kill|status}
3.4 Nginx配置文件:
#vi /usr/local/nginx/conf/nginx.conf
1 user www www; 2 3 worker_processes auto; 4 #启动进程 5 6 error_log /home/wwwlogs/nginx_error.log crit; 7 #错误日志 8 9 pid /usr/local/nginx/logs/nginx.pid; 10 #主进程PID保存文件 11 12 #Specifies the value for maximum file descriptors that can be opened by this process.? 13 worker_rlimit_nofile 51200; 14 #文件描述符数量 15 16 events 17 { 18 use epoll; 19 #网络I/O模型,建议linux使用epoll,FreeBSD使用kqueue 20 #epoll是多路复用IO(I/O Multiplexing)中的一种方式,但是仅用于linux2.6以 上内 核,可以大大提高nginx的性能 21 worker_connections 51200; 22 #单个工作进程最大允许连接数 23 multi_accept on; 24 25 } 26 27 http 28 #整体环境配置 29 { 30 include mime.types; 31 default_type application/octet-stream; 32 #设定mime类型,文件传送类型由mime.type文件定义 33 34 server_names_hash_bucket_size 128; #保存服务器名字的hash表大小 35 client_header_buffer_size 32k; #客户端请求头部缓冲区大小 36 large_client_header_buffers 4 32k; #最大客户端头缓冲大小 37 client_max_body_size 50m; #客户端最大上传文件大小(M) 38 39 sendfile on; 40 #sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文 件,对于普通应用,必须设为 on。如果用来进行下载等应用磁盘IO重负载应用,可 设置为off,以平衡磁盘与网络I/O处理速度,降低系统的uptime. 41 #高效文件传输 42 tcp_nopush on; 43 #这个是默认的,结果就是数据包不会马上传送出去,等到数据包最大时,一次性的 传输出去,这样有助于解决网络堵塞。(只在sendfile on时有效) 44 45 46 keepalive_timeout 60; 47 #连接超时时间 48 49 tcp_nodelay on; 50 #禁用nagle算法,也即不缓存数据。有效解决网络阻塞 51 52 fastcgi_connect_timeout 300; 53 fastcgi_send_timeout 300; 54 fastcgi_read_timeout 300; 55 fastcgi_buffer_size 64k; 56 fastcgi_buffers 4 64k; 57 fastcgi_busy_buffers_size 128k; 58 fastcgi_temp_file_write_size 256k; 59 #fastcgi设置 60 61 gzip on; 62 gzip_min_length 1k; 63 gzip_buffers 4 16k; 64 gzip_http_version 1.1; 65 gzip_comp_level 2; 66 gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss; 67 gzip_vary on; 68 gzip_proxied expired no-cache no-store private auth; 69 gzip_disable "MSIE [1-6]."; 70 71 #limit_conn_zone $binary_remote_addr zone=perip:10m; 72 ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. 73 server_tokens off; 74 #隐藏nginx版本号(curl -I 192.168.4.154可以查看,更加安全) 75 76 #log format 77 log_format access '$remote_addr - $remote_user [$time_local] "$request" ' 78 '$status $body_bytes_sent "$http_referer" ' 79 '"$http_user_agent" $http_x_forwarded_for'; 80 #定义日志格式 81 82 server 83 { 84 listen 80 default_server; 85 #listen [::]:80 default_server ipv6only=on; 86 #监听80端口 87 server_name www.eshop.com 88 #服务器名 89 index index.html index.htm index.php; 90 #默认网页文件 91 root /eshop/laravel/public; 92 #网页主目录 93 94 #error_page 404 /404.html; 95 include enable-php.conf; 96 97 location /nginx_status 98 { 99 stub_status on; 100 access_log off; 101 } 102 #开启status状态监测 103 location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ 104 { 105 expires 30d; 106 } 107 #静态文件处理,保存期30天 108 location ~ .*.(js|css)?$ 109 { 110 expires 12h; 111 } 112 #js和css文件处理,保存期12小时 113 location ~ /. 114 { 115 deny all; 116 } 117 118 access_log /home/wwwlogs/access.log access; 119 #正确访问日志 120 } 121 include vhost/*.conf; 122 #vhost/下子配置文件生效 123 }