这个脚本是使用shell编写,为了快速在生产环境上部署lnmp/lamp/lnmpa(Linux、Nginx/Tengine、MySQL
/MariaDB/Percona、PHP),适用于CentOS 5~7(包括redhat)、Debian 6~8、Ubuntu 12.04~15.04的32位和64位。
Github地址:https://github.com/lj2007331/lnmp
lnmp问题反馈论坛:http://bbs.linuxeye.com
lnmp一键安装包脚本问题反馈请加QQ:
yum -y install wget screen #for CentOS/Redhat #apt-get -y install wget screen # for Debian/Ubuntu wget http://aliyun-oss.linuxeye.com/lnmp-full.tar.gz #阿里云用户下载 wget http://mirrors.linuxeye.com/lnmp-full.tar.gz # 包含源码,国内外均可下载 wget http://mirrors.linuxeye.com/lnmp.tar.gz # 不包含源码,建议仅国外主机下载 tar xzf lnmp-full.tar.gz #tar xzf lnmp.tar.gz cd lnmp # 如果需要修改目录(安装、数据存储、Nginx日志),请修改options.conf文件 screen -S lnmp # 如果网路出现中断,可以执行命令`screen -r lnmp`重新连接安装窗口 ./install.sh # 请勿sh install.sh或者bash install.sh这样执行
如下图
cd ~/lnmp # 必须进入lnmp目录下执行 ./vhost.sh
如下图
cd ~/lnmp # 必须进入lnmp目录下执行 ./pureftpd_vhost.sh
如下图
cd ~/lnmp # 必须进入lnmp目录下执行 ./backup_setup.sh # 备份参数设置 ./backup.sh # 立即执行备份 crontab -e # 可添加到计划任务,如每天凌晨1点自动备份 0 1 * * * cd ~/lnmp;./backup.sh > /dev/null 2>&1 &
备份参数设置如下图:
Nginx/Tengine:
service nginx {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}
MySQL/MariaDB/Percona:
service mysqld {start|stop|restart|reload|force-reload|status}
PHP:
service php-fpm {start|stop|force-quit|restart|reload|status}
Apache:
service httpd {start|restart|graceful|graceful-stop|stop}
Pure-Ftpd:
service pureftpd {start|stop|restart|condrestart|status}
Redis:
service redis-server {start|stop|status|restart|condrestart|try-restart|reload|force-reload}
Memcached:
service memcached {start|stop|status|restart|reload|force-reload}
cd ~/lnmp # 必须进入lnmp目录下执行 ./upgrade_php.sh #升级PHP(小版本升级,如需跨大版本升级,可如下操作service php-fpm stop; mv /usr/local/php{,_bk};./install.sh php选y,其余n) ./upgrade_web.sh #升级Nginx/Tengine ./upgrade_redis.sh #升级Redis ./upgrade_phpmyadmin.sh #升级phpMyAdmin
cd ~/lnmp # 必须进入lnmp目录下执行 ./uninstall.sh
cd ~/lnmp # 必须进入lnmp目录下执行 ./uninstall.sh #备份数据;卸载 ./install.sh #再次安装
最后做magento的域名解析
进入/usr/local/nginx/conf 在这个文件里创建magento.conf文件 代码如下:
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php last;
}
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
location ~ ^(.*)\/\.svn\/{deny all;}
然后在/usr/local/nginx/conf创建vhost文件夹
cd /usr/local/nginx/conf/vhost 进入这个文件夹中创建ugomi.conf文件
server
{
listen 80;
#listen [::]:80;
server_name test.ugomi.con;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/ugomi;
include magento.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
}
最后重启nginx服务,/etc/init.d/nginx restart 如是有效域名就可以直接访问即可