centos6.5 lnmp、lamp、lnmpa一鍵安裝包

這個腳本是使用shell編寫,爲了快速在生產環境上部署lnmp/lamp/lnmpa(LinuxNginx/Tengine、MySQL
/MariaDB/Percona、PHP),適用於CentOS 5~7(包括redhat)、Debian 6~8、Ubuntu 12.04~15.04的32位和64位。

腳本特性

  • 持續不斷更新
  • 源碼編譯安裝,大多數源碼是最新stable版,並從官方網址下載
  • 一些安全優化
  • 提供多個數據庫版本(MySQL-5.6, MySQL-5.5, MariaDB-10.0, MariaDB-5.5, Percona-5.6, Percona-5.5)
  • 提供多個PHP版本(php-5.3, php-5.4, php-5.5,php-5.6,php-7/phpng(alpha))
  • 提供Nginx、Tengine
  • 提供多個Apache版本(Apache-2.4,Apache-2.2)
  • 根據自己需求安裝PHP緩存加速器,提供ZendOPcache、xcache、apcu、eAccelerator。及php加解密工具ionCube、ZendGuardLoader
  • 根據自己需求安裝Pureftpd、phpMyAdmin
  • 根據自己需求安裝memcached、redis
  • 根據自己需求可使用tcmalloc或者jemalloc優化MySQL、Nginx
  • 提供添加虛擬主機腳本
  • 提供Nginx/Tengine、PHP、Redis、phpMyAdmin升級腳本
  • 提供本地備份和遠程備份(服務器之間rsync)腳本
  • 提供CentOS 6、7下HHVM安裝

Github地址:https://github.com/lj2007331/lnmp

lnmp問題反饋論壇:http://bbs.linuxeye.com

lnmp一鍵安裝包腳本問題反饋請加QQ:

  • 1456512210

安裝步驟

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

如下圖

Pure-FTPd虛擬用戶賬號管理

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 

卸載lnmp

cd ~/lnmp # 必須進入lnmp目錄下執行
./uninstall.sh

重裝lnmp

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 如是有效域名就可以直接訪問即可



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章