├── rewrite ├── wordpress.conf ├── discuz.conf ├── typecho.conf ├── discuzx.conf ├── sablog.conf └── ecshop.conf ├── conf ├── proxy_cache.inc ├── control_user.sql ├── server.key ├── httpd-ssl.conf ├── config.inc.php ├── nginx-vhost-proxy.conf ├── init.d.nginx ├── nginx-vhost-localhost.conf ├── nginx-vhost-original.conf ├── nginx.conf ├── init.d.php-fpm ├── httpd.conf ├── sshd_config ├── httpd-mpm.conf ├── server.crt ├── init.d.httpd ├── my.cnf ├── sshd ├── php-fpm-p2.conf └── php-fpm-p4.conf ├── docs ├── about.md ├── introduction.md ├── upgrade.md ├── vhost_del.md ├── install.md └── vhost_add.md ├── install.sh ├── aliyun_init.sh ├── README.md ├── uninstall.sh ├── Changelog ├── vhost_del.sh ├── upgrade.sh ├── vhost_add.sh ├── rpm.sh └── deb.sh /rewrite/wordpress.conf: -------------------------------------------------------------------------------- 1 | if (!-e $request_filename) { 2 | rewrite (.*) /index.php; 3 | } 4 | -------------------------------------------------------------------------------- /conf/proxy_cache.inc: -------------------------------------------------------------------------------- 1 | proxy_cache lanmp; 2 | proxy_cache_key "$scheme://$host$request_uri"; 3 | proxy_cache_valid 200 301 302 304 1d; -------------------------------------------------------------------------------- /docs/about.md: -------------------------------------------------------------------------------- 1 | #Lanmp 项目相关信息 2 | ## 一、项目成员 3 | ### 介绍开发人员的相关情况 4 | ## 二、贡献者 5 | ### 所有为`LANMP`贡献过力量的人们 6 | ## 三、项目地址 7 | ### 如何使用`GIT`获取项目最新源代码 8 | ## 四、讨论组 9 | ### 在这里讨论项目相关问题 10 | ## 五、邮件列表 11 | ### 获取项目最新状况 -------------------------------------------------------------------------------- /rewrite/discuz.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last; 3 | rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last; 4 | rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page%3D$3&page=$2 last; 5 | rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last; 6 | rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last; 7 | } 8 | -------------------------------------------------------------------------------- /rewrite/typecho.conf: -------------------------------------------------------------------------------- 1 | location ~ .+\.php.*$ { 2 | set $path_info ""; 3 | set $real_script_name $fastcgi_script_name; 4 | if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { 5 | set $real_script_name $1; 6 | set $path_info $2; 7 | } 8 | fastcgi_pass 127.0.0.1:9000; 9 | fastcgi_index index.php; 10 | fastcgi_param SCRIPT_FILENAME $document_root/$real_script_name; 11 | include fastcgi_params; 12 | fastcgi_param SCRIPT_NAME $real_script_name; 13 | fastcgi_param PATH_INFO $path_info; 14 | } 15 | 16 | if (!-e $request_filename) { 17 | rewrite ^/(.*)$ /index.php/$1; 18 | } 19 | -------------------------------------------------------------------------------- /rewrite/discuzx.conf: -------------------------------------------------------------------------------- 1 | rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last; 2 | rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last; 3 | rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last; 4 | rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last; 5 | rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last; 6 | rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last; 7 | rewrite ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last; 8 | 9 | if (!-e $request_filename) { 10 | return 404; 11 | } 12 | -------------------------------------------------------------------------------- /conf/control_user.sql: -------------------------------------------------------------------------------- 1 | GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'PMAPWD'; 2 | GRANT SELECT ( 3 | Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv, 4 | Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, 5 | File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, 6 | Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, 7 | Execute_priv, Repl_slave_priv, Repl_client_priv 8 | ) ON mysql.user TO 'pma'@'localhost'; 9 | GRANT SELECT ON mysql.db TO 'pma'@'localhost'; 10 | GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv) 11 | ON mysql.tables_priv TO 'pma'@'localhost'; 12 | GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost'; 13 | -------------------------------------------------------------------------------- /conf/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAK8gAc7QIhJXgPDq 3 | 8hjF+eseUNvcfiEo9OOEcz3PbomfgKXESMDTW8GXvm7ozm4FnTrVQb5R18aw+9q1 4 | E/PXBrD+8p0j+mJAlP2J0STkLoXdQuxHpBwXRpM9tz9Uh14rRqrlaOeJaolfJpKC 5 | vcffk/+qsywnLI2hCbFvgZpP9YxrAgMBAAECgYAcmEBTUZ7OmeUe8W34Z5MoNfoD 6 | /FvH9FUQNVdP12f4JsgtyQAMJDbORIW+vFrAkkAbFCk490ohUlK9YmXQoeKgjH1K 7 | M5qGCLEi7M2+OlR3hXMlqi0OrdZwVibYCI9vFYYF86EQqfMH4GhkEkvEhLUnzA17 8 | upYmzw8GScCQ6QT5QQJBAOiH+41ZEgFE4SejqYptTjpKwKGrupVSDu+GGr6bm19N 9 | yQK1mwGdh8+m0bBWLjlDBqVjupzVrFJ621AvCS1KxKECQQDAzMtuqU/6oDz30u66 10 | vvK9iCkIcaZoi807hxgEMd0jEsF0S5wS99s5tGuRXKXc6pgajBfydILgtSD7lcZT 11 | fymLAkEAz2HfrptenHUi3WhwX33Gw+RBUq7G1D+ABI00swQymNfVyy3OVa16H28n 12 | Gj5yMS2e8sgz+YXzjwf1KtkYNSW2oQJAe0BwrIXAg0/8qdFGnEuFknSBBszgvOTi 13 | hrOOPuBBpjJPSbEsTVP16aXVPlAkGF5AbngwtuaU5GHme+77olUgkQJABWXsVqs/ 14 | lvBnr6TmG2r9ngvqiTQa3N8l6I0Lxht2IDCWj+8tCk2poIrs9G/9ywHT64n1CCyB 15 | c+orRQSZvR0Sdw== 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /rewrite/sablog.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | rewrite “^/date/([0-9]{6})/?([0-9]+)?/?$” /index.php?action=article&setdate=$1&page=$2 last; 3 | rewrite ^/page/([0-9]+)?/?$ /index.php?action=article&page=$1 last; 4 | rewrite ^/category/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&cid=$1&page=$2 last; 5 | rewrite ^/category/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&curl=$1&page=$2 last; 6 | rewrite ^/(archives|search|article|links)/?$ /index.php?action=$1 last; 7 | rewrite ^/(comments|tagslist|trackbacks|article)/?([0-9]+)?/?$ /index.php?action=$1&page=$2 last; 8 | rewrite ^/tag/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&item=$1&page=$2 last; 9 | rewrite ^/archives/([0-9]+)/?([0-9]+)?/?$ /index.php?action=show&id=$1&page=$2 last; 10 | rewrite ^/rss/([^/]+)/?$ /rss.php?url=$1 last; 11 | rewrite ^/user/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&user=$1&page=$2 last; 12 | rewrite sitemap.xml sitemap.php last; 13 | rewrite ^(.*)/([0-9a-zA-Z\-\_]+)/?([0-9]+)?/?$ $1/index.php?action=show&alias=$2&page=$3 last; 14 | } 15 | -------------------------------------------------------------------------------- /conf/httpd-ssl.conf: -------------------------------------------------------------------------------- 1 | Listen 443 2 | NameVirtualHost *:443 3 | 4 | AddType application/x-x509-ca-cert .crt 5 | AddType application/x-pkcs7-crl .crl 6 | 7 | SSLPassPhraseDialog builtin 8 | SSLSessionCache "shmcb:/usr/local/apache/logs/ssl_scache(512000)" 9 | SSLSessionCacheTimeout 300 10 | SSLMutex "file:/usr/local/apache/logs/ssl_mutex" 11 | 12 | 13 | 14 | ServerAdmin webmaster@example.com 15 | DocumentRoot "WEBROOT" 16 | ServerName 127.0.0.1 17 | ErrorLog "logs/error_log" 18 | CustomLog "logs/access_log" combinedio 19 | 20 | 21 | Options +Includes +Indexes 22 | php_admin_flag engine ON 23 | php_admin_value open_basedir "WEBROOT:/tmp:/proc" 24 | 25 | 26 | SSLEngine on 27 | SSLProtocol all -SSLv2 28 | SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 29 | SSLCertificateFile "/usr/local/apache/conf/ssl/server.crt" 30 | SSLCertificateKeyFile "/usr/local/apache/conf/ssl/server.key" 31 | 32 | 33 | SSLOptions +StdEnvVars 34 | 35 | 36 | 37 | SSLOptions +StdEnvVars 38 | 39 | 40 | BrowserMatch "MSIE [2-5]" \ 41 | nokeepalive ssl-unclean-shutdown \ 42 | downgrade-1.0 force-response-1.0 43 | 44 | CustomLog "/usr/local/apache/logs/ssl_request_log" \ 45 | "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/introduction.md: -------------------------------------------------------------------------------- 1 | #LANMP 一键安装包简介 2 | 3 | ## 一、简介 4 | 5 | 1. `LANMP` 指的是 `Linux` + `Apache` + `Nginx` + `MySQL` + `PHP` 运行环境。 6 | 2. `LANMP` 一键安装包是用 `Linux Shell` 语言编写的,用于在 `Linux` 系统(`Redhat`/`CentOS`/`Debian`/`Ubuntu`)上一键安装 `LANMP`环境的工具包。 7 | 8 | ## 二、特点与优势 9 | 1. 3种Web环境自由组合 10 | 11 | `lnmp`、`lamp`、`lanmp`(Nginx前端Apache后端)可自主选择,甚至安装完后还可以自由调整。 12 | 13 | 2. 最新版本软件包 14 | 15 | 全部采用最新稳定版本的软件包,如`PHP 5.4`(可选择`PHP 5.2`)系列,`MySQL 5.5`系列。 16 | 17 | 3. 下载更智能更方便 18 | 19 | 自动从官方地址下载最新稳定版本源码安装,如果官网挂了或被和谐了,可自动从备选地址下载最新版。 20 | 21 | 4. 完美多用户支持 22 | 23 | 配套了虚拟主机用户添加和删除脚本,因此可用来做虚拟主机销售。(主网站位于`/var/www`目录,用户网站位于`/home/user1`、`/home/user2`...) 24 | 25 | 5. 完善的扩展支持 26 | 27 | 除小型依赖库外,都尽可能从源码编译安装。如PHP支持了`gd`,`memcache`,`xcache`,`pdo mysql`等扩展。 28 | 29 | 6. 多种PHP处理方式 30 | 31 | `Nginx`以`FastCGI`方式解析`PHP`,`Nginx`+`Apache`可选以`php moudle`或`FastCGI`方式方式解析`PHP`。 32 | 33 | 7. 模块化安装流程 34 | 35 | 模块化、清晰的安装流程,脚本非常易于理解,因此您可以很容易修改脚本。 36 | 37 | 8. 简洁与高效 38 | 39 | 只安装必须的东西,没有臃肿的图形界面。 40 | 41 | 9. 支持自动升级 42 | 43 | 安装前可自动安装最新版本,安装后也可升级到最新版本。 44 | 45 | 10. 其他 46 | 47 | 如`phpMyAdmin`支持额外的链接表特性,支持添加二级子域名,自定义`Rewrite`规则等等。 48 | 49 | ## 三、配置文件位置 50 | 51 | + `php: /usr/local/php/lib/php.ini` 52 | + `php-fpm: /usr/local/php/etc/php-fpm.conf` 53 | + `pear: /usr/local/php/etc/pear.conf` 54 | + `nginx: /usr/local/nginx/conf/nginx.conf` 55 | + `httpd: /usr/local/apache/conf/httpd.conf` 56 | + `mysql: /etc/my.cnf` 57 | + ...... 58 | 59 | ## 四、注意事项 60 | 61 | 1. LANMP一键安装包针对了512M内存的VPS进行了些优化。如果你的内存较低,建议您要修改php或apache的配置文件。 62 | 2. 下载版安装包需要连接互联网,完整版安装包可以在局域安装,但需要配置好局域网的更新源。 -------------------------------------------------------------------------------- /docs/upgrade.md: -------------------------------------------------------------------------------- 1 | #Lanmp 组件升级说明 2 | 3 | ## 一、概述 4 | 5 | * Lanmp 现已支持自动升级,程序会查找当前版本和最新版本,并提示你是否升级。 6 | * 升级有风险,请务必做好所有数据备份,注意是所有重要数据,包括mysql数据。 7 | 8 | ## 二、升级步骤 9 | 10 | 1. 输入默认网站目录 11 | 12 | 这里要输入您当时选择的目录,如果您当时没有修改,则保持默认网站路径 `/var/www`。 13 | 14 | 15 | 16 | 2. 请选择服务器架构 17 | 18 | 这里不能乱填,如果您安装时是选择`3`,那么这里也要选择`3` 19 | 20 | 21 | 22 | 3. 询问是否需要升级PHP 23 | 24 | 如下图,程序已成功获取已安装PHP版本是`5.2.17p1`,最新PHP版本是`5.4.7`,于是询问你是否需要升级。 25 | 26 | 请注意:目前不支持从PHP 5.2系列跳跃升级到5.4系列。(下图仅作为演示) 27 | 28 | 29 | 30 | 4. 询问是否需要升级xCache组件 31 | 32 | 一般默认升级,xCache可是个好东西。 ^_^ 33 | 34 | 35 | 36 | 5. 询问是否需要升级Nginx 37 | 38 | 如下图,程序已成功获取已安装Nginx版本是`1.3.5`,最新Nginx版本是`1.3.6`,于是询问你是否需要升级。 39 | 40 | 41 | 42 | 6. 询问是否需要升级phpMyAdmin 43 | 44 | 如下图,程序已成功获取已安装phpMyAdmin版本是`3.5.2.1`,最新phpMyAdmin版本是`3.5.2.2`,于是询问你是否需要升级。 45 | 46 | 47 | 48 | ## 三、反馈 49 | 50 | 如果您升级失败,请您运行`nginx -t`和`apache -t`命令,查找原因。 51 | 或者通过下面方式与我联系,谢谢! 52 | 53 | > Email: [WangYan@188.com](WangYan@188.com) 54 | > Twitter:[@wang_yan](https://twitter.com/wang_yan) 55 | > Home Page: [WangYan Blog](http://wangyan.org/blog) -------------------------------------------------------------------------------- /conf/config.inc.php: -------------------------------------------------------------------------------- 1 | 5 | * Date: Tue, 08 Feb 2011 10:59:56 +0000 6 | */ 7 | 8 | /* Servers configuration */ 9 | $i = 0; 10 | 11 | /* Server: localhost [1] */ 12 | $i++; 13 | $cfg['Servers'][$i]['verbose'] = ''; 14 | $cfg['Servers'][$i]['host'] = 'localhost'; 15 | $cfg['Servers'][$i]['port'] = ''; 16 | $cfg['Servers'][$i]['socket'] = ''; 17 | $cfg['Servers'][$i]['connect_type'] = 'socket'; 18 | $cfg['Servers'][$i]['extension'] = 'mysqli'; 19 | $cfg['Servers'][$i]['auth_type'] = 'cookie'; 20 | $cfg['Servers'][$i]['user'] = ''; 21 | $cfg['Servers'][$i]['password'] = ''; 22 | $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; 23 | $cfg['Servers'][$i]['controluser'] = 'pma'; 24 | $cfg['Servers'][$i]['controlpass'] = 'PMAPWD'; 25 | $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark'; 26 | $cfg['Servers'][$i]['relation'] = 'pma_relation'; 27 | $cfg['Servers'][$i]['table_info'] = 'pma_table_info'; 28 | $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords'; 29 | $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages'; 30 | $cfg['Servers'][$i]['column_info'] = 'pma_column_info'; 31 | $cfg['Servers'][$i]['history'] = 'pma_history'; 32 | $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords'; 33 | $cfg['Servers'][$i]['recent'] = 'pma_recent'; 34 | $cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs'; 35 | $cfg['Servers'][$i]['tracking'] = 'pma_tracking'; 36 | $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig'; 37 | 38 | /* End of servers configuration */ 39 | 40 | $cfg['blowfish_secret'] = '4d511fa76e73b0.20642476'; 41 | $cfg['UploadDir'] = ''; 42 | $cfg['SaveDir'] = ''; 43 | $cfg['AllowAnywhereRecoding'] = true; 44 | $cfg['AllowUserDropDatabase'] = true; 45 | $cfg['QueryHistoryDB'] = true; 46 | $cfg['ShowPhpInfo'] = true; 47 | $cfg['ShowAll'] = true; 48 | $cfg['DefaultLang'] = 'zh-utf-8'; 49 | $cfg['ServerDefault'] = 1; 50 | $cfg['ThemeDefault'] = 'pmahomme'; 51 | ?> 52 | -------------------------------------------------------------------------------- /conf/nginx-vhost-proxy.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | # listen [::]:80 default ipv6only=on; 4 | server_name DOMAIN www.DOMAIN; 5 | 6 | root ROOTDIR; 7 | index index.htm index.html index.php; 8 | 9 | access_log logs/DOMAIN/access.log main; 10 | error_log logs/DOMAIN/error.log info; 11 | 12 | location = / { 13 | proxy_pass http://backend; 14 | } 15 | 16 | location / { 17 | try_files $uri $uri/ @apache; 18 | } 19 | 20 | location @apache { 21 | proxy_pass http://backend; 22 | } 23 | 24 | location ~ .+\.php.*$ { 25 | proxy_pass http://backend; 26 | } 27 | 28 | location ~* .+\.(gif|png|jpg|bmp|ico)$ { 29 | expires 30d; 30 | } 31 | 32 | location ~* .+\.(js|css)$ { 33 | expires 1d; 34 | } 35 | 36 | location ~ /\.ht { 37 | deny all; 38 | } 39 | 40 | } 41 | 42 | server { 43 | listen 443; 44 | # listen [::]:443 default ipv6only=on; 45 | server_name DOMAIN www.DOMAIN; 46 | 47 | ssl on; 48 | ssl_certificate ssl/server.crt; 49 | ssl_certificate_key ssl/server.key; 50 | 51 | ssl_session_timeout 5m; 52 | ssl_protocols SSLv2 SSLv3 TLSv1; 53 | ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; 54 | ssl_prefer_server_ciphers on; 55 | 56 | root ROOTDIR; 57 | index index.htm index.html index.php; 58 | 59 | access_log logs/DOMAIN/access.log main; 60 | error_log logs/DOMAIN/error.log info; 61 | 62 | location = / { 63 | proxy_pass http://backend; 64 | } 65 | 66 | location / { 67 | try_files $uri $uri/ @apache; 68 | } 69 | 70 | location @apache { 71 | proxy_pass http://backend; 72 | } 73 | 74 | location ~ .+\.php.*$ { 75 | proxy_pass http://backend; 76 | } 77 | 78 | location ~* .+\.(gif|png|jpg|bmp|ico)$ { 79 | expires 30d; 80 | } 81 | 82 | location ~* .+\.(js|css)$ { 83 | expires 1d; 84 | } 85 | 86 | location ~ /\.ht { 87 | deny all; 88 | } 89 | } -------------------------------------------------------------------------------- /conf/init.d.nginx: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # nginx Start up the nginx server daemon 4 | # 5 | # chkconfig: 2345 55 25 6 | # Description: starts and stops the nginx web server 7 | # 8 | ### BEGIN INIT INFO 9 | # Provides: nginx 10 | # Required-Start: $all 11 | # Required-Stop: $all 12 | # Default-Start: 2 3 4 5 13 | # Default-Stop: 0 1 6 14 | # Description: starts and stops the nginx web server 15 | ### END INIT INFO 16 | 17 | # Author: WangYan 18 | # Version:1.0 (2011.19.15) 19 | 20 | # To install: 21 | # copy this file to /etc/init.d/nginx 22 | # shell> chkconfig --add nginx (RedHat) 23 | # shell> update-rc.d -f nginx defaults (debian) 24 | 25 | # To uninstall: 26 | # shell> chkconfig --del nginx (RedHat) 27 | # shell> update-rc.d -f nginx remove 28 | 29 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin 30 | NAME=nginx 31 | DAEMON=/usr/local/nginx/sbin/$NAME 32 | CONFIGFILE=/usr/local/nginx/conf/$NAME.conf 33 | PIDFILE=/var/run/$NAME.pid 34 | ULIMIT=10240 35 | 36 | set -e 37 | [ -x "$DAEMON" ] || exit 0 38 | 39 | do_start() { 40 | echo "Starting $NAME ..." 41 | ulimit -SHn $ULIMIT 42 | $DAEMON -c $CONFIGFILE 43 | } 44 | 45 | do_stop() { 46 | echo "Shutting down $NAME ..." 47 | kill `cat $PIDFILE` 48 | } 49 | 50 | do_reload() { 51 | echo "Reloading $NAME ..." 52 | kill -HUP `cat $PIDFILE` 53 | } 54 | 55 | case "$1" in 56 | start) 57 | [ ! -f "$PIDFILE" ] && do_start || echo "nginx already running" 58 | echo -e ".\ndone" 59 | ;; 60 | stop) 61 | [ -f "$PIDFILE" ] && do_stop || echo "nginx not running" 62 | echo -e ".\ndone" 63 | ;; 64 | restart) 65 | [ -f "$PIDFILE" ] && do_stop || echo "nginx not running" 66 | do_start 67 | echo -e ".\ndone" 68 | ;; 69 | reload) 70 | [ -f "$PIDFILE" ] && do_reload || echo "nginx not running" 71 | echo -e ".\ndone" 72 | ;; 73 | *) 74 | N=/etc/init.d/$NAME 75 | echo "Usage: $N {start|stop|restart|reload}" >&2 76 | exit 1 77 | ;; 78 | esac 79 | 80 | exit 0 -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #==================================================================== 3 | # install.sh 4 | # 5 | # Linux + Apache + Nginx + MySQL + PHP Auto Install Script 6 | # 7 | # Copyright (c) 2012, WangYan 8 | # All rights reserved. 9 | # Distributed under the GNU General Public License, version 3.0. 10 | # 11 | # Intro: https://wangyan.org/blog/lanmp.html 12 | # 13 | #==================================================================== 14 | 15 | if [ $(id -u) != "0" ]; then 16 | clear && echo "Error: You must be root to run this script!" 17 | exit 1 18 | fi 19 | 20 | LANMP_PATH=`pwd` 21 | if [ `echo $LANMP_PATH | awk -F/ '{print $NF}'` != "lanmp" ]; then 22 | clear && echo "Please enter lanmp script path:" 23 | read -p "(Default path: ${LANMP_PATH}/lanmp):" LANMP_PATH 24 | [ -z "$LANMP_PATH" ] && LANMP_PATH=$(pwd)/lanmp 25 | cd $LANMP_PATH/ 26 | fi 27 | 28 | DISTRIBUTION=`awk 'NR==1{print $1}' /etc/issue` 29 | 30 | if echo $DISTRIBUTION | grep -Eqi '(Red Hat|CentOS|Fedora|Amazon)';then 31 | PACKAGE="rpm" 32 | elif echo $DISTRIBUTION | grep -Eqi '(Debian|Ubuntu)';then 33 | PACKAGE="deb" 34 | else 35 | if cat /proc/version | grep -Eqi '(redhat|centos)';then 36 | PACKAGE="rpm" 37 | elif cat /proc/version | grep -Eqi '(debian|ubuntu)';then 38 | PACKAGE="deb" 39 | else 40 | echo "Please select the package management! (rpm/deb)" 41 | read -p "(Default: rpm):" PACKAGE 42 | if [ -z "$PACKAGE" ]; then 43 | PACKAGE="rpm" 44 | fi 45 | if [[ "$PACKAGE" != "rpm" && "$PACKAGE" != "deb" ]];then 46 | echo -e "\nNot supported linux distribution!" 47 | echo "Please contact me! WangYan " 48 | exit 0 49 | fi 50 | fi 51 | fi 52 | 53 | [ -r "$LANMP_PATH/fifo" ] && rm -rf $LANMP_PATH/fifo 54 | mkfifo $LANMP_PATH/fifo 55 | cat $LANMP_PATH/fifo | tee $LANMP_PATH/log.txt & 56 | exec 1>$LANMP_PATH/fifo 57 | exec 2>&1 58 | 59 | /bin/bash ${LANMP_PATH}/${PACKAGE}.sh 60 | 61 | sed -i '/password/d' $LANMP_PATH/log.txt 62 | rm -rf $LANMP_PATH/fifo 63 | -------------------------------------------------------------------------------- /conf/nginx-vhost-localhost.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | # listen [::]:80 default ipv6only=on; 4 | server_name DOMAIN www.DOMAIN; 5 | 6 | root ROOTDIR; 7 | index index.htm index.html index.php; 8 | 9 | access_log logs/DOMAIN/access.log main; 10 | error_log logs/DOMAIN/error.log info; 11 | 12 | location / { 13 | try_files $uri $uri/ @apache; 14 | } 15 | 16 | location @apache { 17 | proxy_pass http://backend; 18 | } 19 | 20 | location ~ .+\.php.*$ { 21 | proxy_pass http://backend; 22 | } 23 | 24 | location ~* .+\.(gif|png|jpg|bmp|ico)$ { 25 | expires 30d; 26 | } 27 | 28 | location ~* .+\.(js|css)$ { 29 | expires 1d; 30 | } 31 | 32 | location ~ /\.ht { 33 | deny all; 34 | } 35 | 36 | location /nginx-status { 37 | stub_status on; 38 | access_log off; 39 | # allow 192.168.1.100; 40 | # deny all; 41 | } 42 | } 43 | 44 | server { 45 | listen 443; 46 | # listen [::]:443 default ipv6only=on; 47 | server_name DOMAIN www.DOMAIN; 48 | 49 | ssl on; 50 | ssl_certificate ssl/server.crt; 51 | ssl_certificate_key ssl/server.key; 52 | 53 | ssl_session_timeout 5m; 54 | ssl_protocols SSLv2 SSLv3 TLSv1; 55 | ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; 56 | ssl_prefer_server_ciphers on; 57 | 58 | root ROOTDIR; 59 | index index.htm index.html index.php; 60 | 61 | access_log logs/DOMAIN/access.log main; 62 | error_log logs/DOMAIN/error.log info; 63 | 64 | location / { 65 | try_files $uri $uri/ @apache; 66 | } 67 | 68 | location @apache { 69 | proxy_pass http://backend; 70 | } 71 | 72 | location ~ .+\.php.*$ { 73 | proxy_pass http://backend; 74 | } 75 | 76 | location ~* .+\.(gif|png|jpg|bmp|ico)$ { 77 | expires 30d; 78 | } 79 | 80 | location ~* .+\.(js|css)$ { 81 | expires 1d; 82 | } 83 | 84 | location ~ /\.ht { 85 | deny all; 86 | } 87 | 88 | location /nginx-status { 89 | stub_status on; 90 | access_log off; 91 | # allow 192.168.1.100; 92 | # deny all; 93 | } 94 | } -------------------------------------------------------------------------------- /conf/nginx-vhost-original.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | # listen [::]:80 default ipv6only=on; 4 | server_name DOMAIN www.DOMAIN; 5 | 6 | root ROOTDIR; 7 | index index.htm index.html index.php; 8 | 9 | access_log logs/DOMAIN/access.log main; 10 | error_log logs/DOMAIN/error.log info; 11 | 12 | error_page 403 /403.html; 13 | error_page 404 /404.html; 14 | error_page 500 502 503 504 /50x.html; 15 | 16 | location / { 17 | #include REWRITE_RULE.conf; 18 | } 19 | 20 | location ~ .+\.php.*$ { 21 | fastcgi_pass 127.0.0.1:9000; 22 | fastcgi_index index.php; 23 | fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; 24 | include fastcgi_params; 25 | } 26 | 27 | location ~* .+\.(gif|png|jpg|bmp|ico)$ { 28 | expires 30d; 29 | } 30 | 31 | location ~* .+\.(js|css)$ { 32 | expires 1d; 33 | } 34 | 35 | location ~ /\.ht { 36 | deny all; 37 | } 38 | } 39 | 40 | server { 41 | listen 443; 42 | # listen [::]:443 default ipv6only=on; 43 | server_name DOMAIN www.DOMAIN; 44 | 45 | ssl on; 46 | ssl_certificate ssl/server.crt; 47 | ssl_certificate_key ssl/server.key; 48 | 49 | ssl_session_timeout 5m; 50 | ssl_protocols SSLv2 SSLv3 TLSv1; 51 | ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; 52 | ssl_prefer_server_ciphers on; 53 | 54 | root ROOTDIR; 55 | index index.htm index.html index.php; 56 | 57 | access_log logs/DOMAIN/access.log main; 58 | error_log logs/DOMAIN/error.log info; 59 | 60 | error_page 403 /403.html; 61 | error_page 404 /404.html; 62 | error_page 500 502 503 504 /50x.html; 63 | 64 | location / { 65 | #include REWRITE_RULE.conf; 66 | } 67 | 68 | location ~ .+\.php.*$ { 69 | fastcgi_pass 127.0.0.1:9000; 70 | fastcgi_index index.php; 71 | fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; 72 | include fastcgi_params; 73 | } 74 | 75 | location ~* .+\.(gif|png|jpg|bmp|ico)$ { 76 | expires 30d; 77 | } 78 | 79 | location ~* .+\.(js|css)$ { 80 | expires 1d; 81 | } 82 | 83 | location ~ /\.ht { 84 | deny all; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /conf/nginx.conf: -------------------------------------------------------------------------------- 1 | user www www; 2 | pid /var/run/nginx.pid; 3 | 4 | #debug|info|notice|warn|error|crit 5 | error_log logs/error.log info; 6 | 7 | worker_processes 1; 8 | #worker_cpu_affinity 0001 0010 0100 1000; 9 | worker_rlimit_nofile 10240; 10 | 11 | events { 12 | use epoll; 13 | worker_connections 10240; 14 | } 15 | 16 | http { 17 | include mime.types; 18 | default_type application/octet-stream; 19 | 20 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 21 | '$status $body_bytes_sent "$http_referer" ' 22 | '"$http_user_agent" "$http_x_forwarded_for" ' 23 | '"$upstream_cache_status"'; 24 | 25 | access_log logs/access.log main; 26 | 27 | sendfile on; 28 | tcp_nopush on; 29 | tcp_nodelay on; 30 | keepalive_timeout 60; 31 | 32 | gzip on; 33 | gzip_buffers 4 16k; 34 | gzip_comp_level 2; 35 | gzip_http_version 1.1; 36 | gzip_min_length 1k; 37 | gzip_types text/plain application/x-javascript text/css application/xml; 38 | gzip_vary on; 39 | 40 | open_file_cache max=10240 inactive=30s; 41 | open_file_cache_valid 60s; 42 | open_file_cache_min_uses 1; 43 | 44 | autoindex on; 45 | autoindex_exact_size off; 46 | autoindex_localtime on; 47 | 48 | server_tokens off; 49 | server_name_in_redirect off; 50 | server_names_hash_bucket_size 128; 51 | 52 | client_body_buffer_size 16k; 53 | client_body_timeout 60; 54 | client_header_buffer_size 2k; 55 | large_client_header_buffers 4 8k; 56 | client_header_timeout 60; 57 | client_max_body_size 10m; 58 | 59 | proxy_buffer_size 16k; 60 | proxy_buffers 8 32k; 61 | proxy_busy_buffers_size 64k; 62 | proxy_cache_path /var/tmp/nginx/cache levels=1:2 keys_zone=lanmp:32m inactive=1h max_size=512m; 63 | proxy_connect_timeout 30; 64 | proxy_ignore_headers Set-Cookie Cache-Control Expires; 65 | proxy_read_timeout 60; 66 | proxy_send_timeout 30; 67 | proxy_temp_file_write_size 64k; 68 | 69 | proxy_set_header Host $host; 70 | proxy_set_header Accept-Encoding ''; 71 | proxy_set_header Referer $http_referer; 72 | proxy_set_header Cookie $http_cookie; 73 | proxy_set_header X-Real-IP $remote_addr; 74 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 75 | 76 | upstream backend { 77 | ip_hash; 78 | server 127.0.0.1:8080; 79 | } 80 | 81 | include vhosts/*; 82 | 83 | server { 84 | listen 80 default; 85 | return 500; 86 | } 87 | } -------------------------------------------------------------------------------- /aliyun_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 3 | export PATH 4 | 5 | if [ $(id -u) != "0" ]; then 6 | printf "Error: You must be root to run this script!" 7 | exit 1 8 | fi 9 | 10 | #echo "---------- Check the distribution ----------" 11 | 12 | if cat /proc/version | grep -qi redhat;then 13 | DISTRIBUTION="redhat" 14 | elif cat /proc/version | grep -qi centos;then 15 | DISTRIBUTION="centos" 16 | else 17 | exit 0 18 | fi 19 | 20 | echo "---------- Set the software repos ----------" 21 | 22 | if [ "$DISTRIBUTION" = "redhat" ];then 23 | sed -i 's#\[main\]#\[main\]\nmultilib_policy=best#g' /etc/yum.conf 24 | mv /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.bak 25 | wget -c http://mirrors.163.com/.help/CentOS5-Base-163.repo -P /etc/yum.repos.d/ 26 | sed -i 's/$releasever/5/g' /etc/yum.repos.d/CentOS5-Base-163.repo 27 | sed -i 's/$basearch/x86_64/g' /etc/yum.repos.d/CentOS5-Base-163.repo 28 | yum makecache 29 | /etc/init.d/iptables stop 30 | chkconfig iptables off 31 | elif [ "$DISTRIBUTION" = "centos" ];then 32 | sed -i 's/^exclude/#exclude/' /etc/yum.conf 33 | yum makecache 34 | /etc/init.d/iptables stop 35 | chkconfig iptables off 36 | fi 37 | 38 | echo "---------- Set the sysctl ----------" 39 | 40 | if [ "$DISTRIBUTION" = "redhat" ] || [ "$DISTRIBUTION" = "centos" ];then 41 | 42 | cat >> /etc/sysctl.conf <> /etc/security/limits.conf <> /etc/fstab 94 | mount -a 95 | 96 | fi 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 一、简介 2 | 3 | 1. `LANMP` 指的是 `Linux` + `Apache` + `Nginx` + `MySQL` + `PHP` 运行环境。 4 | 2. `LANMP` 一键安装包是用 `Linux Shell` 语言编写的,用于在 `Linux` 系统(`Redhat`/`CentOS`/`Debian`/`Ubuntu`)上一键安装 `LANMP`环境的工具包。 5 | 6 | ## 二、特点与优势 7 | 8 | 1. 3种Web环境自由组合 9 | 10 | `lnmp`、`lamp`、`lanmp`(Nginx前端Apache后端)可自主选择,甚至安装完后还可以自由调整。 11 | 12 | 2. 最新版本软件包 13 | 14 | 全部采用最新稳定版本的软件包,如`PHP 5.4`(可选择`PHP 5.2`)系列,`MySQL 5.5`系列。 15 | 16 | 3. 下载更智能更方便 17 | 18 | 自动从官方地址下载最新稳定版本源码安装,如果官网挂了或被和谐了,可自动从备选地址下载最新版。 19 | 20 | 4. 完美多用户支持 21 | 22 | 配套了虚拟主机用户添加和删除脚本,因此可用来做虚拟主机销售。(主网站位于`/var/www`目录,用户网站位于`/home/user1`、`/home/user2`...) 23 | 24 | 5. 完善的扩展支持 25 | 26 | 除小型依赖库外,都尽可能从源码编译安装。如PHP支持了`gd`,`memcache`,`xcache`,`pdo mysql`等扩展。 27 | 28 | 6. 多种PHP处理方式 29 | 30 | `Nginx`以`FastCGI`方式解析`PHP`,`Nginx`+`Apache`可选以`php moudle`或`FastCGI`方式方式解析`PHP`。 31 | 32 | 7. 模块化安装流程 33 | 34 | 模块化、清晰的安装流程,脚本非常易于理解,因此您可以很容易修改脚本。 35 | 36 | 8. 简洁与高效 37 | 38 | 只安装必须的东西,没有臃肿的图形界面。 39 | 40 | 9. 支持自动升级 41 | 42 | 安装前可自动安装最新版本,安装后也可升级到最新版本。 43 | 44 | 10. 其他 45 | 46 | 如`phpMyAdmin`支持额外的链接表特性,支持添加二级子域名,自定义`Rewrite`规则等等。 47 | 48 | ## 三、安装和使用 49 | 50 | 详细安装和使用说明请参阅 [《Wiki 文档》](https://github.com/wangyan/lanmp/wiki) 51 | 52 | 1、安装方法 53 | 54 | 稳定版是相对稳定的版本,开发版是更新频率较高的版本,带有新特性,但可能存在较多Bug。 55 | 56 | 方法一:直接下载已打包版本 57 | 58 | yum -y install screen #Redhat/CentOS 59 | apt-get -y install screen #Debian/Ubuntu 60 | screen -S lanmp 61 | wget -c http://wangyan.org/download/lanmp/lanmp-latest.tar.gz #安装稳定版 62 | wget -c http://wangyan.org/download/lanmp/lanmp-dev-latest.tar.gz #开发版(二选一) 63 | tar -zxf lanmp-*.tar.gz 64 | cd lanmp && ./install.sh 65 | 66 | 方法二:通过Git下载(推荐) 67 | 68 | yum -y install screen git #Redhat/CentOS 69 | apt-get -y install screen git-core git-gui #Debian/Ubuntu 70 | screen -S lanmp 71 | git clone https://github.com/wangyan/lanmp.git 72 | cd lanmp && ./install.sh #安装稳定版 73 | cd lanmp && git checkout develop && ./install.sh #安装开发版(二选一) 74 | 75 | 3、虚拟主机管理 76 | 77 | cd lanmp/ 78 | ./vhost_add.sh #添加 79 | ./vhost_del.sh #删除 80 | 81 | 4、自动升级 82 | 83 | cd lanmp/ 84 | ./upgrade.sh 85 | 86 | ## 四、注意事项 87 | 88 | 1. 可能会经常更新 89 | 90 | 改进措施:日常更新会推送到`develop`分支,较稳定版本才推送到`master`主分支。 91 | 92 | 2. 可能会不兼容你的VPS 93 | 94 | 改进措施:如果您安装失败,麻烦您将安装目录下的`log.txt`日志文件发给我分析 [WangYan@188.com](WangYan@188.com) 95 | 96 | 3. 针对512M内存的VPS进行了优化 97 | 98 | 如果你的内存较低或更高,建议您要修改php或apache的配置文件。 99 | 100 | ## 五、联系方式 101 | 102 | > Email: [WangYan#188.com](WangYan#188.com) (推荐) 103 | > Gtalk: [myidwy#gmail.com](myidwy#gmail.com) 104 | > Q Q群:[138082163](http://qun.qq.com/#jointhegroup/gid/138082163) 105 | > Twitter:[@wang_yan](https://twitter.com/wang_yan) 106 | > Home Page: [WangYan Blog](http://wangyan.org/blog) -------------------------------------------------------------------------------- /rewrite/ecshop.conf: -------------------------------------------------------------------------------- 1 | if (!-e $request_filename) { 2 | rewrite "^/index\.html" /index.php last; 3 | rewrite "^/category$" /index.php last; 4 | rewrite "^/feed-c([0-9]+)\.xml$" /feed.php?cat=$1 last; 5 | rewrite "^/feed-b([0-9]+)\.xml$" /feed.php?brand=$1 last; 6 | rewrite "^/feed\.xml$" /feed.php last; 7 | rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last; 8 | rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last; 9 | rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last; 10 | rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3 last; 11 | rewrite "^/category-([0-9]+)-b([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2 last; 12 | rewrite "^/category-([0-9]+)(.*)\.html$" /category.php?id=$1 last; 13 | rewrite "^/goods-([0-9]+)(.*)\.html" /goods.php?id=$1 last; 14 | rewrite "^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last; 15 | rewrite "^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$" /article_cat.php?id=$1&page=$2 last; 16 | rewrite "^/article_cat-([0-9]+)(.*)\.html$" /article_cat.php?id=$1 last; 17 | rewrite "^/article-([0-9]+)(.*)\.html$" /article.php?id=$1 last; 18 | rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html" /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last; 19 | rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2&page=$3 last; 20 | rewrite "^/brand-([0-9]+)-c([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2 last; 21 | rewrite "^/brand-([0-9]+)(.*)\.html" /brand.php?id=$1 last; 22 | rewrite "^/tag-(.*)\.html" /search.php?keywords=$1 last; 23 | rewrite "^/snatch-([0-9]+)\.html$" /snatch.php?id=$1 last; 24 | rewrite "^/group_buy-([0-9]+)\.html$" /group_buy.php?act=view&id=$1 last; 25 | rewrite "^/auction-([0-9]+)\.html$" /auction.php?act=view&id=$1 last; 26 | rewrite "^/exchange-id([0-9]+)(.*)\.html$" /exchange.php?id=$1&act=view last; 27 | rewrite "^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last; 28 | rewrite "^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last; 29 | rewrite "^/exchange-([0-9]+)-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2 last; 30 | rewrite "^/exchange-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1 last; 31 | } -------------------------------------------------------------------------------- /docs/vhost_del.md: -------------------------------------------------------------------------------- 1 | ## 一、概述 2 | 3 | * 删除虚拟主机用户的操作比较简单,唯一需要注意的是,删除前请做好备份工作。 4 | 5 | ## 二、删除步骤 6 | 7 | 1. 进入安装目录并运行删除虚拟主机脚本 8 | 9 | cd lanmp/ 10 | ./vhost_del.sh 11 | 12 | 13 | 14 | 2. 请输入虚拟主机用户帐号 15 | 16 | 17 | 18 | 3. 询问是否删除`FTP`帐号 19 | 20 | 注意:删除`FTP`帐号的前提是,你已经成功添加了FTP帐号。([了解添加FTP帐号条件](https://github.com/wangyan/lanmp/wiki/%E6%B7%BB%E5%8A%A0%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA%E7%94%A8%E6%88%B7%E6%96%B9%E6%B3%95)) 21 | 22 | 23 | 24 | 4. 询问是否添加`MySQL`数据库 25 | 26 | 1)默认不删除,如果需要删除请输入`y` 27 | 2)然后输入MySQL的Root密码。(注意是ROOT用户密码) 28 | 29 | 30 | 31 | 5. 请输入需要删除的`MySQL`数据库名 32 | 33 | 1)`MySQL`数据库名默认为您的虚拟主机帐号 34 | 2)一次只能删除一个数据库,这点请注意。 35 | 36 | 37 | 38 | 6. 请输入网站域名 39 | 40 | 1)注意是域名不包含`WWW` 41 | 2)脚本会自动判断,您输入的域名是否存在。 42 | 43 | 44 | 45 | 7. 请选择服务器架构 46 | 47 | 1)这里默认值为`3`,选择`3`是删除最彻底的。 48 | 49 | 50 | 51 | 8. 选择是否删除二级子域名? 52 | 53 | 注意:一次只能删除一个,要么是删除一级域名(`wangyan.org`),要么是删除二级子域名(`bbs.wangyan.org`)。 54 | 55 | 56 | 57 | 9. 最后一步,按任意键开始删除虚拟主机用户。 58 | 59 | 注意:任意键可不包括主机电源键。。。 60 | 按 ` + c` 可放弃删除。 61 | 62 | 63 | 64 | ## 三、结束 65 | 66 | * 安装结束后,可看到下图。 67 | * 上半部分的意思是运行`nginx -t`和`apache -t`命令测试NGINX和APACHE删除用户是否成功,OK就表示成功了。 68 | * 下半部分是给出了该虚拟主机用户的账户信息。 69 | * 再最后?没有了,已经大功告成了。 70 | 71 | 72 | 73 | ## 四、反馈 74 | 75 | 如果删除虚拟主机用户失败,请将出错页面截图发给我。 76 | 或者通过下面方式与我联系,谢谢! 77 | 78 | > Email: [WangYan@188.com](WangYan@188.com) 79 | > Twitter:[@wang_yan](https://twitter.com/wang_yan) 80 | > Home Page: [WangYan Blog](http://wangyan.org/blog) -------------------------------------------------------------------------------- /conf/init.d.php-fpm: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # chkconfig: 2345 55 25 3 | # Description: Startup script for php-fpm on Debian. Place in /etc/init.d and 4 | # run 'update-rc.d -f php-fpm defaults', or use the appropriate command on your 5 | # distro. For CentOS/Redhat run: 'chkconfig --add php-fpm' 6 | 7 | ### BEGIN INIT INFO 8 | # Provides: php-fpm 9 | # Required-Start: $all 10 | # Required-Stop: $all 11 | # Default-Start: 2 3 4 5 12 | # Default-Stop: 0 1 6 13 | # Short-Description: starts php-fpm 14 | # Description: starts php-fpm 15 | ### END INIT INFO 16 | 17 | php_fpm_BIN=/usr/local/php/bin/php-cgi 18 | php_fpm_CONF=/usr/local/php/etc/php-fpm.conf 19 | php_fpm_PID=/usr/local/php/logs/php-fpm.pid 20 | 21 | 22 | php_opts="--fpm-config $php_fpm_CONF" 23 | 24 | 25 | wait_for_pid () { 26 | try=0 27 | 28 | while test $try -lt 35 ; do 29 | 30 | case "$1" in 31 | 'created') 32 | if [ -f "$2" ] ; then 33 | try='' 34 | break 35 | fi 36 | ;; 37 | 38 | 'removed') 39 | if [ ! -f "$2" ] ; then 40 | try='' 41 | break 42 | fi 43 | ;; 44 | esac 45 | 46 | echo -n . 47 | try=`expr $try + 1` 48 | sleep 1 49 | 50 | done 51 | 52 | } 53 | 54 | case "$1" in 55 | start) 56 | echo -n "Starting php_fpm " 57 | 58 | $php_fpm_BIN --fpm $php_opts 59 | 60 | if [ "$?" != 0 ] ; then 61 | echo " failed" 62 | exit 1 63 | fi 64 | 65 | wait_for_pid created $php_fpm_PID 66 | 67 | if [ -n "$try" ] ; then 68 | echo " failed" 69 | exit 1 70 | else 71 | echo " done" 72 | fi 73 | ;; 74 | 75 | stop) 76 | echo -n "Shutting down php_fpm " 77 | 78 | if [ ! -r $php_fpm_PID ] ; then 79 | echo "warning, no pid file found - php-fpm is not running ?" 80 | exit 1 81 | fi 82 | 83 | kill -TERM `cat $php_fpm_PID` 84 | 85 | wait_for_pid removed $php_fpm_PID 86 | 87 | if [ -n "$try" ] ; then 88 | echo " failed" 89 | exit 1 90 | else 91 | echo " done" 92 | fi 93 | ;; 94 | 95 | quit) 96 | echo -n "Gracefully shutting down php_fpm " 97 | 98 | if [ ! -r $php_fpm_PID ] ; then 99 | echo "warning, no pid file found - php-fpm is not running ?" 100 | exit 1 101 | fi 102 | 103 | kill -QUIT `cat $php_fpm_PID` 104 | 105 | wait_for_pid removed $php_fpm_PID 106 | 107 | if [ -n "$try" ] ; then 108 | echo " failed" 109 | exit 1 110 | else 111 | echo " done" 112 | fi 113 | ;; 114 | 115 | restart) 116 | $0 stop 117 | $0 start 118 | ;; 119 | 120 | reload) 121 | 122 | echo -n "Reload service php-fpm " 123 | 124 | if [ ! -r $php_fpm_PID ] ; then 125 | echo "warning, no pid file found - php-fpm is not running ?" 126 | exit 1 127 | fi 128 | 129 | kill -USR2 `cat $php_fpm_PID` 130 | 131 | echo " done" 132 | ;; 133 | 134 | logrotate) 135 | 136 | echo -n "Re-opening php-fpm log file " 137 | 138 | if [ ! -r $php_fpm_PID ] ; then 139 | echo "warning, no pid file found - php-fpm is not running ?" 140 | exit 1 141 | fi 142 | 143 | kill -USR1 `cat $php_fpm_PID` 144 | 145 | echo " done" 146 | ;; 147 | 148 | *) 149 | echo "Usage: $0 {start|stop|quit|restart|reload|logrotate}" 150 | exit 1 151 | ;; 152 | 153 | esac 154 | -------------------------------------------------------------------------------- /conf/httpd.conf: -------------------------------------------------------------------------------- 1 | ServerRoot "/usr/local/apache" 2 | ServerName example.com 3 | #Listen 127.0.0.1:8080 4 | #Listen 80 5 | 6 | LoadModule authz_host_module modules/mod_authz_host.so 7 | LoadModule log_config_module modules/mod_log_config.so 8 | LoadModule logio_module modules/mod_logio.so 9 | LoadModule mime_module modules/mod_mime.so 10 | LoadModule status_module modules/mod_status.so 11 | LoadModule autoindex_module modules/mod_autoindex.so 12 | LoadModule cgi_module modules/mod_cgi.so 13 | LoadModule vhost_alias_module modules/mod_vhost_alias.so 14 | LoadModule dir_module modules/mod_dir.so 15 | LoadModule actions_module modules/mod_actions.so 16 | LoadModule alias_module modules/mod_alias.so 17 | LoadModule rewrite_module modules/mod_rewrite.so 18 | LoadModule headers_module modules/mod_headers.so 19 | LoadModule expires_module modules/mod_expires.so 20 | LoadModule ssl_module modules/mod_ssl.so 21 | LoadModule setenvif_module modules/mod_setenvif.so 22 | #LoadModule rpaf_module modules/mod_rpaf-2.0.so 23 | 24 | 25 | RPAFenable On 26 | RPAFproxy_ips 127.0.0.1 27 | RPAFsethostname On 28 | RPAFheader X-Forwarded-For 29 | 30 | 31 | 32 | 33 | User www 34 | Group www 35 | 36 | 37 | 38 | 39 | Options FollowSymLinks 40 | AllowOverride All 41 | Order deny,allow 42 | Allow from all 43 | 44 | 45 | 46 | DirectoryIndex index.htm index.html index.php 47 | 48 | 49 | 50 | Order allow,deny 51 | Deny from all 52 | Satisfy All 53 | 54 | 55 | ErrorLog "logs/error_log" 56 | LogLevel info 57 | 58 | 59 | LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 60 | LogFormat "%h %l %u %t \"%r\" %>s %b" common 61 | 62 | 63 | LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio 64 | 65 | 66 | CustomLog "logs/access_log" common 67 | CustomLog "logs/access_log" combined 68 | 69 | 70 | 71 | ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/" 72 | 73 | 74 | 75 | Scriptsock logs/cgisock 76 | 77 | 78 | 79 | AllowOverride None 80 | Options None 81 | Order allow,deny 82 | Allow from all 83 | 84 | 85 | DefaultType text/plain 86 | 87 | 88 | TypesConfig conf/mime.types 89 | AddType application/x-gzip .tgz 90 | AddEncoding x-compress .Z 91 | AddEncoding x-gzip .gz .tgz 92 | AddType application/x-compress .Z 93 | AddType application/x-gzip .gz .tgz 94 | AddType application/x-httpd-php .php 95 | AddType application/x-httpd-php-source .phps 96 | AddHandler cgi-script .cgi 97 | AddType text/html .shtml 98 | AddOutputFilter INCLUDES .shtml 99 | 100 | 101 | Include conf/extra/httpd-mpm.conf 102 | #Include conf/extra/httpd-multilang-errordoc.conf 103 | Include conf/extra/httpd-autoindex.conf 104 | #Include conf/extra/httpd-languages.conf 105 | #Include conf/extra/httpd-userdir.conf 106 | #Include conf/extra/httpd-info.conf 107 | Include conf/extra/httpd-vhosts.conf 108 | #Include conf/extra/httpd-manual.conf 109 | #Include conf/extra/httpd-dav.conf 110 | #Include conf/extra/httpd-default.conf 111 | #Include conf/extra/httpd-ssl.conf 112 | 113 | 114 | SSLRandomSeed startup builtin 115 | SSLRandomSeed connect builtin 116 | 117 | -------------------------------------------------------------------------------- /conf/sshd_config: -------------------------------------------------------------------------------- 1 | # $OpenBSD: sshd_config,v 1.81 2009/10/08 14:03:41 markus Exp $ 2 | 3 | # This is the sshd server system-wide configuration file. See 4 | # sshd_config(5) for more information. 5 | 6 | # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin 7 | 8 | # The strategy used for options in the default sshd_config shipped with 9 | # OpenSSH is to specify options with their default value where 10 | # possible, but leave them commented. Uncommented options change a 11 | # default value. 12 | 13 | Port 22 14 | AddressFamily any 15 | ListenAddress 0.0.0.0 16 | #ListenAddress :: 17 | 18 | # The default requires explicit activation of protocol 1 19 | Protocol 2 20 | 21 | # HostKey for protocol version 1 22 | #HostKey /etc/ssh/ssh_host_key 23 | # HostKeys for protocol version 2 24 | HostKey /etc/ssh/ssh_host_rsa_key 25 | HostKey /etc/ssh/ssh_host_dsa_key 26 | 27 | # Lifetime and size of ephemeral version 1 server key 28 | #KeyRegenerationInterval 1h 29 | #ServerKeyBits 1024 30 | 31 | # Logging 32 | # obsoletes QuietMode and FascistLogging 33 | SyslogFacility AUTH 34 | LogLevel INFO 35 | 36 | # Authentication: 37 | 38 | LoginGraceTime 2m 39 | PermitRootLogin yes 40 | StrictModes yes 41 | MaxAuthTries 6 42 | MaxSessions 10 43 | 44 | #RSAAuthentication yes 45 | PubkeyAuthentication yes 46 | AuthorizedKeysFile .ssh/authorized_keys 47 | 48 | # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts 49 | #RhostsRSAAuthentication no 50 | # similar for protocol version 2 51 | #HostbasedAuthentication no 52 | # Change to yes if you don't trust ~/.ssh/known_hosts for 53 | # RhostsRSAAuthentication and HostbasedAuthentication 54 | #IgnoreUserKnownHosts no 55 | # Don't read the user's ~/.rhosts and ~/.shosts files 56 | #IgnoreRhosts yes 57 | 58 | # To disable tunneled clear text passwords, change to no here! 59 | PasswordAuthentication yes 60 | PermitEmptyPasswords no 61 | 62 | # Change to no to disable s/key passwords 63 | ChallengeResponseAuthentication yes 64 | 65 | # Kerberos options 66 | #KerberosAuthentication no 67 | #KerberosOrLocalPasswd yes 68 | #KerberosTicketCleanup yes 69 | #KerberosGetAFSToken no 70 | 71 | # GSSAPI options 72 | #GSSAPIAuthentication no 73 | #GSSAPICleanupCredentials yes 74 | 75 | # Set this to 'yes' to enable PAM authentication, account processing, 76 | # and session processing. If this is enabled, PAM authentication will 77 | # be allowed through the ChallengeResponseAuthentication and 78 | # PasswordAuthentication. Depending on your PAM configuration, 79 | # PAM authentication via ChallengeResponseAuthentication may bypass 80 | # the setting of "PermitRootLogin without-password". 81 | # If you just want the PAM account and session checks to run without 82 | # PAM authentication, then enable this but set PasswordAuthentication 83 | # and ChallengeResponseAuthentication to 'no'. 84 | #UsePAM no 85 | 86 | AllowAgentForwarding yes 87 | AllowTcpForwarding yes 88 | GatewayPorts no 89 | X11Forwarding no 90 | X11DisplayOffset 10 91 | X11UseLocalhost yes 92 | PrintMotd yes 93 | PrintLastLog yes 94 | TCPKeepAlive yes 95 | UseLogin no 96 | UsePrivilegeSeparation yes 97 | PermitUserEnvironment no 98 | Compression delayed 99 | ClientAliveInterval 0 100 | ClientAliveCountMax 3 101 | UseDNS yes 102 | PidFile /var/run/sshd.pid 103 | MaxStartups 10 104 | PermitTunnel no 105 | ChrootDirectory none 106 | 107 | # no default banner path 108 | Banner none 109 | 110 | # override default of no subsystems 111 | # Subsystem sftp /usr/libexec/sftp-server 112 | Subsystem sftp /usr/libexec/openssh/sftp-server 113 | 114 | # Example of overriding settings on a per-user basis 115 | #Match User anoncvs 116 | # X11Forwarding no 117 | # AllowTcpForwarding no 118 | # ForceCommand cvs server 119 | -------------------------------------------------------------------------------- /conf/httpd-mpm.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Server-Pool Management (MPM specific) 3 | # 4 | 5 | # 6 | # PidFile: The file in which the server should record its process 7 | # identification number when it starts. 8 | # 9 | # Note that this is the default PidFile for most MPMs. 10 | # 11 | 12 | PidFile "logs/httpd.pid" 13 | 14 | 15 | # 16 | # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. 17 | # 18 | 19 | 20 | LockFile "logs/accept.lock" 21 | 22 | 23 | 24 | # 25 | # Only one of the below sections will be relevant on your 26 | # installed httpd. Use "apachectl -l" to find out the 27 | # active mpm. 28 | # 29 | 30 | # prefork MPM 31 | # StartServers: number of server processes to start 32 | # MinSpareServers: minimum number of server processes which are kept spare 33 | # MaxSpareServers: maximum number of server processes which are kept spare 34 | # MaxClients: maximum number of server processes allowed to start 35 | # MaxRequestsPerChild: maximum number of requests a server process serves 36 | 37 | StartServers 4 38 | MinSpareServers 2 39 | MaxSpareServers 8 40 | MaxClients 100 41 | MaxRequestsPerChild 800 42 | 43 | 44 | # worker MPM 45 | # StartServers: initial number of server processes to start 46 | # MaxClients: maximum number of simultaneous client connections 47 | # MinSpareThreads: minimum number of worker threads which are kept spare 48 | # MaxSpareThreads: maximum number of worker threads which are kept spare 49 | # ThreadsPerChild: constant number of worker threads in each server process 50 | # MaxRequestsPerChild: maximum number of requests a server process serves 51 | 52 | StartServers 2 53 | MaxClients 150 54 | MinSpareThreads 25 55 | MaxSpareThreads 75 56 | ThreadsPerChild 25 57 | MaxRequestsPerChild 0 58 | 59 | 60 | # BeOS MPM 61 | # StartThreads: how many threads do we initially spawn? 62 | # MaxClients: max number of threads we can have (1 thread == 1 client) 63 | # MaxRequestsPerThread: maximum number of requests each thread will process 64 | 65 | StartThreads 10 66 | MaxClients 50 67 | MaxRequestsPerThread 10000 68 | 69 | 70 | # NetWare MPM 71 | # ThreadStackSize: Stack size allocated for each worker thread 72 | # StartThreads: Number of worker threads launched at server startup 73 | # MinSpareThreads: Minimum number of idle threads, to handle request spikes 74 | # MaxSpareThreads: Maximum number of idle threads 75 | # MaxThreads: Maximum number of worker threads alive at the same time 76 | # MaxRequestsPerChild: Maximum number of requests a thread serves. It is 77 | # recommended that the default value of 0 be set for this 78 | # directive on NetWare. This will allow the thread to 79 | # continue to service requests indefinitely. 80 | 81 | ThreadStackSize 65536 82 | StartThreads 250 83 | MinSpareThreads 25 84 | MaxSpareThreads 250 85 | MaxThreads 1000 86 | MaxRequestsPerChild 0 87 | MaxMemFree 100 88 | 89 | 90 | # OS/2 MPM 91 | # StartServers: Number of server processes to maintain 92 | # MinSpareThreads: Minimum number of idle threads per process, 93 | # to handle request spikes 94 | # MaxSpareThreads: Maximum number of idle threads per process 95 | # MaxRequestsPerChild: Maximum number of connections per server process 96 | 97 | StartServers 2 98 | MinSpareThreads 5 99 | MaxSpareThreads 10 100 | MaxRequestsPerChild 0 101 | 102 | 103 | # WinNT MPM 104 | # ThreadsPerChild: constant number of worker threads in the server process 105 | # MaxRequestsPerChild: maximum number of requests a server process serves 106 | 107 | ThreadsPerChild 150 108 | MaxRequestsPerChild 0 109 | 110 | -------------------------------------------------------------------------------- /conf/server.crt: -------------------------------------------------------------------------------- 1 | Certificate: 2 | Data: 3 | Version: 3 (0x2) 4 | Serial Number: 1 (0x1) 5 | Signature Algorithm: sha1WithRSAEncryption 6 | Issuer: C=US, ST=CA, L=SanFrancisco, O=Fort-Funston, OU=changeme, CN=changeme/name=changeme/emailAddress=mail@host.domain 7 | Validity 8 | Not Before: Feb 12 05:38:11 2012 GMT 9 | Not After : Feb 9 05:38:11 2022 GMT 10 | Subject: C=US, ST=CA, L=SanFrancisco, O=Fort-Funston, OU=changeme, CN=changeme/name=changeme/emailAddress=mail@host.domain 11 | Subject Public Key Info: 12 | Public Key Algorithm: rsaEncryption 13 | Public-Key: (1024 bit) 14 | Modulus: 15 | 00:af:20:01:ce:d0:22:12:57:80:f0:ea:f2:18:c5: 16 | f9:eb:1e:50:db:dc:7e:21:28:f4:e3:84:73:3d:cf: 17 | 6e:89:9f:80:a5:c4:48:c0:d3:5b:c1:97:be:6e:e8: 18 | ce:6e:05:9d:3a:d5:41:be:51:d7:c6:b0:fb:da:b5: 19 | 13:f3:d7:06:b0:fe:f2:9d:23:fa:62:40:94:fd:89: 20 | d1:24:e4:2e:85:dd:42:ec:47:a4:1c:17:46:93:3d: 21 | b7:3f:54:87:5e:2b:46:aa:e5:68:e7:89:6a:89:5f: 22 | 26:92:82:bd:c7:df:93:ff:aa:b3:2c:27:2c:8d:a1: 23 | 09:b1:6f:81:9a:4f:f5:8c:6b 24 | Exponent: 65537 (0x10001) 25 | X509v3 extensions: 26 | X509v3 Basic Constraints: 27 | CA:FALSE 28 | Netscape Cert Type: 29 | SSL Server 30 | Netscape Comment: 31 | Easy-RSA Generated Server Certificate 32 | X509v3 Subject Key Identifier: 33 | A7:F4:E6:E5:23:6B:F7:3C:5C:4C:9F:23:44:38:0B:3D:CB:83:94:EF 34 | X509v3 Authority Key Identifier: 35 | keyid:6A:FE:1E:B3:8D:98:43:48:3A:8E:02:0B:34:C7:FB:C4:19:5F:7E:45 36 | DirName:/C=US/ST=CA/L=SanFrancisco/O=Fort-Funston/OU=changeme/CN=changeme/name=changeme/emailAddress=mail@host.domain 37 | serial:F5:FB:8D:8D:A8:0C:66:8D 38 | 39 | X509v3 Extended Key Usage: 40 | TLS Web Server Authentication 41 | X509v3 Key Usage: 42 | Digital Signature, Key Encipherment 43 | Signature Algorithm: sha1WithRSAEncryption 44 | 0c:1b:50:64:a7:68:41:f4:da:c1:d8:ca:f7:51:eb:a6:ed:24: 45 | 77:bf:82:f7:5e:57:88:c6:6b:15:60:73:24:3d:c1:6e:7f:2a: 46 | 66:6b:be:a0:44:9b:56:5b:c8:af:5d:21:80:10:43:a8:72:19: 47 | 23:a2:c5:da:c4:95:8c:c5:09:cb:0f:0e:d7:4f:63:b2:38:16: 48 | 14:42:63:38:ea:7a:75:e3:54:28:d1:29:77:f5:bd:44:02:43: 49 | 5a:ff:d7:e2:e3:f0:21:fe:4a:d2:fb:9d:0b:78:9f:1c:ff:87: 50 | 41:c2:db:39:d5:64:77:a1:ee:5a:22:46:50:47:d9:26:2f:e5: 51 | b9:d8 52 | -----BEGIN CERTIFICATE----- 53 | MIIEMTCCA5qgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBojELMAkGA1UEBhMCVVMx 54 | CzAJBgNVBAgTAkNBMRUwEwYDVQQHEwxTYW5GcmFuY2lzY28xFTATBgNVBAoTDEZv 55 | cnQtRnVuc3RvbjERMA8GA1UECxMIY2hhbmdlbWUxETAPBgNVBAMTCGNoYW5nZW1l 56 | MREwDwYDVQQpEwhjaGFuZ2VtZTEfMB0GCSqGSIb3DQEJARYQbWFpbEBob3N0LmRv 57 | bWFpbjAeFw0xMjAyMTIwNTM4MTFaFw0yMjAyMDkwNTM4MTFaMIGiMQswCQYDVQQG 58 | EwJVUzELMAkGA1UECBMCQ0ExFTATBgNVBAcTDFNhbkZyYW5jaXNjbzEVMBMGA1UE 59 | ChMMRm9ydC1GdW5zdG9uMREwDwYDVQQLEwhjaGFuZ2VtZTERMA8GA1UEAxMIY2hh 60 | bmdlbWUxETAPBgNVBCkTCGNoYW5nZW1lMR8wHQYJKoZIhvcNAQkBFhBtYWlsQGhv 61 | c3QuZG9tYWluMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvIAHO0CISV4Dw 62 | 6vIYxfnrHlDb3H4hKPTjhHM9z26Jn4ClxEjA01vBl75u6M5uBZ061UG+UdfGsPva 63 | tRPz1waw/vKdI/piQJT9idEk5C6F3ULsR6QcF0aTPbc/VIdeK0aq5WjniWqJXyaS 64 | gr3H35P/qrMsJyyNoQmxb4GaT/WMawIDAQABo4IBczCCAW8wCQYDVR0TBAIwADAR 65 | BglghkgBhvhCAQEEBAMCBkAwNAYJYIZIAYb4QgENBCcWJUVhc3ktUlNBIEdlbmVy 66 | YXRlZCBTZXJ2ZXIgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFKf05uUja/c8XEyfI0Q4 67 | Cz3Lg5TvMIHXBgNVHSMEgc8wgcyAFGr+HrONmENIOo4CCzTH+8QZX35FoYGopIGl 68 | MIGiMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFTATBgNVBAcTDFNhbkZyYW5j 69 | aXNjbzEVMBMGA1UEChMMRm9ydC1GdW5zdG9uMREwDwYDVQQLEwhjaGFuZ2VtZTER 70 | MA8GA1UEAxMIY2hhbmdlbWUxETAPBgNVBCkTCGNoYW5nZW1lMR8wHQYJKoZIhvcN 71 | AQkBFhBtYWlsQGhvc3QuZG9tYWluggkA9fuNjagMZo0wEwYDVR0lBAwwCgYIKwYB 72 | BQUHAwEwCwYDVR0PBAQDAgWgMA0GCSqGSIb3DQEBBQUAA4GBAAwbUGSnaEH02sHY 73 | yvdR66btJHe/gvdeV4jGaxVgcyQ9wW5/KmZrvqBEm1ZbyK9dIYAQQ6hyGSOixdrE 74 | lYzFCcsPDtdPY7I4FhRCYzjqenXjVCjRKXf1vUQCQ1r/1+Lj8CH+StL7nQt4nxz/ 75 | h0HC2znVZHeh7loiRlBH2SYv5bnY 76 | -----END CERTIFICATE----- 77 | -------------------------------------------------------------------------------- /docs/install.md: -------------------------------------------------------------------------------- 1 | ## 一、系统需求 2 | 3 | * 需要`2GB`以上磁盘剩余空间 4 | * 需要`256M`以上内存空间 5 | * 服务器必须配置好软件源和可连接外网 6 | * 必须具有系统`Root`权限 7 | * 建议使用干净系统全新安装 8 | 9 | ## 二、安装前准备 10 | 11 | 1. 使用`putty`或`Bitvise Tunnelier`等`SSH`工具登陆 12 | 13 | 登陆后运行:`screen -S lanmp` 14 | 15 | 1)关于`screen`请自行`Google`,简单说该命令可以防止网络中断等因素造成的安装失败。 16 | 2)如果提示`screen`命令不存在可以执行:`yum -y install screen` 安装。 17 | 18 | 2. 下载`LANMP`一键安装包 19 | 20 | 说明:稳定版是相对稳定的版本,开发版是更新频率较高的版本,带有新特性,但可能存在较多Bug。 21 | 22 | 方法一:直接下载已打包版本 23 | 24 | 1)下载稳定版:`wget -c http://wangyan.org/download/lanmp/lanmp-latest.tar.gz` 25 | 2)或者下载开发版:`wget -c http://wangyan.org/download/lanmp/lanmp-dev-latest.tar.gz` 26 | 2)开始安装:`cd lanmp && ./install.sh` 27 | 28 | 方法二:通过Git下载(推荐) 29 | 30 | 1)安装`Git`软件:`yum -y install git` 31 | 2)开始克隆:`git clone https://github.com/wangyan/lanmp.git` 32 | 3)安装稳定版: `cd lanmp && ./install.sh` 33 | 4)或者安装开发版: `cd lanmp && git checkout develop && ./install.sh` 34 | 35 | ## 三、安装步骤 36 | 37 | 1. 输入服务器公网IP地址(IPv4) 38 | 39 | 脚本默认会自动获取IP地址,如果发现不准确,请手工输入。 40 | 41 | 42 | 43 | 2. 输入默认网站目录 44 | 45 | 默认网站路径是 `/var/www`,虚拟主机数据目录是 `/home`,所以此项一般保持默认不要改动。 46 | 47 | 48 | 49 | 3. 输入`MySQL`数据库`Root`用户密码 50 | 51 | `MySQL`数据库`Root`最高权限用户密码,为安全起见,请尽可能使用复杂密码。 52 | 53 | 54 | 55 | 4. 输入`MySQL`数据库`PMA`用户密码 56 | 57 | `PMA`用户是为了让phpMyAdmin支持额外的链接表特性,该密码仅在安装时使用一次,因此你可以使用随机密码。 58 | 59 | 60 | 61 | 5. 请选择服务器架构 (重要) 62 | 63 | 1)单独 `Nginx`(`lnmp`):效率高,但不兼容`Apache`的`Rewrite`规则,低内存微型用户首选。 64 | 2)单独 `Apache` (`lamp`):经典组合,兼容性好,几乎所有程序都支持。 65 | 3)`Apache` + `Nginx (`lanmp`):`Nginx`作为前端处理静态文件,`Php`脚本转后端`Apache`处理,该架构可发挥`Nginx`处理静态文件优势,还可以作负载均衡,个人推荐。 66 | 67 | 68 | 69 | 6. 选择安装的`PHP`版本 70 | 71 | 默认是`PHP 5.4`系列,但有些程序需要旧版Zend支持如`ShopEX`,所以也可以安装旧版`PHP 5.2`系列 72 | 73 | 74 | 75 | 7. 是否要初始化阿里云服务器(选做) 76 | 77 | 1)程序会自动判断你是否使用的是阿里云服务器,非阿里云用户不会出现该选项。 78 | 2)如果选择是(y),那么程序会格式化数据盘,并挂载到/home目录。(适用于初次安装或重装系统后的用户) 79 | 80 | 81 | 82 | 8. 选择是否安装的`xCache`加速器 83 | 84 | 可大幅提高PHP性能,不需要犹豫,立即安装吧!这货甚至比`eaccelerator`还牛逼。 85 | 86 | 87 | 88 | 9. 选择是否安装的`ioncube` 89 | 90 | PHP解密工具,类似于`Zend Optimizer`,如果你不玩`WHMCS`,可以不装。 91 | 92 | 93 | 94 | 10. 选择是否安装的`Zend Optimizer` 95 | 96 | 如果您用的是开源程序,则可以不装。 97 | 注意:如果您上面选择安装的PHP版本是5.2,那么这里自动安装`Zend Optimizer`,否则自动安装`Zend GuardLoader` 98 | 99 | 100 | 101 | 11. 最后一步,按任意键开始安装。 102 | 103 | 注意:任意键可不包括主机电源键。。。 104 | 按 ` + c` 可放弃安装。 105 | 106 | 107 | 108 | ## 四、结束 109 | 110 | * 安装结束后,可看到下图,意思很明确了,请谨记该图中的帐号信息。 111 | * 在浏览器中打开图中所示的PHP探针地址,如:`http://192.168.8.134/p.php`,即可看到整个安装过程是否成功。 112 | * 部分VPS装有`iptables`防火墙,请使用下面命令关闭。`service iptables stop && chkconfig iptables off` 113 | * 安装失败的,请按下面提示进行反馈,谢谢! 114 | 115 | 116 | 117 | ## 五、反馈 118 | 119 | 如果安装失败,请您将安装目录下的`log.txt`日志文件发给我分析。 120 | 或者通过下面方式与我联系,谢谢! 121 | 122 | > Email: [WangYan@188.com](WangYan@188.com) 123 | > Twitter:[@wang_yan](https://twitter.com/wang_yan) 124 | > Home Page: [WangYan Blog](http://wangyan.org/blog) -------------------------------------------------------------------------------- /conf/init.d.httpd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Startup script for the Apache Web Server 3 | # chkconfig: 345 85 15 4 | # Description: Startup script for Apache webserver on Debian. Place in /etc/init.d and 5 | # run 'update-rc.d -f httpd defaults', or use the appropriate command on your 6 | # distro. For CentOS/Redhat run: 'chkconfig --add httpd' 7 | 8 | ### BEGIN INIT INFO 9 | # Provides: httpd 10 | # Required-Start: $all 11 | # Required-Stop: $all 12 | # Default-Start: 2 3 4 5 13 | # Default-Stop: 0 1 6 14 | # Short-Description: starts Apache Web Server 15 | # Description: starts Apache Web Server 16 | ### END INIT INFO 17 | 18 | # Author: licess 19 | # website: http://lnmp.org 20 | # 21 | # Licensed to the Apache Software Foundation (ASF) under one or more 22 | # contributor license agreements. See the NOTICE file distributed with 23 | # this work for additional information regarding copyright ownership. 24 | # The ASF licenses this file to You under the Apache License, Version 2.0 25 | # (the "License"); you may not use this file except in compliance with 26 | # the License. You may obtain a copy of the License at 27 | # 28 | # http://www.apache.org/licenses/LICENSE-2.0 29 | # 30 | # Unless required by applicable law or agreed to in writing, software 31 | # distributed under the License is distributed on an "AS IS" BASIS, 32 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 33 | # See the License for the specific language governing permissions and 34 | # limitations under the License. 35 | # 36 | # 37 | # Apache control script designed to allow an easy command line interface 38 | # to controlling Apache. Written by Marc Slemko, 1997/08/23 39 | # 40 | # The exit codes returned are: 41 | # XXX this doc is no longer correct now that the interesting 42 | # XXX functions are handled by httpd 43 | # 0 - operation completed successfully 44 | # 1 - 45 | # 2 - usage error 46 | # 3 - httpd could not be started 47 | # 4 - httpd could not be stopped 48 | # 5 - httpd could not be started during a restart 49 | # 6 - httpd could not be restarted during a restart 50 | # 7 - httpd could not be restarted during a graceful restart 51 | # 8 - configuration syntax error 52 | # 53 | # When multiple arguments are given, only the error from the _last_ 54 | # one is reported. Run "apachectl help" for usage info 55 | # 56 | ARGV="$@" 57 | # 58 | # |||||||||||||||||||| START CONFIGURATION SECTION |||||||||||||||||||| 59 | # -------------------- -------------------- 60 | # 61 | # the path to your httpd binary, including options if necessary 62 | HTTPD='/usr/local/apache/bin/httpd' 63 | # 64 | # pick up any necessary environment variables 65 | if test -f /usr/local/apache/bin/envvars; then 66 | . /usr/local/apache/bin/envvars 67 | fi 68 | # 69 | # a command that outputs a formatted text version of the HTML at the 70 | # url given on the command line. Designed for lynx, however other 71 | # programs may work. 72 | LYNX="lynx -dump" 73 | # 74 | # the URL to your server's mod_status status page. If you do not 75 | # have one, then status and fullstatus will not work. 76 | STATUSURL="http://localhost:80/server-status" 77 | # 78 | # Set this variable to a command that increases the maximum 79 | # number of file descriptors allowed per child process. This is 80 | # critical for configurations that use many file descriptors, 81 | # such as mass vhosting, or a multithreaded server. 82 | ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`" 83 | # -------------------- -------------------- 84 | # |||||||||||||||||||| END CONFIGURATION SECTION |||||||||||||||||||| 85 | 86 | # Set the maximum number of file descriptors allowed per child process. 87 | if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then 88 | $ULIMIT_MAX_FILES 89 | fi 90 | 91 | ERROR=0 92 | if [ "x$ARGV" = "x" ] ; then 93 | ARGV="-h" 94 | fi 95 | 96 | case $ARGV in 97 | start|stop|restart|graceful|graceful-stop) 98 | $HTTPD -k $ARGV 99 | ERROR=$? 100 | ;; 101 | startssl|sslstart|start-SSL) 102 | echo The startssl option is no longer supported. 103 | echo Please edit httpd.conf to include the SSL configuration settings 104 | echo and then use "apachectl start". 105 | ERROR=2 106 | ;; 107 | configtest) 108 | $HTTPD -t 109 | ERROR=$? 110 | ;; 111 | status) 112 | $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' 113 | ;; 114 | fullstatus) 115 | $LYNX $STATUSURL 116 | ;; 117 | *) 118 | $HTTPD $ARGV 119 | ERROR=$? 120 | esac 121 | 122 | exit $ERROR -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 3 | export PATH 4 | 5 | if [ $(id -u) != "0" ]; then 6 | printf "Error: You must be root to run this script!" 7 | exit 1 8 | fi 9 | 10 | LANMP_PATH=`pwd` 11 | if [ `echo $LANMP_PATH | awk -F/ '{print $NF}'` != "lanmp" ]; then 12 | clear && echo "Please enter lanmp script path:" 13 | read -p "(Default path: ${LANMP_PATH}/lanmp):" LANMP_PATH 14 | [ -z "$LANMP_PATH" ] && LANMP_PATH=$(pwd)/lanmp 15 | cd $LANMP_PATH/ 16 | fi 17 | 18 | clear 19 | echo "#############################################################" 20 | echo "# LANMP Auto Uninstall Shell Scritp" 21 | echo "# Env: Debian/Ubuntu/Redhat/CentOS" 22 | echo "# Version: $(awk '/version/{print $2}' $LANMP_PATH/Changelog)" 23 | echo "" 24 | echo "# Copyright (c) 2011, WangYan " 25 | echo "# All rights reserved." 26 | echo "# Distributed under the GNU General Public License, version 3.0." 27 | echo "#" 28 | echo "#############################################################" 29 | echo "" 30 | 31 | echo "Are you sure uninstall LANMP? (y/n)" 32 | read -p "(Default: n):" UNINSTALL 33 | if [ -z $UNINSTALL ]; then 34 | UNINSTALL="n" 35 | fi 36 | if [ "$UNINSTALL" != "y" ]; then 37 | clear 38 | echo "===========================" 39 | echo "You canceled the uninstall!" 40 | echo "===========================" 41 | exit 42 | else 43 | echo "---------------------------" 44 | echo "Yes, I decided to uninstall!" 45 | echo "---------------------------" 46 | echo "" 47 | fi 48 | 49 | get_char() 50 | { 51 | SAVEDSTTY=`stty -g` 52 | stty -echo 53 | stty cbreak 54 | dd if=/dev/tty bs=1 count=1 2> /dev/null 55 | stty -raw 56 | stty echo 57 | stty $SAVEDSTTY 58 | } 59 | echo "Press any key to start uninstall..." 60 | echo "Or Ctrl+C cancel and exit ?" 61 | char=`get_char` 62 | echo "" 63 | 64 | if [ "$UNINSTALL" = 'y' ]; then 65 | 66 | echo "---------- MySQL ----------" 67 | 68 | if cat /proc/version | grep -Eqi '(redhat|centos)';then 69 | chkconfig mysql off 70 | elif cat /proc/version | grep -Eqi '(debian|ubuntu)';then 71 | update-rc.d -f mysql remove 72 | fi 73 | 74 | /etc/init.d/mysql stop 75 | killall mysqld 76 | userdel mysql 77 | groupdel mysql 78 | rm -rf /etc/init.d/mysql 79 | rm -rf /usr/local/mysql 80 | rm -rf /etc/my.cnf 81 | rm -rf /usr/bin/mysql* 82 | sed -i 's/\/usr\/local\/mysql\/lib//g' /etc/ld.so.conf 83 | 84 | echo "---------- Apache ----------" 85 | 86 | if cat /proc/version | grep -Eqi '(redhat|centos)';then 87 | chkconfig httpd off 88 | elif cat /proc/version | grep -Eqi '(debian|ubuntu)';then 89 | update-rc.d -f httpd remove 90 | fi 91 | 92 | /etc/init.d/httpd stop 93 | killall httpd 94 | userdel www 95 | groupdel www 96 | rm -rf /etc/init.d/httpd 97 | rm -rf /usr/local/apache 98 | rm -rf /usr/local/apr 99 | rm -rf /usr/bin/apachectl 100 | rm -rf /usr/bin/httpd 101 | rm -rf /usr/bin/ab 102 | 103 | echo "---------- PHP ----------" 104 | 105 | cd $LANMP_PATH/src/libpng-*/ 106 | make uninstall 107 | 108 | cd $LANMP_PATH/src/jpeg-*/ 109 | make uninstall 110 | 111 | cd $LANMP_PATH/src/libiconv-*/ 112 | make uninstall 113 | 114 | cd $LANMP_PATH/src/libmcrypt-*/ 115 | make uninstall 116 | 117 | cd $LANMP_PATH/src/mhash-*/ 118 | make uninstall 119 | 120 | cd $LANMP_PATH/src/mcrypt-*/ 121 | make uninstall 122 | 123 | if [ -s /usr/local/php/sbin/php-fpm ]; then 124 | /usr/local/php/sbin/php-fpm stop 125 | killall php-fpm 126 | if cat /proc/version | grep -Eqi '(redhat|centos)';then 127 | chkconfig php-fpm off 128 | elif cat /proc/version | grep -Eqi '(debian|ubuntu)';then 129 | update-rc.d -f php-fpm remove 130 | fi 131 | rm -rf /etc/init.d/php-fpm 132 | fi 133 | 134 | rm -rf /usr/local/php 135 | rm -rf /usr/local/zend 136 | rm -rf /var/www/xcache 137 | rm -rf /tmp/{pcov,phpcore} 138 | rm -rf /usr/bin/php* 139 | 140 | echo "---------- nginx ----------" 141 | 142 | cd $LANMP_PATH/src/pcre-*/ 143 | make uninstall 144 | 145 | if cat /proc/version | grep -Eqi '(redhat|centos)';then 146 | chkconfig nginx off 147 | elif cat /proc/version | grep -Eqi '(debian|ubuntu)';then 148 | update-rc.d -f nginx remove 149 | fi 150 | 151 | /etc/init.d/nginx stop 152 | killall nginx 153 | userdel nginx 154 | groupdel nginx 155 | 156 | rm -rf /etc/init.d/nginx 157 | rm -rf /usr/local/nginx 158 | rm -rf /var/tmp/nginx 159 | rm -rf /usr/sbin/nginx* 160 | 161 | echo "---------- phpmyadmin ----------" 162 | 163 | rm -rf /var/www/phpmyadmin 164 | 165 | echo "===========================" 166 | echo "Uninstall completed!" 167 | echo "===========================" 168 | fi 169 | -------------------------------------------------------------------------------- /Changelog: -------------------------------------------------------------------------------- 1 | 一、当前版本 2 | 3 | version 0.5.09.21.99 4 | - 修复获取最新PHP版本方法失效BUG 5 | 6 | 二、更新历史 7 | 8 | v0.5.08.31.98 9 | - 更新雅黑探针至0.4.7 10 | 11 | v0.5.08.30.97 12 | - 修复phpMyAdmin高级功能失效BUG 13 | 14 | v0.5.08.30.96 15 | - 移除Ioncube扩展(PHP5.5) 16 | 17 | v0.5.08.30.95 18 | - 新增opcache支持(PHP5.5) 19 | 20 | v0.5.08.30.94 21 | - 修复PHP扩展路径错误 22 | 23 | v0.5.08.29.93 24 | - 更新apache至2.2.25 25 | 26 | v0.5.08.29.92 27 | - 更新php至5.5x 28 | 29 | v0.5.08.29.91 30 | - 更新xcache至3.03 31 | 32 | v0.5.05.18.90 33 | - 修复libmcrypt备选下载方法错误 34 | 35 | v0.5.04.18.89 36 | - 更正Nginx官方下载链接 37 | 38 | v0.5.04.18.88 39 | - 升级Apache版本为2.2.24 40 | 41 | v0.5.02.23.87 42 | - 完善获取nginx及phpMyAdmin最新版本号的方法 43 | 44 | v0.5.02.23.86 45 | - 调整MySQL5.6编译选项 46 | 47 | v0.5.02.21.85 48 | - 修复mysql5.6系列编译错误 49 | 50 | v0.5.02.18.84 51 | - 改进获取phpMyAdmin最新版本号的方法 52 | 53 | v0.5.02.18.83 54 | - MySQL 更新到5.6系列 55 | 56 | v0.5.02.18.82 57 | - 修复Debian系统出现的依赖包安装错误 58 | 59 | v0.5.02.18.81 60 | - 安装前进行网络检查 61 | 62 | v0.4.12.09.80 63 | - 修复失效的PHP官方下载链接 64 | 65 | v0.4.10.26.79 66 | - 完善下载链接,确保都有备用下载地址 67 | 68 | v0.4.10.25.78 69 | - 修复centos中apache及nginx自启动的错误 70 | 71 | v0.4.10.23.77 72 | - 完善升级脚本 73 | 74 | v0.4.10.23.76 75 | - 修复因关闭pathinfo而导致typecho伪静态规则失效问题 76 | 77 | v0.4.9.27.75 78 | - 发布v0.4稳定版 79 | 80 | v0.4.9.26.74 81 | - 移除PHP IMAP扩展支持 82 | 83 | v0.3.9.25.73 84 | - 正式发布v0.3稳定版 85 | 86 | v0.2.9.24.72 87 | - 大幅修改PHP安装步骤 88 | 89 | v0.2.9.22.71 90 | - 新增docs目录,内容是帮助文档 91 | 92 | v0.2.9.22.70 93 | - 将所有相对路径改为绝对路径 94 | 95 | v0.2.9.22.69 96 | - 修复在特定情况下phpMyAdmin版本号记录出错 97 | 98 | v0.2.9.22.68 99 | - 修改备用下载地址 100 | 101 | v0.2.9.22.67 102 | - 修改配置文件编码为UTF-8 103 | 104 | v0.2.9.22.66 105 | - 修改PHP-FPM为unix socket方式 106 | 107 | v0.2.9.22.65 108 | - 调整Session默认值为1440 109 | 110 | v0.2.9.22.64 111 | - 修改PHP-5.4.x编译选项 112 | 113 | v0.2.9.21.63 114 | - 解决php-5.2.17编译安装错误 115 | 116 | v0.2.9.12.62 117 | - 新增升级脚本,支持PHP、Nginx、phpMyAdmin自动升级 118 | 119 | v0.2.9.12.61 120 | - 规范版本号,发布v0.2版 121 | 122 | v0.1.9.11.60 123 | - 精简获取PHP版本号的代码 124 | 125 | v0.1.9.11.59 126 | - 为解压缩函数指定下载及解压路径 127 | 128 | v0.1.9.11.58 129 | - 支持自动下载PHP的最新版本 130 | 131 | v0.1.9.11.57 132 | - 记录所安装的phpMyAdmin版本号 133 | 134 | v0.1.9.08.56 135 | - 更正阿里云服务器网关IP地址 136 | 137 | v0.1.9.08.55 138 | - 替换部分官方下载链接 139 | 140 | v0.1.9.08.54 141 | - 支持阿里云服务器初始化 142 | 143 | v0.1.8.18.53 144 | - 修复Proxy_cache无命中的Bug 145 | 146 | v0.1.8.18.52 147 | - 更新PHP版本到5.4.6 148 | 149 | v0.1.8.18.51 150 | - Nginx默认启用proxy_cache缓存 151 | 152 | v0.1.8.06.50 153 | - 调低xCache缓存值 154 | 155 | v0.1.8.05.49 156 | - 完善获取外网IP的方法 157 | 158 | v0.1.8.05.48 159 | - 更新PHP版本到5.4.5 160 | 161 | v0.1.8.05.47 162 | - 完善卸载脚本 163 | 164 | v0.1.8.04.46 165 | - 完善对系统发行版的判断 166 | 167 | v0.1.8.03.45 168 | - 默认启用nginx status 169 | 170 | v0.1.8.02.44 171 | - 添加QQ群联系方式 172 | 173 | v0.1.8.01.43 174 | - README文件添加Gtalk和QQ两种联系方式 175 | 176 | v0.1.8.01.42 177 | - README文件添加简要的安装和使用说明 178 | 179 | v0.1.8.01.41 180 | - 删除虚拟主机默认不删除数据库 181 | 182 | v0.1.8.01.40 183 | - 设置虚拟主机数据库初始密码为123456 184 | 185 | v0.1.8.01.39 186 | - 安装结束后移动源码到src目录保存 187 | 188 | v0.1.8.01.38 189 | - 更新README文件 190 | 191 | v0.1.7.30.37 192 | - 更新README说明 193 | 194 | v0.1.7.30.36 195 | - 兼容阿里云,允许更新内核。 196 | 197 | v0.1.7.30.35 198 | - 修改localhost为127.0.0.1 199 | 200 | v0.1.7.21.34 201 | - 修复Zend扩展安装错误 202 | 203 | v0.1.7.21.33 204 | - 修复IMAP扩展安装错误 205 | 206 | v0.1.7.21.32 207 | - 增加IMAP扩展支持 208 | 209 | v0.1.7.21.31 210 | - 改进Zend扩展的安装步骤 211 | 212 | v0.1.7.21.30 213 | - 修复pdo_mysql安装错误 214 | 215 | v0.1.7.21.29 216 | - 修复apr-util安装错误 217 | 218 | v0.1.7.21.28 219 | - 更新雅黑探针为v0.45版 220 | 221 | v0.1.7.20.27 222 | - 添加主机用户默认不添加数据库 223 | 224 | v0.1.7.20.26 225 | - 完善Nginx前端时的虚拟主机配置文件 226 | 227 | v0.1.7.19.25 228 | - 修复编译apache时可能出现的apr错误 229 | 230 | v0.1.7.19.24 231 | - 升级ioncube loader版本为5.4 232 | 233 | v0.1.7.19.23 234 | - 将eAccelerator替换为XCache 235 | 236 | v0.1.7.19.22 237 | - 修复PDO MYSQL扩展安装错误 238 | 239 | v0.1.7.19.21 240 | - 修复新版PHP扩展路径错误 241 | 242 | v0.1.7.10.20 243 | - 修复Apache出现 _default_vitualhost overlap 警告 244 | 245 | v0.1.7.10.19 246 | - 修复Apache出现 no virtualhosts 警告 247 | 248 | v0.1.7.07.18 249 | - 修复无法获取最新版本MySQL的BUG 250 | 251 | v0.1.7.04.17 252 | - Apache+Nginx架构时,Apache不开启SSL 253 | 254 | v0.1.6.23.16 255 | - Apache增加SSL支持 256 | 257 | v0.1.6.23.15 258 | - 将ssl.crt改名为server.crt 259 | 260 | v0.1.6.23.14 261 | - Apache 允许目录浏览 262 | 263 | v0.1.6.23.13 264 | - 增加新的README文件 265 | 266 | v0.1.6.23.12 267 | - 删除过时的README文件 268 | 269 | v0.1.6.23.11 270 | - 升级php版本至5.4.4 271 | 272 | v0.1.4.16.10 273 | - Apache默认开启headers和expires扩展 274 | 275 | v0.1.4.16.9 276 | - 修复phpMyAdmin3.5以上版本,找不到create_tables.sql的错误 277 | 278 | v0.1.4.16.8 279 | - 升级php版本至5.4.0 280 | 281 | v0.1.2.29.7 282 | - nginx增加ipv6支持 283 | 284 | v0.1.2.29.6 285 | - 修复httpd.conf备份文件被覆盖 286 | 287 | v0.1.2.28.5 288 | - 设置Apache版本为2.2.22,不再自动安装最新版 289 | 290 | v0.1.2.28.4 291 | - 设置MySQL默认引擎为MyISAM 292 | 293 | v0.1.2.27.3 294 | - 修复Apache的extra文件夹误删问题 295 | 296 | v0.1.2.27.2 297 | - 修复MySQL备用下载地址错误 298 | 299 | v0.1.2.20.1 300 | - 首次提交 301 | -------------------------------------------------------------------------------- /docs/vhost_add.md: -------------------------------------------------------------------------------- 1 | ## 一、概述 2 | 3 | * 安装完成后请添加首个虚拟主机用户(`/home/user1`),不建议您直接将网站放置在默认的网站目录`/var/www`。 4 | * 本教程会分两种情况讲解。一种是`lnmp`架构,另外一种是`lamp`和`lanmp`架构。 5 | * `LANMP` 指的是 `Linux` + `Apache` + `Nginx` + `MySQL` + `PHP` 运行环境。 ([了解更多](https://github.com/wangyan/lanmp/wiki/LANMP-%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E5%8C%85%E7%AE%80%E4%BB%8B)) 6 | 7 | ## 二、添加虚拟主机用户(共同步骤) 8 | 9 | 1. 进入安装目录并运行添加虚拟主机脚本 10 | 11 | cd lanmp/ 12 | ./vhost_add.sh 13 | 14 | 15 | 16 | 2. 请输入虚拟主机用户帐号 17 | 18 | 用户目录位于`/home/username`,另外该帐号会作为默认的数据库用户名和数据库名(可修改) 19 | 20 | 21 | 22 | 3. 询问是否添加`FTP`帐号 23 | 24 | 注意:添加`FTP`帐号的前提是,你已经安装了`pureftpd`并且安装了`pureftpd`图像管理界面。(本人有提供一键安装脚本) 25 | 26 | 27 | 28 | 4. 询问是否添加`MySQL`数据库 29 | 30 | 1)默认不添加,如果需要添加请输入`y` 31 | 2)然后输入MySQL的Root密码。(注意是ROOT用户密码) 32 | 33 | 34 | 35 | 5. 请输入`MySQL`数据库名及用户密码 36 | 37 | 1)`MySQL`数据库名和数据库用户名,默认为您的虚拟主机帐号 38 | 2)如果您上面添加了FTP用户,那么默认的密码为FTP密码,否则为123456 39 | 40 | 41 | 42 | 6. 请输入网站域名 43 | 44 | 1)注意是域名不包含`WWW` 45 | 2)脚本会自动判断,您输入的域名是否已经添加过。 46 | 47 | 48 | 49 | ## 三、添加虚拟主机用户(`LNMP`) 50 | 51 | > 注意:该部分教程仅适用单独使用`Nginx`用户(`lnmp`) 52 | > 如果您当时安装的是`lamp`或`lanmp`架构,请跳过此节,直接移步到第四部分。 53 | 54 | 1. 请选择服务器架构 55 | 56 | 1)注意:这里要输入`1` 57 | 2)单独使用`NGINX`的特点是,效率高,但不兼容`Apache`的`Rewrite`规则,低内存微型用户首选。 58 | 59 | 60 | 61 | 2. 请选择是否载入NGINX `rewrite`规则? 62 | 63 | 默认值为`否`,如果您程序需要支持`伪静态`,请输入`y` 64 | 65 | 66 | 67 | 3. 请选择预置的`rewrite`规则 (可选步骤) 68 | 69 | 1)Nginx和Apache的重写规则不同,你需要单独定义,这里提供一些常见的规则供您选择。 70 | 2)目前已经预置的规则有:`wordpress`、`discuzx`、`discuzx`、`ecshop`、`sablog`、`typecho` 71 | 3)如果您输入的程序名`XXX`没有预置规则,则脚本自动在`/usr/local/nginx/conf/`目录创建`XXX.conf`文件,您需要另外编辑该文件。 72 | 73 | 74 | 75 | 4. 选择是否添加二级子域名? 76 | 77 | 注意:一次添加,要么是一级域名(`wangyan.org`),要么是二级子域名(`bbs.wangyan.org`)。 78 | 79 | 80 | 81 | 5. 最后一步,按任意键开始添加用户。 82 | 83 | 注意:任意键可不包括主机电源键。。。 84 | 按 ` + c` 可放弃安装。 85 | 86 | 87 | 88 | ## 四、添加虚拟主机用户(`LANMP`) 89 | 90 | > 注意:该部分教程仅适用于使用`Apache`+`Nginx`用户(`lanmp`) 91 | > 如果您当时安装的是`lnmp`架构,请移步到上一节,即到第三部分。 92 | 93 | 1. 请选择服务器架构 94 | 95 | 1)注意:这里要输入`3` 96 | 2)使用`Apache` + `Nginx (`lanmp`)的特点是,Nginx`作为前端处理静态文件,`Php`脚本转后端`Apache`处理,该架构可发挥`Nginx`处理静态文件优势,还可以作负载均衡,个人推荐。 97 | 98 | 99 | 100 | 2. 选择是否添加二级子域名? 101 | 102 | 注意:一次添加,要么是一级域名(`wangyan.org`),要么是二级子域名(`bbs.wangyan.org`)。 103 | 104 | 105 | 106 | 3. 最后一步,按任意键开始添加用户。 107 | 108 | 注意:任意键可不包括主机电源键。。。 109 | 按 ` + c` 可放弃安装。 110 | 111 | 112 | 113 | ## 五、结束 114 | 115 | * 安装结束后,可看到下图。 116 | * 上半部分的意思是运行`nginx -t`和`apache -t`命令测试NGINX和APACHE添加用户是否成功,OK就表示成功了。 117 | * 下半部分是给出了该虚拟主机用户的账户信息,请谨记。 118 | * 最后,在浏览器中输入该该虚拟主机用户的域名,如:`http://example.com`,如果看到`example.com`则表示一切正常。 119 | * 再最后?没有了,已经大功告成了。 120 | * 安装失败的,请按下面提示进行反馈,谢谢! 121 | 122 | 123 | 124 | ## 六、反馈 125 | 126 | 如果添加虚拟主机用户失败,请您运行`nginx -t`和`apache -t`命令,然后将截图发给我。 127 | 或者通过下面方式与我联系,谢谢! 128 | 129 | > Email: [WangYan@188.com](WangYan@188.com) 130 | > Twitter:[@wang_yan](https://twitter.com/wang_yan) 131 | > Home Page: [WangYan Blog](http://wangyan.org/blog) -------------------------------------------------------------------------------- /conf/my.cnf: -------------------------------------------------------------------------------- 1 | # Example MySQL config file for medium systems. 2 | # 3 | # This is for a system with little memory (32M - 64M) where MySQL plays 4 | # an important part, or systems up to 128M where MySQL is used together with 5 | # other programs (such as a web server) 6 | # 7 | # MySQL programs look for option files in a set of 8 | # locations which depend on the deployment platform. 9 | # You can copy this option file to one of those 10 | # locations. For information about these locations, see: 11 | # http://dev.mysql.com/doc/mysql/en/option-files.html 12 | # 13 | # In this file, you can use all long options that a program supports. 14 | # If you want to know which options a program supports, run the program 15 | # with the "--help" option. 16 | 17 | # The following options will be passed to all MySQL clients 18 | [client] 19 | #password = your_password 20 | port = 3306 21 | socket = /tmp/mysql.sock 22 | 23 | # Here follows entries for some specific programs 24 | 25 | # The MySQL server 26 | [mysqld] 27 | # bind-address = 127.0.0.1 28 | port = 3306 29 | socket = /tmp/mysql.sock 30 | skip-external-locking 31 | key_buffer_size = 16M 32 | max_allowed_packet = 1M 33 | table_open_cache = 64 34 | sort_buffer_size = 512K 35 | net_buffer_length = 8K 36 | read_buffer_size = 256K 37 | read_rnd_buffer_size = 512K 38 | myisam_sort_buffer_size = 8M 39 | default-storage-engine = MyISAM 40 | loose-skip-innodb 41 | 42 | # Don't listen on a TCP/IP port at all. This can be a security enhancement, 43 | # if all processes that need to connect to mysqld run on the same host. 44 | # All interaction with mysqld must be made via Unix sockets or named pipes. 45 | # Note that using this option without enabling named pipes on Windows 46 | # (via the "enable-named-pipe" option) will render mysqld useless! 47 | # 48 | #skip-networking 49 | 50 | # Replication Master Server (default) 51 | # binary logging is required for replication 52 | log-bin=mysql-bin 53 | 54 | # binary logging format - mixed recommended 55 | binlog_format=mixed 56 | 57 | # required unique id between 1 and 2^32 - 1 58 | # defaults to 1 if master-host is not set 59 | # but will not function as a master if omitted 60 | server-id = 1 61 | # binlog-ignore-db=phpmyadmin 62 | # innodb_flush_log_at_trx_commit=1 63 | # slave-skip-errors=all 64 | # log-slave-updates 65 | # sync_binlog=1 66 | # auto_increment_offset=2 67 | # auto_increment_increment=1 68 | 69 | # Replication Slave (comment out master section to use this) 70 | # 71 | # To configure this host as a replication slave, you can choose between 72 | # two methods : 73 | # 74 | # 1) Use the CHANGE MASTER TO command (fully described in our manual) - 75 | # the syntax is: 76 | # 77 | # CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=, 78 | # MASTER_USER=, MASTER_PASSWORD= ; 79 | # 80 | # where you replace , , by quoted strings and 81 | # by the master's port number (3306 by default). 82 | # 83 | # Example: 84 | # 85 | # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, 86 | # MASTER_USER='joe', MASTER_PASSWORD='secret'; 87 | # 88 | # OR 89 | # 90 | # 2) Set the variables below. However, in case you choose this method, then 91 | # start replication for the first time (even unsuccessfully, for example 92 | # if you mistyped the password in master-password and the slave fails to 93 | # connect), the slave will create a master.info file, and any later 94 | # change in this file to the variables' values below will be ignored and 95 | # overridden by the content of the master.info file, unless you shutdown 96 | # the slave server, delete master.info and restart the slaver server. 97 | # For that reason, you may want to leave the lines below untouched 98 | # (commented) and instead use CHANGE MASTER TO (see above) 99 | # 100 | # required unique id between 2 and 2^32 - 1 101 | # (and different from the master) 102 | # defaults to 2 if master-host is set 103 | # but will not function as a slave if omitted 104 | #server-id = 2 105 | # 106 | # The replication master for this slave - required 107 | #master-host = 108 | # 109 | # The username the slave will use for authentication when connecting 110 | # to the master - required 111 | #master-user = 112 | # 113 | # The password the slave will authenticate with when connecting to 114 | # the master - required 115 | #master-password = 116 | # 117 | # The port the master is listening on. 118 | # optional - defaults to 3306 119 | #master-port = 120 | # 121 | # binary logging - not required for slaves, but recommended 122 | #log-bin=mysql-bin 123 | 124 | # Uncomment the following if you are using InnoDB tables 125 | #innodb_data_home_dir = /usr/local/mysql/data 126 | #innodb_data_file_path = ibdata1:10M:autoextend 127 | #innodb_log_group_home_dir = /usr/local/mysql/data 128 | # You can set .._buffer_pool_size up to 50 - 80 % 129 | # of RAM but beware of setting memory usage too high 130 | #innodb_buffer_pool_size = 16M 131 | #innodb_additional_mem_pool_size = 2M 132 | # Set .._log_file_size to 25 % of buffer pool size 133 | #innodb_log_file_size = 5M 134 | #innodb_log_buffer_size = 8M 135 | #innodb_flush_log_at_trx_commit = 1 136 | #innodb_lock_wait_timeout = 50 137 | 138 | [mysqldump] 139 | quick 140 | max_allowed_packet = 16M 141 | 142 | [mysql] 143 | no-auto-rehash 144 | # Remove the next comment character if you are not familiar with SQL 145 | #safe-updates 146 | 147 | [myisamchk] 148 | key_buffer_size = 20M 149 | sort_buffer_size = 20M 150 | read_buffer = 2M 151 | write_buffer = 2M 152 | 153 | [mysqlhotcopy] 154 | interactive-timeout 155 | -------------------------------------------------------------------------------- /conf/sshd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # sshd Start up the OpenSSH server daemon 4 | # 5 | # chkconfig: 2345 55 25 6 | # description: SSH is a protocol for secure remote shell access. \ 7 | # This service starts up the OpenSSH server daemon. 8 | # 9 | # processname: sshd 10 | # config: /etc/ssh/ssh_host_key 11 | # config: /etc/ssh/ssh_host_key.pub 12 | # config: /etc/ssh/ssh_random_seed 13 | # config: /etc/ssh/sshd_config 14 | # pidfile: /var/run/sshd.pid 15 | 16 | ### BEGIN INIT INFO 17 | # Provides: sshd 18 | # Required-Start: $local_fs $network $syslog 19 | # Required-Stop: $local_fs $syslog 20 | # Should-Start: $syslog 21 | # Should-Stop: $network $syslog 22 | # Default-Start: 2 3 4 5 23 | # Default-Stop: 0 1 6 24 | # Short-Description: Start up the OpenSSH server daemon 25 | # Description: SSH is a protocol for secure remote shell access. 26 | # This service starts up the OpenSSH server daemon. 27 | ### END INIT INFO 28 | 29 | # source function library 30 | . /etc/rc.d/init.d/functions 31 | 32 | # pull in sysconfig settings 33 | [ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd 34 | 35 | RETVAL=0 36 | prog="sshd" 37 | lockfile=/var/lock/subsys/$prog 38 | 39 | # Some functions to make the below more readable 40 | KEYGEN=/usr/bin/ssh-keygen 41 | SSHD=/usr/sbin/sshd 42 | RSA1_KEY=/etc/ssh/ssh_host_key 43 | RSA_KEY=/etc/ssh/ssh_host_rsa_key 44 | DSA_KEY=/etc/ssh/ssh_host_dsa_key 45 | PID_FILE=/var/run/sshd.pid 46 | 47 | runlevel=$(set -- $(runlevel); eval "echo \$$#" ) 48 | 49 | do_rsa1_keygen() { 50 | if [ ! -s $RSA1_KEY ]; then 51 | echo -n $"Generating SSH1 RSA host key: " 52 | rm -f $RSA1_KEY 53 | if test ! -f $RSA1_KEY && $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then 54 | chmod 600 $RSA1_KEY 55 | chmod 644 $RSA1_KEY.pub 56 | if [ -x /sbin/restorecon ]; then 57 | /sbin/restorecon $RSA1_KEY.pub 58 | fi 59 | success $"RSA1 key generation" 60 | echo 61 | else 62 | failure $"RSA1 key generation" 63 | echo 64 | exit 1 65 | fi 66 | fi 67 | } 68 | 69 | do_rsa_keygen() { 70 | if [ ! -s $RSA_KEY ]; then 71 | echo -n $"Generating SSH2 RSA host key: " 72 | rm -f $RSA_KEY 73 | if test ! -f $RSA_KEY && $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then 74 | chmod 600 $RSA_KEY 75 | chmod 644 $RSA_KEY.pub 76 | if [ -x /sbin/restorecon ]; then 77 | /sbin/restorecon $RSA_KEY.pub 78 | fi 79 | success $"RSA key generation" 80 | echo 81 | else 82 | failure $"RSA key generation" 83 | echo 84 | exit 1 85 | fi 86 | fi 87 | } 88 | 89 | do_dsa_keygen() { 90 | if [ ! -s $DSA_KEY ]; then 91 | echo -n $"Generating SSH2 DSA host key: " 92 | rm -f $DSA_KEY 93 | if test ! -f $DSA_KEY && $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then 94 | chmod 600 $DSA_KEY 95 | chmod 644 $DSA_KEY.pub 96 | if [ -x /sbin/restorecon ]; then 97 | /sbin/restorecon $DSA_KEY.pub 98 | fi 99 | success $"DSA key generation" 100 | echo 101 | else 102 | failure $"DSA key generation" 103 | echo 104 | exit 1 105 | fi 106 | fi 107 | } 108 | 109 | do_restart_sanity_check() 110 | { 111 | $SSHD -t 112 | RETVAL=$? 113 | if [ $RETVAL -ne 0 ]; then 114 | failure $"Configuration file or keys are invalid" 115 | echo 116 | fi 117 | } 118 | 119 | start() 120 | { 121 | [ -x $SSHD ] || exit 5 122 | [ -f /etc/ssh/sshd_config ] || exit 6 123 | # Create keys if necessary 124 | if [ "x${AUTOCREATE_SERVER_KEYS}" != xNO ]; then 125 | do_rsa1_keygen 126 | do_rsa_keygen 127 | do_dsa_keygen 128 | fi 129 | 130 | echo -n $"Starting $prog: " 131 | $SSHD $OPTIONS && success || failure 132 | RETVAL=$? 133 | [ $RETVAL -eq 0 ] && touch $lockfile 134 | echo 135 | return $RETVAL 136 | } 137 | 138 | stop() 139 | { 140 | echo -n $"Stopping $prog: " 141 | if [ -n "`pidfileofproc $SSHD`" ] ; then 142 | killproc $SSHD 143 | else 144 | failure $"Stopping $prog" 145 | fi 146 | RETVAL=$? 147 | # if we are in halt or reboot runlevel kill all running sessions 148 | # so the TCP connections are closed cleanly 149 | if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then 150 | trap '' TERM 151 | killall $prog 2>/dev/null 152 | trap TERM 153 | fi 154 | [ $RETVAL -eq 0 ] && rm -f $lockfile 155 | echo 156 | } 157 | 158 | reload() 159 | { 160 | echo -n $"Reloading $prog: " 161 | if [ -n "`pidfileofproc $SSHD`" ] ; then 162 | killproc $SSHD -HUP 163 | else 164 | failure $"Reloading $prog" 165 | fi 166 | RETVAL=$? 167 | echo 168 | } 169 | 170 | restart() { 171 | stop 172 | start 173 | } 174 | 175 | force_reload() { 176 | restart 177 | } 178 | 179 | rh_status() { 180 | status -p $PID_FILE openssh-daemon 181 | } 182 | 183 | rh_status_q() { 184 | rh_status >/dev/null 2>&1 185 | } 186 | 187 | case "$1" in 188 | start) 189 | rh_status_q && exit 0 190 | start 191 | ;; 192 | stop) 193 | if ! rh_status_q; then 194 | rm -f $lockfile 195 | exit 0 196 | fi 197 | stop 198 | ;; 199 | restart) 200 | restart 201 | ;; 202 | reload) 203 | rh_status_q || exit 7 204 | reload 205 | ;; 206 | force-reload) 207 | force_reload 208 | ;; 209 | condrestart|try-restart) 210 | rh_status_q || exit 0 211 | if [ -f $lockfile ] ; then 212 | do_restart_sanity_check 213 | if [ $RETVAL -eq 0 ] ; then 214 | stop 215 | # avoid race 216 | sleep 3 217 | start 218 | else 219 | RETVAL=6 220 | fi 221 | fi 222 | ;; 223 | status) 224 | rh_status 225 | RETVAL=$? 226 | if [ $RETVAL -eq 3 -a -f $lockfile ] ; then 227 | RETVAL=2 228 | fi 229 | ;; 230 | *) 231 | echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" 232 | RETVAL=2 233 | esac 234 | exit $RETVAL 235 | -------------------------------------------------------------------------------- /conf/php-fpm-p2.conf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | All relative paths in this config are relative to php's install prefix 5 | 6 |
7 | 8 | Pid file 9 | /usr/local/php/logs/php-fpm.pid 10 | 11 | Error log file 12 | /usr/local/php/logs/php-fpm.log 13 | 14 | Log level 15 | notice 16 | 17 | When this amount of php processes exited with SIGSEGV or SIGBUS ... 18 | 10 19 | 20 | ... in a less than this interval of time, a graceful restart will be initiated. 21 | Useful to work around accidental curruptions in accelerator's shared memory. 22 | 1m 23 | 24 | Time limit on waiting child's reaction on signals from master 25 | 5s 26 | 27 | Set to 'no' to debug fpm 28 | yes 29 | 30 |
31 | 32 | 33 | 34 |
35 | 36 | Name of pool. Used in logs and stats. 37 | default 38 | 39 | Address to accept fastcgi requests on. 40 | Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket' 41 | 127.0.0.1:9000 42 | 43 | 44 | 45 | Set listen(2) backlog 46 | -1 47 | 48 | Set permissions for unix socket, if one used. 49 | In Linux read/write permissions must be set in order to allow connections from web server. 50 | Many BSD-derrived systems allow connections regardless of permissions. 51 | 52 | 53 | 0666 54 | 55 | 56 | Additional php.ini defines, specific to this pool of workers. 57 | 58 | /usr/sbin/sendmail -t -i 59 | 1 60 | 61 | 62 | Unix user of processes 63 | www 64 | 65 | Unix group of processes 66 | www 67 | 68 | Process manager settings 69 | 70 | 71 | Sets style of controling worker process count. 72 | Valid values are 'static' and 'apache-like' 73 | static 74 | 75 | Sets the limit on the number of simultaneous requests that will be served. 76 | Equivalent to Apache MaxClients directive. 77 | Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi 78 | Used with any pm_style. 79 | 5 80 | 81 | Settings group for 'apache-like' pm style 82 | 83 | 84 | Sets the number of server processes created on startup. 85 | Used only when 'apache-like' pm_style is selected 86 | 20 87 | 88 | Sets the desired minimum number of idle server processes. 89 | Used only when 'apache-like' pm_style is selected 90 | 5 91 | 92 | Sets the desired maximum number of idle server processes. 93 | Used only when 'apache-like' pm_style is selected 94 | 35 95 | 96 | 97 | 98 | 99 | 100 | The timeout (in seconds) for serving a single request after which the worker process will be terminated 101 | Should be used when 'max_execution_time' ini option does not stop script execution for some reason 102 | '0s' means 'off' 103 | 0s 104 | 105 | The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file 106 | '0s' means 'off' 107 | 0s 108 | 109 | The log file for slow requests 110 | logs/slow.log 111 | 112 | Set open file desc rlimit 113 | 65535 114 | 115 | Set max core size rlimit 116 | 0 117 | 118 | Chroot to this directory at the start, absolute path 119 | 120 | 121 | Chdir to this directory at the start, absolute path 122 | 123 | 124 | Redirect workers' stdout and stderr into main error log. 125 | If not set, they will be redirected to /dev/null, according to FastCGI specs 126 | yes 127 | 128 | How much requests each process should execute before respawn. 129 | Useful to work around memory leaks in 3rd party libraries. 130 | For endless request processing please specify 0 131 | Equivalent to PHP_FCGI_MAX_REQUESTS 132 | 10240 133 | 134 | Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect. 135 | Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+) 136 | Makes sense only with AF_INET listening socket. 137 | 127.0.0.1 138 | 139 | Pass environment variables like LD_LIBRARY_PATH 140 | All $VARIABLEs are taken from current environment 141 | 142 | $HOSTNAME 143 | /usr/local/bin:/usr/bin:/bin 144 | /tmp 145 | /tmp 146 | /tmp 147 | $OSTYPE 148 | $MACHTYPE 149 | 2 150 | 151 | 152 |
153 | 154 |
155 | 156 |
157 | -------------------------------------------------------------------------------- /vhost_del.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 3 | export PATH 4 | 5 | if [ $(id -u) != "0" ]; then 6 | printf "Error: You must be root to run this script!" 7 | exit 1 8 | fi 9 | 10 | LANMP_PATH=`pwd` 11 | if [ `echo $LANMP_PATH | awk -F/ '{print $NF}'` != "lanmp" ]; then 12 | clear && echo "Please enter lanmp script path:" 13 | read -p "(Default path: ${LANMP_PATH}/lanmp):" LANMP_PATH 14 | [ -z "$LANMP_PATH" ] && LANMP_PATH=$(pwd)/lanmp 15 | cd $LANMP_PATH/ 16 | fi 17 | 18 | clear 19 | echo "#############################################################" 20 | echo "# Delete Virtual hosts for LANMP" 21 | echo "# Env: Debian/Ubuntu/Redhat/CentOS" 22 | echo "# Author: https://wangyan.org/" 23 | echo "# Version: $(awk '/version/{print $2}' $LANMP_PATH/Changelog)" 24 | echo "#############################################################" 25 | echo "" 26 | 27 | echo "Please enter account name:" 28 | read -p "(Default vhost account: example):" VHOST_ACCOUNT 29 | if [ -z $VHOST_ACCOUNT ]; then 30 | VHOST_ACCOUNT="example" 31 | fi 32 | echo "---------------------------" 33 | echo "vhost account = $VHOST_ACCOUNT" 34 | echo "---------------------------" 35 | echo "" 36 | 37 | echo "Do you want to delete pureftpd user? (y/n)" 38 | read -p "(Default: n):" DELETE_FTPUSER 39 | if [ -z $DELETE_FTPUSER ]; then 40 | DELETE_FTPUSER="n" 41 | fi 42 | if [ "$DELETE_FTPUSER" = 'y' ]; then 43 | echo "Please enter the MySQL root password:" 44 | read -p "(Default password: 123456):" MYSQL_ROOT_PWD 45 | if [ -z $MYSQL_ROOT_PWD ]; then 46 | MYSQL_ROOT_PWD="123456" 47 | fi 48 | echo "---------------------------" 49 | echo "MySQL root password = $MYSQL_ROOT_PWD" 50 | echo "---------------------------" 51 | echo "" 52 | else 53 | echo "---------------------------" 54 | echo "You decided not to delete FTP users!" 55 | echo "---------------------------" 56 | echo "" 57 | fi 58 | 59 | echo "Do you want to delete MySQL DB? (y/n)" 60 | read -p "(Default: n):" DELETE_MYSQL_DB 61 | if [ -z $DELETE_MYSQL_DB ]; then 62 | DELETE_MYSQL_DB="n" 63 | fi 64 | if [ "$DELETE_MYSQL_DB" = 'y' ]; then 65 | if [ -z $MYSQL_ROOT_PWD ]; then 66 | echo "Please enter the MySQL root password:" 67 | read -p "(Default password: 123456):" MYSQL_ROOT_PWD 68 | if [ -z $MYSQL_ROOT_PWD ]; then 69 | MYSQL_ROOT_PWD="123456" 70 | fi 71 | echo "---------------------------" 72 | echo "MySQL root password = $MYSQL_ROOT_PWD" 73 | echo "---------------------------" 74 | echo "" 75 | fi 76 | echo "Please enter your MySQL db name:" 77 | read -p "(Default: ${VHOST_ACCOUNT}):" MYSQL_DB_NAME 78 | if [ -z $MYSQL_DB_NAME ]; then 79 | MYSQL_DB_NAME="$VHOST_ACCOUNT" 80 | fi 81 | echo "---------------------------" 82 | echo "MySQL db name = $MYSQL_DB_NAME" 83 | echo "---------------------------" 84 | echo "" 85 | else 86 | echo "---------------------------" 87 | echo "You decided not to delete MySQL DB!" 88 | echo "---------------------------" 89 | echo "" 90 | fi 91 | 92 | echo "Please enter website domain:" 93 | read -p "(e.g: example.com):" DOMAIN 94 | if [ -z $DOMAIN ]; then 95 | DOMAIN="example.com" 96 | fi 97 | echo "---------------------------" 98 | echo " Domain = $DOMAIN" 99 | echo "---------------------------" 100 | echo "" 101 | sed -i '/'$DOMAIN'/d' $LANMP_PATH/domain_list.txt 102 | 103 | echo "Please choose software of webserver! (1:nginx,2:apache,3:nginx+apache) (1/2/3)" 104 | read -p "(Default: 3):" SOFTWARE 105 | if [ -z $SOFTWARE ]; then 106 | SOFTWARE="3" 107 | fi 108 | echo "---------------------------" 109 | echo "You choose = $SOFTWARE" 110 | echo "---------------------------" 111 | echo "" 112 | 113 | echo "Do you want to delete subdomain? (y/n)" 114 | read -p "(Default: n):" DEL_SUBDOMAIN 115 | if [ -z $DEL_SUBDOMAIN ]; then 116 | DEL_SUBDOMAIN="n" 117 | fi 118 | if [ "$DEL_SUBDOMAIN" = 'y' ]; then 119 | echo "Please enter your subdomain:" 120 | read -p "(e.g: bbs):" SUBDOMAIN 121 | if [ -z $SUBDOMAIN ]; then 122 | SUBDOMAIN="bbs" 123 | fi 124 | echo "---------------------------" 125 | echo "Subdomain = $SUBDOMAIN" 126 | echo "---------------------------" 127 | else 128 | echo "---------------------------" 129 | echo "Not delete any subdomain!" 130 | echo "---------------------------" 131 | echo "" 132 | fi 133 | 134 | get_char() 135 | { 136 | SAVEDSTTY=`stty -g` 137 | stty -echo 138 | stty cbreak 139 | dd if=/dev/tty bs=1 count=1 2> /dev/null 140 | stty -raw 141 | stty echo 142 | stty $SAVEDSTTY 143 | } 144 | echo "Press any key to start delete vhost..." 145 | echo "Or Ctrl+C cancel and exit ?" 146 | echo "" 147 | char=`get_char` 148 | 149 | ###################################################################### 150 | 151 | if [ "$DELETE_FTPUSER" = "y" ]; then 152 | mysql -uroot -p$MYSQL_ROOT_PWD -e"DELETE FROM pureftpd.users WHERE users.User = '$VHOST_ACCOUNT';" 153 | fi 154 | 155 | if [ "$DELETE_MYSQL_DB" = "y" ]; then 156 | mysql -uroot -p$MYSQL_ROOT_PWD -e"drop database $MYSQL_DB_NAME;Drop USER ${MYSQL_DB_NAME}@localhost;" 157 | fi 158 | 159 | if [ "$SOFTWARE" != 2 ]; then 160 | if [ "$SOFTWARE" = "1" ]; then 161 | userdel $VHOST_ACCOUNT 162 | rm -rf /var/spool/mail/$VHOST_ACCOUNT 163 | fi 164 | if [ "$DEL_SUBDOMAIN" = 'n' ]; then 165 | rm -rf /usr/local/nginx/conf/vhosts/*${DOMAIN}.conf 166 | rm -rf /usr/local/nginx/logs/$DOMAIN 167 | rm -rf /home/$VHOST_ACCOUNT 168 | else 169 | rm -rf /usr/local/nginx/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf 170 | rm -rf /home/$VHOST_ACCOUNT/$SUBDOMAIN 171 | fi 172 | fi 173 | 174 | if [ "$SOFTWARE" != 1 ]; then 175 | if [ "$DEL_SUBDOMAIN" = 'n' ]; then 176 | rm -rf /usr/local/apache/conf/vhosts/*${DOMAIN}.conf 177 | rm -rf /usr/local/apache/logs/$DOMAIN 178 | \rm -rf /home/$VHOST_ACCOUNT 179 | else 180 | rm -rf /usr/local/apache/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf 181 | \rm -rf /home/$VHOST_ACCOUNT/$SUBDOMAIN 182 | fi 183 | fi 184 | 185 | if [ "$SOFTWARE" != "2" ]; then 186 | echo "Test Nginx configure file......" 187 | /usr/local/nginx/sbin/nginx -t 188 | echo "" 189 | /etc/init.d/nginx reload 190 | fi 191 | 192 | if [ "$SOFTWARE" != "1" ]; then 193 | echo "Test apache configure file......" 194 | /usr/local/apache/bin/apachectl -t 195 | echo "" 196 | /etc/init.d/httpd restart 197 | fi 198 | 199 | clear 200 | echo "" 201 | echo "===================== Delete completed =====================" 202 | echo "" 203 | echo "Vhost account: $VHOST_ACCOUNT" 204 | echo "Website domain: $DOMAIN" 205 | if [ "$DEL_SUBDOMAIN" = 'y' ]; then 206 | echo "Website subdomain: $SUBDOMAIN" 207 | fi 208 | echo "" 209 | echo "=============================================================" 210 | echo "" 211 | -------------------------------------------------------------------------------- /upgrade.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 3 | export PATH 4 | 5 | if [ $(id -u) != "0" ]; then 6 | printf "Error: You must be root to run this script!" 7 | exit 1 8 | fi 9 | 10 | LANMP_PATH=`pwd` 11 | if [ `echo $LANMP_PATH | awk -F/ '{print $NF}'` != "lanmp" ]; then 12 | clear && echo "Please enter lanmp script path:" 13 | read -p "(Default path: ${LANMP_PATH}/lanmp):" LANMP_PATH 14 | [ -z "$LANMP_PATH" ] && LANMP_PATH=$(pwd)/lanmp 15 | cd $LANMP_PATH/ 16 | fi 17 | 18 | clear 19 | echo "#############################################################" 20 | echo "# LANMP Auto Update Script" 21 | echo "# Env: Redhat/CentOS" 22 | echo "# Intro: https://wangyan.org/blog/lanmp.html" 23 | echo "# Version: $(awk '/version/{print $2}' $LANMP_PATH/Changelog)" 24 | echo "#" 25 | echo "# Copyright (c) 2012, WangYan " 26 | echo "# All rights reserved." 27 | echo "# Distributed under the GNU General Public License, version 3.0." 28 | echo "#" 29 | echo "#############################################################" 30 | echo "" 31 | 32 | echo "Please enter the webroot dir:" 33 | read -p "(Default webroot dir: /var/www):" WEBROOT 34 | if [ -z $WEBROOT ]; then 35 | WEBROOT="/var/www" 36 | fi 37 | echo "---------------------------" 38 | echo "Webroot dir=$WEBROOT" 39 | echo "---------------------------" 40 | echo "" 41 | 42 | echo "Please choose webserver software! (1:nginx,2:apache,3:nginx+apache) (1/2/3)" 43 | read -p "(Default: 3):" SOFTWARE 44 | if [ -z $SOFTWARE ]; then 45 | SOFTWARE="3" 46 | fi 47 | echo "---------------------------" 48 | echo "You choose = $SOFTWARE" 49 | echo "---------------------------" 50 | echo "" 51 | 52 | ######################### PHP5 ######################### 53 | 54 | LATEST_PHP=$(curl -s http://www.php.net/downloads.php | awk '/Current Stable/{print $3}') 55 | INSTALLED_PHP=$(php -r 'echo PHP_VERSION;' 2>/dev/null) 56 | 57 | echo -e "Latest version of PHP: \033[41;37m $LATEST_PHP \033[0m" 58 | echo -e "Installed version of PHP: \033[41;37m $INSTALLED_PHP \033[0m" 59 | echo "" 60 | 61 | if [ "$INSTALLED_PHP" != "5.2.17p1" ];then 62 | echo "Do you want to upgrade PHP ? (y/n)" 63 | read -p "(Default: n):" UPGRADE_PHP 64 | if [ -z $UPGRADE_PHP ]; then 65 | UPGRADE_PHP="n" 66 | fi 67 | echo "---------------------------" 68 | echo "You choose = $UPGRADE_PHP" 69 | echo "---------------------------" 70 | echo "" 71 | fi 72 | 73 | ######################### Nginx ######################### 74 | 75 | if [ "$SOFTWARE" != 2 ];then 76 | INSTALLED_NGINX=$(echo `nginx -v 2>&1` | cut -d '/' -f 2) 77 | LATEST_NGINX=$(curl -s http://nginx.org/| awk -F- '/nginx-/{print $6}' | head -1|cut -d '<' -f 1) 78 | 79 | echo -e "Latest version of Nginx: \033[41;37m $LATEST_NGINX \033[0m" 80 | echo -e "Installed version of Nginx: \033[41;37m $INSTALLED_NGINX \033[0m" 81 | echo "" 82 | 83 | echo "Do you want to upgrade Nginx ? (y/n)" 84 | read -p "(Default: n):" UPGRADE_NGINX 85 | if [ -z $UPGRADE_NGINX ]; then 86 | UPGRADE_NGINX="n" 87 | fi 88 | echo "---------------------------" 89 | echo "You choose = $UPGRADE_NGINX" 90 | echo "---------------------------" 91 | echo "" 92 | fi 93 | 94 | ######################### phpMyAdmin ######################### 95 | 96 | if [ ! -s "$LANMP_PATH/version.txt" ]; then 97 | echo -e "phpmyadmin\t0" > $LANMP_PATH/version.txt 98 | fi 99 | 100 | INSTALLED_PMA=$(awk '/phpmyadmin/{print $2}' $LANMP_PATH/version.txt) 101 | LATEST_PMA=$(elinks http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/ | awk -F/ '{print $7F}' | sort -n | grep -iv '-' | tail -1) 102 | 103 | echo -e "Latest version of phpmyadmin: \033[41;37m $LATEST_PMA \033[0m" 104 | echo -e "Installed version of phpmyadmin: \033[41;37m $INSTALLED_PMA \033[0m" 105 | echo "" 106 | 107 | echo "Do you want to upgrade phpmyadmin ? (y/n)" 108 | read -p "(Default: n):" UPGRADE_PMA 109 | if [ -z $UPGRADE_PMA ]; then 110 | UPGRADE_PMA="n" 111 | fi 112 | echo "---------------------------" 113 | echo "You choose = $UPGRADE_PMA" 114 | echo "---------------------------" 115 | echo "" 116 | 117 | 118 | get_char() 119 | { 120 | SAVEDSTTY=`stty -g` 121 | stty -echo 122 | stty cbreak 123 | dd if=/dev/tty bs=1 count=1 2> /dev/null 124 | stty -raw 125 | stty echo 126 | stty $SAVEDSTTY 127 | } 128 | echo "Press any key to start Upgrade..." 129 | echo "Or Ctrl+C cancel and exit ?" 130 | echo "" 131 | char=`get_char` 132 | 133 | ######################### Extract Function ######################### 134 | 135 | Extract(){ 136 | local TARBALL_TYPE 137 | if [ -n $1 ]; then 138 | SOFTWARE_NAME=`echo $1 | awk -F/ '{print $NF}'` 139 | TARBALL_TYPE=`echo $1 | awk -F. '{print $NF}'` 140 | wget -c -t3 -T3 $1 -P $LANMP_PATH/ 141 | if [ $? != "0" ];then 142 | rm -rf $LANMP_PATH/$SOFTWARE_NAME 143 | wget -c -t3 -T60 $2 -P $LANMP_PATH/ 144 | SOFTWARE_NAME=`echo $2 | awk -F/ '{print $NF}'` 145 | TARBALL_TYPE=`echo $2 | awk -F. '{print $NF}'` 146 | fi 147 | else 148 | SOFTWARE_NAME=`echo $2 | awk -F/ '{print $NF}'` 149 | TARBALL_TYPE=`echo $2 | awk -F. '{print $NF}'` 150 | wget -c -t3 -T3 $2 -P $LANMP_PATH/ || exit 151 | fi 152 | EXTRACTED_DIR=`tar tf $LANMP_PATH/$SOFTWARE_NAME | tail -n 1 | awk -F/ '{print $1}'` 153 | case $TARBALL_TYPE in 154 | gz|tgz) 155 | tar zxf $LANMP_PATH/$SOFTWARE_NAME -C $LANMP_PATH/ && cd $LANMP_PATH/$EXTRACTED_DIR || return 1 156 | ;; 157 | bz2|tbz) 158 | tar jxf $LANMP_PATH/$SOFTWARE_NAME -C $LANMP_PATH/ && cd $LANMP_PATH/$EXTRACTED_DIR || return 1 159 | ;; 160 | tar|Z) 161 | tar xf $LANMP_PATH/$SOFTWARE_NAME -C $LANMP_PATH/ && cd $LANMP_PATH/$EXTRACTED_DIR || return 1 162 | ;; 163 | *) 164 | echo "$SOFTWARE_NAME is wrong tarball type ! " 165 | esac 166 | } 167 | 168 | echo "===================== PHP5 Upgrade ====================" 169 | 170 | if [[ "$UPGRADE_PHP" = "y" && "$INSTALLED_PHP" > 5 ]];then 171 | 172 | if [[ -d "/usr/local/php.bak" && -d "/usr/local/php" ]];then 173 | rm -rf /usr/local/php.bak/ 174 | fi 175 | \mv /usr/local/php /usr/local/php.bak 176 | 177 | cd $LANMP_PATH 178 | 179 | if [ ! -s php-5.5.*.tar.gz ]; then 180 | LATEST_PHP_LINK="http://php.net/distributions/php-${$LATEST_PHP}.tar.gz" 181 | BACKUP_PHP_LINK="http://wangyan.org/download/lanmp-src/php-latest.tar.gz" 182 | Extract ${LATEST_PHP_LINK} ${BACKUP_PHP_LINK} 183 | else 184 | tar -zxf php-5.5.*.tar.gz 185 | cd php-5.5.*/ 186 | fi 187 | 188 | if [ "$SOFTWARE" != "1" ]; then 189 | ./configure \ 190 | --prefix=/usr/local/php \ 191 | --with-apxs2=/usr/local/apache/bin/apxs \ 192 | --with-curl \ 193 | --with-curlwrappers \ 194 | --with-freetype-dir \ 195 | --with-gettext \ 196 | --with-gd \ 197 | --with-iconv-dir \ 198 | --with-jpeg-dir \ 199 | --with-libxml-dir \ 200 | --with-mcrypt \ 201 | --with-mhash \ 202 | --with-mysql=/usr/local/mysql \ 203 | --with-mysqli=/usr/local/mysql/bin/mysql_config \ 204 | --with-openssl \ 205 | --with-pear \ 206 | --with-png-dir \ 207 | --with-xmlrpc \ 208 | --with-zlib \ 209 | --enable-bcmath \ 210 | --enable-calendar \ 211 | --enable-exif \ 212 | --enable-ftp \ 213 | --enable-gd-native-ttf \ 214 | --enable-inline-optimization \ 215 | --enable-mbregex \ 216 | --enable-mbstring \ 217 | --enable-shmop \ 218 | --enable-soap \ 219 | --enable-sockets \ 220 | --enable-sysvsem \ 221 | --enable-sysvshm \ 222 | --enable-xml \ 223 | --enable-zip 224 | else 225 | ./configure \ 226 | --prefix=/usr/local/php \ 227 | --with-curl \ 228 | --with-freetype-dir \ 229 | --with-gettext \ 230 | --with-gd \ 231 | --with-iconv-dir \ 232 | --with-jpeg-dir \ 233 | --with-libxml-dir \ 234 | --with-mcrypt \ 235 | --with-mhash \ 236 | --with-mysql=/usr/local/mysql \ 237 | --with-mysqli=/usr/local/mysql/bin/mysql_config \ 238 | --with-openssl \ 239 | --with-pear \ 240 | --with-png-dir \ 241 | --with-xmlrpc \ 242 | --with-zlib \ 243 | --enable-bcmath \ 244 | --enable-calendar \ 245 | --enable-exif \ 246 | --enable-fpm \ 247 | --enable-ftp \ 248 | --enable-gd-native-ttf \ 249 | --enable-inline-optimization \ 250 | --enable-mbregex \ 251 | --enable-mbstring \ 252 | --enable-pcntl \ 253 | --enable-shmop \ 254 | --enable-soap \ 255 | --enable-sockets \ 256 | --enable-sysvsem \ 257 | --enable-sysvshm \ 258 | --enable-xml \ 259 | --enable-zip 260 | fi 261 | 262 | make ZEND_EXTRA_LIBS='-liconv' 263 | make install 264 | 265 | echo "---------- PHP Extension ----------" 266 | 267 | PHP_EXT1=`ls /usr/local/php.bak/lib/php/extensions/` 268 | PHP_EXT2=`ls /usr/local/php/lib/php/extensions/` 269 | 270 | mkdir -p /usr/local/php/lib/php/extensions/${PHP_EXT2} 271 | cp /usr/local/php.bak/lib/php/extensions/${PHP_EXT1}/* /usr/local/php/lib/php/extensions/${PHP_EXT2} 272 | 273 | echo "---------- PHP Config ----------" 274 | 275 | cp /usr/local/php.bak/lib/php.ini /usr/local/php/lib/php.ini 276 | 277 | if [ "$SOFTWARE" != "1" ]; then 278 | pkill httpd 279 | /etc/init.d/httpd start 280 | else 281 | cp /usr/local/php.bak/etc/php-fpm.conf /usr/local/php/etc/php-fpm.conf 282 | pkill php-fpm 283 | /etc/init.d/php-fpm start 284 | fi 285 | 286 | rm -rf $LANMP_PATH/src/{php-*,memcache-*,xcache-*} 287 | fi 288 | 289 | echo "===================== Nginx Upgrade ====================" 290 | 291 | if [[ "$UPGRADE_NGINX" = "y" || "$UPGRADE_NGINX" = "Y" ]];then 292 | 293 | cd $LANMP_PATH 294 | 295 | if [ ! -s nginx-${LATEST_NGINX}.tar.gz ]; then 296 | LATEST_NGINX_LINK="http://nginx.org/download/nginx-$LATEST_NGINX.tar.gz" 297 | BACKUP_NGINX_LINK="http://wangyan.org/download/lanmp-src/nginx-latest.tar.gz" 298 | Extract ${LATEST_NGINX_LINK} ${BACKUP_NGINX_LINK} 299 | else 300 | tar -zxf nginx-${LATEST_NGINX}.tar.gz 301 | cd nginx-${LATEST_NGINX}/ 302 | fi 303 | 304 | ./configure \ 305 | --pid-path=/var/run/nginx.pid \ 306 | --lock-path=/var/lock/nginx.lock \ 307 | --user=www \ 308 | --group=www \ 309 | --with-http_ssl_module \ 310 | --with-http_dav_module \ 311 | --with-http_flv_module \ 312 | --with-http_realip_module \ 313 | --with-http_gzip_static_module \ 314 | --with-http_stub_status_module \ 315 | --with-mail \ 316 | --with-mail_ssl_module \ 317 | --with-pcre \ 318 | --with-debug \ 319 | --with-ipv6 \ 320 | --http-client-body-temp-path=/var/tmp/nginx/client \ 321 | --http-proxy-temp-path=/var/tmp/nginx/proxy \ 322 | --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \ 323 | --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ 324 | --http-scgi-temp-path=/var/tmp/nginx/scgi 325 | make 326 | 327 | \mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old 328 | cp objs/nginx /usr/local/nginx/sbin/nginx 329 | /usr/local/nginx/sbin/nginx -t 330 | make upgrade 331 | echo "Upgrade completed!" 332 | /usr/local/nginx/sbin/nginx -v 333 | echo "" 334 | /etc/init.d/nginx restart 335 | 336 | rm -rf $LANMP_PATH/src/nginx-* 337 | fi 338 | 339 | 340 | echo "===================== phpMyAdmin Upgrade ====================" 341 | 342 | if [[ "$UPGRADE_PMA" = "y" || "$UPGRADE_PMA" = "Y" ]];then 343 | 344 | PMA_LINK="http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin" 345 | 346 | mv $WEBROOT/phpmyadmin/config.inc.php $WEBROOT/config.inc.php 347 | rm -rf $WEBROOT/phpmyadmin/ 348 | 349 | if [ ! -s phpMyAdmin-${LATEST_PMA}-all-languages.tar.gz ]; then 350 | LATEST_PMA_LINK="${PMA_LINK}/${LATEST_PMA}/phpMyAdmin-${LATEST_PMA}-all-languages.tar.gz" 351 | BACKUP_PMA_LINK="http://wangyan.org/download/lanmp/phpMyAdmin-latest-all-languages.tar.gz" 352 | Extract ${LATEST_PMA_LINK} ${BACKUP_PMA_LINK} 353 | mkdir -p $WEBROOT/phpmyadmin 354 | mv * $WEBROOT/phpmyadmin 355 | else 356 | tar -zxf phpMyAdmin-${LATEST_PMA}-all-languages.tar.gz -C $WEBROOT 357 | mv $WEBROOT/phpMyAdmin-${LATEST_PMA}-all-languages $WEBROOT/phpmyadmin 358 | fi 359 | 360 | mv $WEBROOT/config.inc.php $WEBROOT/phpmyadmin/ 361 | 362 | sed -i '/phpmyadmin/d' $LANMP_PATH/version.txt 363 | echo -e "phpmyadmin\t${LATEST_PMA}" >> $LANMP_PATH/version.txt 2>&1 364 | rm -rf $LANMP_PATH/src/phpMyAdmin-* 365 | 366 | fi 367 | 368 | if [ ! -d "$LANMP_PATH/src" ];then 369 | mkdir -p $LANMP_PATH/src/ 370 | fi 371 | \mv $LANMP_PATH/{*gz,*-*/,ioncube,package.xml} $LANMP_PATH/src >/dev/null 2>&1 372 | -------------------------------------------------------------------------------- /conf/php-fpm-p4.conf: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;; 2 | ; FPM Configuration ; 3 | ;;;;;;;;;;;;;;;;;;;;; 4 | 5 | ; All relative paths in this configuration file are relative to PHP's install 6 | ; prefix (/usr/local/php). This prefix can be dynamicaly changed by using the 7 | ; '-p' argument from the command line. 8 | 9 | ; Include one or more files. If glob(3) exists, it is used to include a bunch of 10 | ; files from a glob(3) pattern. This directive can be used everywhere in the 11 | ; file. 12 | ; Relative path can also be used. They will be prefixed by: 13 | ; - the global prefix if it's been set (-p arguement) 14 | ; - /usr/local/php otherwise 15 | ;include=etc/fpm.d/*.conf 16 | 17 | ;;;;;;;;;;;;;;;;;; 18 | ; Global Options ; 19 | ;;;;;;;;;;;;;;;;;; 20 | 21 | [global] 22 | ; Pid file 23 | ; Note: the default prefix is /usr/local/php/var 24 | ; Default Value: none 25 | pid = run/php-fpm.pid 26 | 27 | ; Error log file 28 | ; Note: the default prefix is /usr/local/php/var 29 | ; Default Value: log/php-fpm.log 30 | error_log = log/php-fpm.log 31 | 32 | ; Log level 33 | ; Possible Values: alert, error, warning, notice, debug 34 | ; Default Value: notice 35 | log_level = notice 36 | 37 | ; If this number of child processes exit with SIGSEGV or SIGBUS within the time 38 | ; interval set by emergency_restart_interval then FPM will restart. A value 39 | ; of '0' means 'Off'. 40 | ; Default Value: 0 41 | ;emergency_restart_threshold = 0 42 | 43 | ; Interval of time used by emergency_restart_interval to determine when 44 | ; a graceful restart will be initiated. This can be useful to work around 45 | ; accidental corruptions in an accelerator's shared memory. 46 | ; Available Units: s(econds), m(inutes), h(ours), or d(ays) 47 | ; Default Unit: seconds 48 | ; Default Value: 0 49 | ;emergency_restart_interval = 0 50 | 51 | ; Time limit for child processes to wait for a reaction on signals from master. 52 | ; Available units: s(econds), m(inutes), h(ours), or d(ays) 53 | ; Default Unit: seconds 54 | ; Default Value: 0 55 | ;process_control_timeout = 0 56 | 57 | ; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging. 58 | ; Default Value: yes 59 | ;daemonize = yes 60 | 61 | ;;;;;;;;;;;;;;;;;;;; 62 | ; Pool Definitions ; 63 | ;;;;;;;;;;;;;;;;;;;; 64 | 65 | ; Multiple pools of child processes may be started with different listening 66 | ; ports and different management options. The name of the pool will be 67 | ; used in logs and stats. There is no limitation on the number of pools which 68 | ; FPM can handle. Your system will tell you anyway :) 69 | 70 | ; Start a new pool named 'www'. 71 | ; the variable $pool can we used in any directive and will be replaced by the 72 | ; pool name ('www' here) 73 | [www] 74 | 75 | ; Per pool prefix 76 | ; It only applies on the following directives: 77 | ; - 'slowlog' 78 | ; - 'listen' (unixsocket) 79 | ; - 'chroot' 80 | ; - 'chdir' 81 | ; - 'php_values' 82 | ; - 'php_admin_values' 83 | ; When not set, the global prefix (or /usr/local/php) applies instead. 84 | ; Note: This directive can also be relative to the global prefix. 85 | ; Default Value: none 86 | ;prefix = /path/to/pools/$pool 87 | 88 | ; The address on which to accept FastCGI requests. 89 | ; Valid syntaxes are: 90 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on 91 | ; a specific port; 92 | ; 'port' - to listen on a TCP socket to all addresses on a 93 | ; specific port; 94 | ; '/path/to/unix/socket' - to listen on a unix socket. 95 | ; Note: This value is mandatory. 96 | listen = 127.0.0.1:9000 97 | 98 | ; Set listen(2) backlog. A value of '-1' means unlimited. 99 | ; Default Value: 128 (-1 on FreeBSD and OpenBSD) 100 | ;listen.backlog = -1 101 | 102 | ; List of ipv4 addresses of FastCGI clients which are allowed to connect. 103 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original 104 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address 105 | ; must be separated by a comma. If this value is left blank, connections will be 106 | ; accepted from any ip address. 107 | ; Default Value: any 108 | ;listen.allowed_clients = 127.0.0.1 109 | 110 | ; Set permissions for unix socket, if one is used. In Linux, read/write 111 | ; permissions must be set in order to allow connections from a web server. Many 112 | ; BSD-derived systems allow connections regardless of permissions. 113 | ; Default Values: user and group are set as the running user 114 | ; mode is set to 0666 115 | ;listen.owner = www 116 | ;listen.group = www 117 | ;listen.mode = 0666 118 | 119 | ; Unix user/group of processes 120 | ; Note: The user is mandatory. If the group is not set, the default user's group 121 | ; will be used. 122 | user = www 123 | group = www 124 | 125 | ; Choose how the process manager will control the number of child processes. 126 | ; Possible Values: 127 | ; static - a fixed number (pm.max_children) of child processes; 128 | ; dynamic - the number of child processes are set dynamically based on the 129 | ; following directives: 130 | ; pm.max_children - the maximum number of children that can 131 | ; be alive at the same time. 132 | ; pm.start_servers - the number of children created on startup. 133 | ; pm.min_spare_servers - the minimum number of children in 'idle' 134 | ; state (waiting to process). If the number 135 | ; of 'idle' processes is less than this 136 | ; number then some children will be created. 137 | ; pm.max_spare_servers - the maximum number of children in 'idle' 138 | ; state (waiting to process). If the number 139 | ; of 'idle' processes is greater than this 140 | ; number then some children will be killed. 141 | ; Note: This value is mandatory. 142 | pm = dynamic 143 | 144 | ; The number of child processes to be created when pm is set to 'static' and the 145 | ; maximum number of child processes to be created when pm is set to 'dynamic'. 146 | ; This value sets the limit on the number of simultaneous requests that will be 147 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 148 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 149 | ; CGI. 150 | ; Note: Used when pm is set to either 'static' or 'dynamic' 151 | ; Note: This value is mandatory. 152 | pm.max_children = 10 153 | 154 | ; The number of child processes created on startup. 155 | ; Note: Used only when pm is set to 'dynamic' 156 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 157 | pm.start_servers = 6 158 | 159 | ; The desired minimum number of idle server processes. 160 | ; Note: Used only when pm is set to 'dynamic' 161 | ; Note: Mandatory when pm is set to 'dynamic' 162 | pm.min_spare_servers = 2 163 | 164 | ; The desired maximum number of idle server processes. 165 | ; Note: Used only when pm is set to 'dynamic' 166 | ; Note: Mandatory when pm is set to 'dynamic' 167 | pm.max_spare_servers = 10 168 | 169 | ; The number of requests each child process should execute before respawning. 170 | ; This can be useful to work around memory leaks in 3rd party libraries. For 171 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 172 | ; Default Value: 0 173 | pm.max_requests = 10240 174 | 175 | ; The URI to view the FPM status page. If this value is not set, no URI will be 176 | ; recognized as a status page. By default, the status page shows the following 177 | ; information: 178 | ; accepted conn - the number of request accepted by the pool; 179 | ; pool - the name of the pool; 180 | ; process manager - static or dynamic; 181 | ; idle processes - the number of idle processes; 182 | ; active processes - the number of active processes; 183 | ; total processes - the number of idle + active processes. 184 | ; max children reached - number of times, the process limit has been reached, 185 | ; when pm tries to start more children (works only for 186 | ; pm 'dynamic') 187 | ; The values of 'idle processes', 'active processes' and 'total processes' are 188 | ; updated each second. The value of 'accepted conn' is updated in real time. 189 | ; Example output: 190 | ; accepted conn: 12073 191 | ; pool: www 192 | ; process manager: static 193 | ; idle processes: 35 194 | ; active processes: 65 195 | ; total processes: 100 196 | ; max children reached: 1 197 | ; By default the status page output is formatted as text/plain. Passing either 198 | ; 'html' or 'json' as a query string will return the corresponding output 199 | ; syntax. Example: 200 | ; http://www.foo.bar/status 201 | ; http://www.foo.bar/status?json 202 | ; http://www.foo.bar/status?html 203 | ; Note: The value must start with a leading slash (/). The value can be 204 | ; anything, but it may not be a good idea to use the .php extension or it 205 | ; may conflict with a real PHP file. 206 | ; Default Value: not set 207 | ;pm.status_path = /status 208 | 209 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no 210 | ; URI will be recognized as a ping page. This could be used to test from outside 211 | ; that FPM is alive and responding, or to 212 | ; - create a graph of FPM availability (rrd or such); 213 | ; - remove a server from a group if it is not responding (load balancing); 214 | ; - trigger alerts for the operating team (24/7). 215 | ; Note: The value must start with a leading slash (/). The value can be 216 | ; anything, but it may not be a good idea to use the .php extension or it 217 | ; may conflict with a real PHP file. 218 | ; Default Value: not set 219 | ;ping.path = /ping 220 | 221 | ; This directive may be used to customize the response of a ping request. The 222 | ; response is formatted as text/plain with a 200 response code. 223 | ; Default Value: pong 224 | ;ping.response = pong 225 | 226 | ; The timeout for serving a single request after which the worker process will 227 | ; be killed. This option should be used when the 'max_execution_time' ini option 228 | ; does not stop script execution for some reason. A value of '0' means 'off'. 229 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 230 | ; Default Value: 0 231 | ;request_terminate_timeout = 0 232 | 233 | ; The timeout for serving a single request after which a PHP backtrace will be 234 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'. 235 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 236 | ; Default Value: 0 237 | ;request_slowlog_timeout = 0 238 | 239 | ; The log file for slow requests 240 | ; Default Value: not set 241 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 242 | ;slowlog = log/$pool.log.slow 243 | 244 | ; Set open file descriptor rlimit. 245 | ; Default Value: system defined value 246 | ;rlimit_files = 1024 247 | 248 | ; Set max core size rlimit. 249 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 250 | ; Default Value: system defined value 251 | ;rlimit_core = 0 252 | 253 | ; Chroot to this directory at the start. This value must be defined as an 254 | ; absolute path. When this value is not set, chroot is not used. 255 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one 256 | ; of its subdirectories. If the pool prefix is not set, the global prefix 257 | ; will be used instead. 258 | ; Note: chrooting is a great security feature and should be used whenever 259 | ; possible. However, all PHP paths will be relative to the chroot 260 | ; (error_log, sessions.save_path, ...). 261 | ; Default Value: not set 262 | ;chroot = 263 | 264 | ; Chdir to this directory at the start. 265 | ; Note: relative path can be used. 266 | ; Default Value: current directory or / when chroot 267 | ;chdir = /var/www 268 | 269 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 270 | ; stderr will be redirected to /dev/null according to FastCGI specs. 271 | ; Note: on highloaded environement, this can cause some delay in the page 272 | ; process time (several ms). 273 | ; Default Value: no 274 | ;catch_workers_output = yes 275 | 276 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 277 | ; the current environment. 278 | ; Default Value: clean env 279 | ;env[HOSTNAME] = $HOSTNAME 280 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin 281 | ;env[TMP] = /tmp 282 | ;env[TMPDIR] = /tmp 283 | ;env[TEMP] = /tmp 284 | 285 | ; Additional php.ini defines, specific to this pool of workers. These settings 286 | ; overwrite the values previously defined in the php.ini. The directives are the 287 | ; same as the PHP SAPI: 288 | ; php_value/php_flag - you can set classic ini defines which can 289 | ; be overwritten from PHP call 'ini_set'. 290 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 291 | ; PHP call 'ini_set' 292 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 293 | 294 | ; Defining 'extension' will load the corresponding shared extension from 295 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 296 | ; overwrite previously defined php.ini values, but will append the new value 297 | ; instead. 298 | 299 | ; Note: path INI options can be relative and will be expanded with the prefix 300 | ; (pool, global or /usr/local/php) 301 | 302 | ; Default Value: nothing is defined by default except the values in php.ini and 303 | ; specified at startup with the -d argument 304 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 305 | ;php_flag[display_errors] = off 306 | ;php_admin_value[error_log] = /var/log/fpm-php.www.log 307 | ;php_admin_flag[log_errors] = on 308 | ;php_admin_value[memory_limit] = 32M 309 | -------------------------------------------------------------------------------- /vhost_add.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 3 | export PATH 4 | 5 | if [ $(id -u) != "0" ]; then 6 | printf "Error: You must be root to run this script!" 7 | exit 1 8 | fi 9 | 10 | LANMP_PATH=`pwd` 11 | if [ `echo $LANMP_PATH | awk -F/ '{print $NF}'` != "lanmp" ]; then 12 | clear && echo "Please enter lanmp script path:" 13 | read -p "(Default path: ${LANMP_PATH}/lanmp):" LANMP_PATH 14 | [ -z "$LANMP_PATH" ] && LANMP_PATH=$(pwd)/lanmp 15 | cd $LANMP_PATH/ 16 | fi 17 | 18 | clear 19 | echo "#############################################################" 20 | echo "# Add Virtual Host for LANMP" 21 | echo "# Env: Debian/Ubuntu/Redhat/CentOS" 22 | echo "# Author: https://wangyan.org/" 23 | echo "# Version: $(awk '/version/{print $2}' $LANMP_PATH/Changelog)" 24 | echo "#############################################################" 25 | echo "" 26 | 27 | echo "Please enter account name:" 28 | read -p "(Default vhost account: example):" VHOST_ACCOUNT 29 | if [ -z $VHOST_ACCOUNT ]; then 30 | VHOST_ACCOUNT="example" 31 | fi 32 | echo "---------------------------" 33 | echo "vhost account = $VHOST_ACCOUNT" 34 | echo "---------------------------" 35 | echo "" 36 | 37 | echo "Do you want to add a pureftpd user? (y/n)" 38 | read -p "(Default: n):" ADD_FTPUSER 39 | if [ -z $ADD_FTPUSER ]; then 40 | ADD_FTPUSER="n" 41 | fi 42 | if [ "$ADD_FTPUSER" = 'y' ]; then 43 | echo "Please enter the MySQL root password:" 44 | read -p "(Default password: 123456):" MYSQL_ROOT_PWD 45 | if [ -z $MYSQL_ROOT_PWD ]; then 46 | MYSQL_ROOT_PWD="123456" 47 | fi 48 | echo "---------------------------" 49 | echo "MySQL root password = $MYSQL_ROOT_PWD" 50 | echo "---------------------------" 51 | echo "" 52 | echo "Please enter your ftp account password:" 53 | read -p "(Default: 123456):" FTP_PWD 54 | if [ -z $FTP_PWD ]; then 55 | FTP_PWD="123456" 56 | fi 57 | echo "---------------------------" 58 | echo "Ftp password = $FTP_PWD" 59 | echo "---------------------------" 60 | echo "" 61 | else 62 | echo "---------------------------" 63 | echo "You decided not to add FTP users!" 64 | echo "---------------------------" 65 | echo "" 66 | fi 67 | 68 | echo "Do you want to add MySQL DB? (y/n)" 69 | read -p "(Default: n):" ADD_MYSQL_DB 70 | if [ -z $ADD_MYSQL_DB ]; then 71 | ADD_MYSQL_DB="n" 72 | fi 73 | if [ "$ADD_MYSQL_DB" = 'y' ]; then 74 | if [ -z $MYSQL_ROOT_PWD ]; then 75 | echo "Please enter the MySQL root password:" 76 | read -p "(Default password: 123456):" MYSQL_ROOT_PWD 77 | if [ -z $MYSQL_ROOT_PWD ]; then 78 | MYSQL_ROOT_PWD="123456" 79 | fi 80 | echo "---------------------------" 81 | echo "MySQL root password = $MYSQL_ROOT_PWD" 82 | echo "---------------------------" 83 | echo "" 84 | fi 85 | echo "Please enter your MySQL db name:" 86 | read -p "(Default: ${VHOST_ACCOUNT}):" MYSQL_DB_NAME 87 | if [ -z $MYSQL_DB_NAME ]; then 88 | MYSQL_DB_NAME="$VHOST_ACCOUNT" 89 | fi 90 | echo "Please enter your MySQL db password:" 91 | read -p "(Default: $FTP_PWD):" MYSQL_DB_PWD 92 | if [ -z $MYSQL_DB_PWD ]; then 93 | if [ -z $FTP_PWD ]; then 94 | MYSQL_DB_PWD="123456" 95 | else 96 | MYSQL_DB_PWD="$FTP_PWD" 97 | fi 98 | fi 99 | echo "---------------------------" 100 | echo "MySQL db name = $MYSQL_DB_NAME" 101 | echo "MySQL db password = $MYSQL_DB_PWD" 102 | echo "---------------------------" 103 | echo "" 104 | else 105 | echo "---------------------------" 106 | echo " You decided not to add MySQL DB!" 107 | echo "---------------------------" 108 | echo "" 109 | fi 110 | 111 | echo "Please enter website domain:" 112 | read -p "(e.g: example.com):" DOMAIN 113 | if [ -z $DOMAIN ]; then 114 | DOMAIN="example.com" 115 | fi 116 | [ ! -s $LANMP_PATH/domain_list.txt ] && touch $LANMP_PATH/domain_list.txt 117 | if grep -iqw $DOMAIN $LANMP_PATH/domain_list.txt; then 118 | IS_DOMAIN="1" 119 | echo "---------------------------" 120 | echo "Note! $DOMAIN already is exist!" 121 | echo "---------------------------" 122 | echo "" 123 | else 124 | echo -e $DOMAIN >> $LANMP_PATH/domain_list.txt 125 | echo "---------------------------" 126 | echo " Domain = $DOMAIN" 127 | echo "---------------------------" 128 | echo "" 129 | fi 130 | 131 | echo "Please choose software of webserver! (1:nginx,2:apache,3:nginx+apache) (1/2/3)" 132 | read -p "(Default: 3):" SOFTWARE 133 | if [ -z $SOFTWARE ]; then 134 | SOFTWARE="3" 135 | fi 136 | echo "---------------------------" 137 | echo "You choose = $SOFTWARE" 138 | echo "---------------------------" 139 | echo "" 140 | if [ "$SOFTWARE" = "1" ]; then 141 | echo "Do you want to support nginx rewrite? (y/n)" 142 | read -p "(Default: n):" NGINX_REWRITE 143 | if [ -z $NGINX_REWRITE ]; then 144 | NGINX_REWRITE="n" 145 | fi 146 | 147 | if [ "$NGINX_REWRITE" = 'y' ]; then 148 | echo "Please choose rewrite rule (wordpress,typecho,sablog,...):" 149 | read -p "(Default: wordpress):" REWRITE_RULE 150 | if [ -z $REWRITE_RULE ]; then 151 | REWRITE_RULE="wordpress" 152 | fi 153 | 154 | if [ ! -f $LANMP_PATH/rewrite/$REWRITE_RULE.conf ]; then 155 | touch /usr/local/nginx/conf/$REWRITE_RULE.conf 156 | echo "---------------------------" 157 | echo "Create a new rewirte rule: /usr/local/nginx/conf/$REWRITE_RULE.conf" 158 | echo "---------------------------" 159 | echo "" 160 | else 161 | \cp $LANMP_PATH/rewrite/$REWRITE_RULE.conf /usr/local/nginx/conf/$REWRITE_RULE.conf 162 | echo "---------------------------" 163 | echo "You choose rewrite rule: $REWRITE_RULE" 164 | echo "---------------------------" 165 | echo "" 166 | fi 167 | else 168 | echo "---------------------------" 169 | echo "You dont't allow nginx rewrite!" 170 | echo "---------------------------" 171 | echo "" 172 | fi 173 | fi 174 | 175 | echo "Do you want to add subdomain? (y/n)" 176 | read -p "(Default: n):" ADD_SUBDOMAIN 177 | if [ -z $ADD_SUBDOMAIN ]; then 178 | ADD_SUBDOMAIN="n" 179 | fi 180 | if [ "$ADD_SUBDOMAIN" = 'y' ]; then 181 | echo "Please enter your subdomain:" 182 | read -p "(e.g: bbs):" SUBDOMAIN 183 | if [ -z $SUBDOMAIN ]; then 184 | SUBDOMAIN="bbs" 185 | fi 186 | echo "---------------------------" 187 | echo "Subdomain = $SUBDOMAIN" 188 | echo "---------------------------" 189 | echo "" 190 | else 191 | if [ "$IS_DOMAIN" = "1" ]; then 192 | clear 193 | echo "" 194 | echo "Over! Because $DOMAIN is exist!" 195 | echo "" 196 | exit 197 | else 198 | echo "---------------------------" 199 | echo "You don't want to add subdomain" 200 | echo "---------------------------" 201 | echo "" 202 | fi 203 | fi 204 | 205 | get_char() 206 | { 207 | SAVEDSTTY=`stty -g` 208 | stty -echo 209 | stty cbreak 210 | dd if=/dev/tty bs=1 count=1 2> /dev/null 211 | stty -raw 212 | stty echo 213 | stty $SAVEDSTTY 214 | } 215 | echo "Press any key to start create vhost..." 216 | echo "Or Ctrl+C cancel and exit ?" 217 | echo "" 218 | char=`get_char` 219 | 220 | 221 | if [ ! -d "/home/$VHOST_ACCOUNT" ]; then 222 | mkdir -p /home/$VHOST_ACCOUNT/public_html 223 | chmod -R 711 /home/$VHOST_ACCOUNT 224 | echo $DOMAIN > /home/$VHOST_ACCOUNT/public_html/index.php 225 | fi 226 | 227 | if [ "$ADD_SUBDOMAIN" = 'y' ]; then 228 | mkdir -p /home/$VHOST_ACCOUNT/public_html/$SUBDOMAIN 229 | chmod 711 /home/$VHOST_ACCOUNT/public_html/$SUBDOMAIN 230 | echo ${SUBDOMAIN}.${DOMAIN} > /home/$VHOST_ACCOUNT/public_html/$SUBDOMAIN/index.php 231 | fi 232 | 233 | ################################### MySQL ################################### 234 | 235 | if [ "$ADD_FTPUSER" = "y" ]; then 236 | UNUM=`awk -F: '$1=="www"{print $3}' /etc/passwd` 237 | GNUM=`awk -F: '$1=="www"{print $4}' /etc/passwd` 238 | cat >/tmp/add_ftpuser<<-EOF 239 | use pureftpd; 240 | insert pureftpd.users values ('$VHOST_ACCOUNT',md5('$FTP_PWD'),'$UNUM','$GNUM','/home/$VHOST_ACCOUNT','0','0','0','0','*','','1','0','0'); 241 | EOF 242 | cat /tmp/add_ftpuser | mysql -u root -p$MYSQL_ROOT_PWD 243 | rm -rf /tmp/add_ftpuser 244 | fi 245 | 246 | if [ "$ADD_MYSQL_DB" = "y" ]; then 247 | cat >/tmp/add_mysql_db<<-EOF 248 | create database $MYSQL_DB_NAME; 249 | grant all on ${MYSQL_DB_NAME}.* to $MYSQL_DB_NAME@localhost identified by '$MYSQL_DB_PWD'; 250 | EOF 251 | cat /tmp/add_mysql_db | mysql -u root -p$MYSQL_ROOT_PWD 252 | rm -rf /tmp/add_mysql_db 253 | fi 254 | 255 | ################################### Nginx ################################### 256 | 257 | if [ "$SOFTWARE" != "2" ]; then 258 | 259 | if [ "$SOFTWARE" = "1" ]; then 260 | if grep -iqw $VHOST_ACCOUNT /etc/passwd; then 261 | echo "$VHOST_ACCOUNT is exist!" 262 | else 263 | groupadd $VHOST_ACCOUNT 264 | useradd -g $VHOST_ACCOUNT -d /home/$VHOST_ACCOUNT -s /bin/false $VHOST_ACCOUNT 265 | chown -R $VHOST_ACCOUNT:$VHOST_ACCOUNT /home/$VHOST_ACCOUNT 266 | fi 267 | fi 268 | 269 | if [ ! -s "/usr/local/nginx/conf/vhosts/$DOMAIN.conf" ];then 270 | if [ "$SOFTWARE" = "1" ]; then 271 | cp $LANMP_PATH/conf/nginx-vhost-original.conf /usr/local/nginx/conf/vhosts/$DOMAIN.conf 272 | else 273 | cp $LANMP_PATH/conf/nginx-vhost-proxy.conf /usr/local/nginx/conf/vhosts/$DOMAIN.conf 274 | fi 275 | chmod 644 /usr/local/nginx/conf/vhosts/$DOMAIN.conf 276 | sed -i 's/DOMAIN/'$DOMAIN'/g' /usr/local/nginx/conf/vhosts/$DOMAIN.conf 277 | sed -i 's,ROOTDIR,/home/'$VHOST_ACCOUNT'/public_html,g' /usr/local/nginx/conf/vhosts/$DOMAIN.conf 278 | fi 279 | 280 | if [ "$ADD_SUBDOMAIN" = 'y' ]; then 281 | if [ ! -s "/usr/local/nginx/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf" ];then 282 | cp /usr/local/nginx/conf/vhosts/$DOMAIN.conf /usr/local/nginx/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf 283 | sed -i 's/server_name '$DOMAIN'/server_name/g' /usr/local/nginx/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf 284 | sed -i 's/www./'$SUBDOMAIN'./g' /usr/local/nginx/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf 285 | sed -i 's,public_html,public_html/'$SUBDOMAIN',g' /usr/local/nginx/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf 286 | fi 287 | fi 288 | 289 | if [ "$NGINX_REWRITE" = 'y' ] && [ "$SOFTWARE" = "1" ]; then 290 | if [ "$ADD_SUBDOMAIN" = 'y' ]; then 291 | sed -i 's/\#include REWRITE_RULE/include '$REWRITE_RULE'/g' /usr/local/nginx/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf 292 | else 293 | sed -i 's/\#include REWRITE_RULE/include '$REWRITE_RULE'/g' /usr/local/nginx/conf/vhosts/$DOMAIN.conf 294 | fi 295 | chmod 644 /usr/local/nginx/conf/$REWRITE_RULE.conf 296 | fi 297 | 298 | if [ ! -d "/usr/local/nginx/logs/$DOMAIN" ]; then 299 | mkdir /usr/local/nginx/logs/$DOMAIN 300 | fi 301 | 302 | fi 303 | 304 | ################################### Apache ################################### 305 | 306 | if [ "$SOFTWARE" != "1" ]; then 307 | 308 | chown -R www:www /home/$VHOST_ACCOUNT 309 | 310 | if [ ! -s "/usr/local/apache/conf/vhosts/$DOMAIN.conf" ];then 311 | cat >>/usr/local/apache/conf/vhosts/$DOMAIN.conf<<-EOF 312 | 313 | ServerAdmin webmaster@$DOMAIN 314 | DocumentRoot "/home/$VHOST_ACCOUNT/public_html" 315 | ServerName $DOMAIN 316 | ServerAlias www.$DOMAIN 317 | ErrorLog "logs/$DOMAIN/error.log" 318 | CustomLog "logs/$DOMAIN/access.log" combinedio 319 | 320 | Options +Includes +Indexes 321 | php_admin_flag engine ON 322 | php_admin_value open_basedir "/home/$VHOST_ACCOUNT/public_html:/tmp:/proc" 323 | 324 | 325 | 326 | EOF 327 | if [ "$SOFTWARE" = "2" ]; then 328 | cat >>/usr/local/apache/conf/vhosts/$DOMAIN.conf<<-EOF 329 | 330 | ServerAdmin webmaster@$DOMAIN 331 | DocumentRoot "/home/$VHOST_ACCOUNT/public_html" 332 | ServerName $DOMAIN 333 | ServerAlias www.$DOMAIN 334 | ErrorLog "logs/$DOMAIN/error.log" 335 | CustomLog "logs/$DOMAIN/access.log" combinedio 336 | SSLEngine on 337 | SSLCertificateFile "/usr/local/apache/conf/ssl/server.crt" 338 | SSLCertificateKeyFile "/usr/local/apache/conf/ssl/server.key" 339 | #SSLCACertificateFile "/usr/local/apache/conf/ssl/ca.crt" 340 | 341 | Options +Includes +Indexes 342 | php_admin_flag engine ON 343 | php_admin_value open_basedir "/home/$VHOST_ACCOUNT/public_html:/tmp:/proc" 344 | 345 | 346 | EOF 347 | fi 348 | fi 349 | 350 | if [ "$ADD_SUBDOMAIN" = 'y' ]; then 351 | if [ ! -s "/usr/local/apache/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf" ];then 352 | cat >>/usr/local/apache/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf<<-EOF 353 | 354 | ServerAdmin webmaster@$DOMAIN 355 | DocumentRoot "/home/$VHOST_ACCOUNT/public_html/$SUBDOMAIN" 356 | ServerName $SUBDOMAIN.$DOMAIN 357 | ErrorLog "logs/$DOMAIN/error.log" 358 | CustomLog "logs/$DOMAIN/access.log" combinedio 359 | 360 | Options +Includes +Indexes 361 | php_admin_flag engine ON 362 | php_admin_value open_basedir "/home/$VHOST_ACCOUNT/public_html/$SUBDOMAIN:/tmp:/proc" 363 | 364 | 365 | 366 | EOF 367 | if [ "$SOFTWARE" = "2" ]; then 368 | cat >>/usr/local/apache/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf<<-EOF 369 | 370 | ServerAdmin webmaster@$DOMAIN 371 | DocumentRoot "/home/$VHOST_ACCOUNT/public_html/$SUBDOMAIN" 372 | ServerName $SUBDOMAIN.$DOMAIN 373 | ErrorLog "logs/$DOMAIN/error.log" 374 | CustomLog "logs/$DOMAIN/access.log" combinedio 375 | SSLEngine on 376 | SSLCertificateFile "/usr/local/apache/conf/ssl/server.crt" 377 | SSLCertificateKeyFile "/usr/local/apache/conf/ssl/server.key" 378 | #SSLCACertificateFile "/usr/local/apache/conf/ssl/ca.crt" 379 | 380 | Options +Includes +Indexes 381 | php_admin_flag engine ON 382 | php_admin_value open_basedir "/home/$VHOST_ACCOUNT/public_html/$SUBDOMAIN:/tmp:/proc" 383 | 384 | 385 | EOF 386 | fi 387 | 388 | fi 389 | fi 390 | 391 | if [ ! -d "/usr/local/apache/logs/$DOMAIN" ]; then 392 | mkdir /usr/local/apache/logs/$DOMAIN 393 | fi 394 | 395 | fi 396 | 397 | ################################### Nginx + Apache ################################### 398 | 399 | if [ "$SOFTWARE" = "3" ]; then 400 | if [ "$ADD_SUBDOMAIN" = 'n' ]; then 401 | sed -i 's/\*:80/127.0.0.1:8080/g' /usr/local/apache/conf/vhosts/$DOMAIN.conf 402 | else 403 | sed -i 's/\*:80/127.0.0.1:8080/g' /usr/local/apache/conf/vhosts/${SUBDOMAIN}.${DOMAIN}.conf 404 | fi 405 | fi 406 | 407 | if [ "$SOFTWARE" != "2" ]; then 408 | echo "Test Nginx configure file......" 409 | /usr/local/nginx/sbin/nginx -t 410 | echo "" 411 | /etc/init.d/nginx reload 412 | fi 413 | 414 | if [ "$SOFTWARE" != "1" ]; then 415 | echo "Test apache configure file......" 416 | /usr/local/apache/bin/apachectl -t 417 | echo "" 418 | /etc/init.d/httpd restart 419 | fi 420 | 421 | clear 422 | echo "" 423 | echo "===================== Install completed =====================" 424 | echo "" 425 | echo "Your account: $VHOST_ACCOUNT" 426 | echo "Your domain: $DOMAIN" 427 | echo "Your domain directory: /home/$VHOST_ACCOUNT/" 428 | if [ "$ADD_SUBDOMAIN" = 'y' ]; then 429 | echo "Your subdomain: $SUBDOMAIN" 430 | echo "Your subdomain directory: /home/$VHOST_ACCOUNT/public_html/$SUBDOMAIN" 431 | fi 432 | echo "" 433 | if [ "$SOFTWARE" != "2" ]; then 434 | echo "nginx vhost config file at: /usr/local/nginx/conf/vhosts/$DOMAIN.conf" 435 | elif [ "$SOFTWARE" != "1" ]; then 436 | echo "httpd config file at: /usr/local/apache/conf/vhosts/$DOMAIN.conf" 437 | fi 438 | echo "" 439 | echo "=============================================================" 440 | echo "" 441 | -------------------------------------------------------------------------------- /rpm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 3 | export PATH 4 | 5 | if [ $(id -u) != "0" ]; then 6 | printf "Error: You must be root to run this script!" 7 | exit 1 8 | fi 9 | 10 | LANMP_PATH=`pwd` 11 | if [ `echo $LANMP_PATH | awk -F/ '{print $NF}'` != "lanmp" ]; then 12 | clear && echo "Please enter lanmp script path:" 13 | read -p "(Default path: ${LANMP_PATH}/lanmp):" LANMP_PATH 14 | [ -z "$LANMP_PATH" ] && LANMP_PATH=$(pwd)/lanmp 15 | cd $LANMP_PATH/ 16 | fi 17 | 18 | clear 19 | echo "#############################################################" 20 | echo "# Linux + Apache + Nginx + MySQL + PHP Auto Install Script" 21 | echo "# Env: Redhat/CentOS" 22 | echo "# Intro: https://wangyan.org/blog/lanmp.html" 23 | echo "# Version: $(awk '/version/{print $2}' $LANMP_PATH/Changelog)" 24 | echo "#" 25 | echo "# Copyright (c) 2012, WangYan " 26 | echo "# All rights reserved." 27 | echo "# Distributed under the GNU General Public License, version 3.0." 28 | echo "#" 29 | echo "#############################################################" 30 | echo "" 31 | 32 | echo "Please enter the server IP address:" 33 | TEMP_IP=`ifconfig |grep 'inet' | grep -Evi '(inet6|127.0.0.1)' | awk '{print $2}' | cut -d: -f2 | tail -1` 34 | read -p "(e.g: $TEMP_IP):" IP_ADDRESS 35 | if [ -z $IP_ADDRESS ]; then 36 | IP_ADDRESS="$TEMP_IP" 37 | fi 38 | echo "---------------------------" 39 | echo "IP address = $IP_ADDRESS" 40 | echo "---------------------------" 41 | echo "" 42 | 43 | echo "Please enter the webroot dir:" 44 | read -p "(Default webroot dir: /var/www):" WEBROOT 45 | if [ -z $WEBROOT ]; then 46 | WEBROOT="/var/www" 47 | fi 48 | echo "---------------------------" 49 | echo "Webroot dir=$WEBROOT" 50 | echo "---------------------------" 51 | echo "" 52 | 53 | echo "Please enter the MySQL root password:" 54 | read -p "(Default password: 123456):" MYSQL_ROOT_PWD 55 | if [ -z $MYSQL_ROOT_PWD ]; then 56 | MYSQL_ROOT_PWD="123456" 57 | fi 58 | echo "---------------------------" 59 | echo "MySQL root password = $MYSQL_ROOT_PWD" 60 | echo "---------------------------" 61 | echo "" 62 | 63 | echo "Please enter the MySQL pma password:" 64 | read -p "(Default password: 123456):" PMAPWD 65 | if [ -z $PMAPWD ]; then 66 | PMAPWD="123456" 67 | fi 68 | echo "---------------------------" 69 | echo "PMA password = $PMAPWD" 70 | echo "---------------------------" 71 | echo "" 72 | 73 | echo "Please choose webserver software! (1:nginx,2:apache,3:nginx+apache) (1/2/3)" 74 | read -p "(Default: 3):" SOFTWARE 75 | if [ -z $SOFTWARE ]; then 76 | SOFTWARE="3" 77 | fi 78 | echo "---------------------------" 79 | echo "You choose = $SOFTWARE" 80 | echo "---------------------------" 81 | echo "" 82 | 83 | echo "Please choose the version of PHP: (1:php-5.2.x,2:php-5.5.x) (1/2)" 84 | read -p "(Default version: 2):" PHP_VER 85 | if [ -z $PHP_VER ]; then 86 | PHP_VER="2" 87 | fi 88 | echo "---------------------------" 89 | echo "PHP Version = $PHP_VER" 90 | echo "---------------------------" 91 | echo "" 92 | 93 | echo "Do you want to initialize aliyun ? (y/n)" 94 | read -p "(Default: n):" INIT_ALIYUN 95 | if [ -z $INIT_ALIYUN ]; then 96 | INIT_ALIYUN="n" 97 | fi 98 | echo "---------------------------" 99 | echo "You choose = $INIT_ALIYUN" 100 | echo "---------------------------" 101 | echo "" 102 | 103 | echo "Do you want to install xCache ? (y/n)" 104 | read -p "(Default: y):" INSTALL_XC 105 | if [ -z $INSTALL_XC ]; then 106 | INSTALL_XC="y" 107 | fi 108 | echo "---------------------------" 109 | echo "You choose = $INSTALL_XC" 110 | echo "---------------------------" 111 | echo "" 112 | 113 | echo "Do you want to install ioncube ? (y/n)" 114 | read -p "(Default: y):" INSTALL_IONCUBE 115 | if [ -z $INSTALL_IONCUBE ]; then 116 | INSTALL_IONCUBE="y" 117 | fi 118 | echo "---------------------------" 119 | echo "You choose = $INSTALL_IONCUBE" 120 | echo "---------------------------" 121 | echo "" 122 | 123 | echo "Do you want to install Zend Optimizer ? (y/n)" 124 | read -p "(Default: y):" INSTALL_ZEND 125 | if [ -z $INSTALL_ZEND ]; then 126 | INSTALL_ZEND="y" 127 | fi 128 | echo "---------------------------" 129 | echo "You choose = $INSTALL_ZEND" 130 | echo "---------------------------" 131 | echo "" 132 | 133 | get_char() 134 | { 135 | SAVEDSTTY=`stty -g` 136 | stty -echo 137 | stty cbreak 138 | dd if=/dev/tty bs=1 count=1 2> /dev/null 139 | stty -raw 140 | stty echo 141 | stty $SAVEDSTTY 142 | } 143 | echo "Press any key to start install..." 144 | echo "Or Ctrl+C cancel and exit ?" 145 | echo "" 146 | char=`get_char` 147 | 148 | echo "---------- Network Check ----------" 149 | 150 | ping -c 1 baidu.com &>/dev/null && PING=1 || PING=0 151 | 152 | if [ -d "$LANMP_PATH/src" ];then 153 | \mv $LANMP_PATH/src/* $LANMP_PATH 154 | fi 155 | 156 | if [ "$PING" = 0 ];then 157 | echo "Network Failed!" 158 | [ ! -s mysql-*.tar.gz ] && exit 159 | else 160 | echo "Network OK" 161 | fi 162 | 163 | echo "---------- Aliyun Initialize ----------" 164 | 165 | if [ "$INIT_ALIYUN" = "y" ]; then 166 | $LANMP_PATH/aliyun_init.sh 167 | fi 168 | 169 | echo "---------- Remove Packages ----------" 170 | 171 | yum -y remove httpd 172 | yum -y remove mysql 173 | yum -y remove php 174 | yum -y update 175 | 176 | if [ ! -s /etc/yum.conf.bak ]; then 177 | cp /etc/yum.conf /etc/yum.conf.bak 178 | fi 179 | sed -i 's:exclude=.*:exclude=:g' /etc/yum.conf 180 | 181 | echo "---------- Set timezone ----------" 182 | 183 | rm -rf /etc/localtime 184 | ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 185 | 186 | yum -y install ntp 187 | [ "$PING" = 1 ] && ntpdate -d cn.pool.ntp.org 188 | 189 | echo "---------- Disable SeLinux ----------" 190 | 191 | if [ -s /etc/selinux/config ]; then 192 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 193 | fi 194 | 195 | echo "---------- Set Library ----------" 196 | 197 | if [ ! `grep -iqw /lib /etc/ld.so.conf` ]; then 198 | echo "/lib" >> /etc/ld.so.conf 199 | fi 200 | 201 | if [ ! `grep -iqw /usr/lib /etc/ld.so.conf` ]; then 202 | echo "/usr/lib" >> /etc/ld.so.conf 203 | fi 204 | 205 | if [ -d "/usr/lib64" ] && [ ! `grep -iqw /usr/lib64 /etc/ld.so.conf` ]; then 206 | echo "/usr/lib64" >> /etc/ld.so.conf 207 | fi 208 | 209 | if [ ! `grep -iqw /usr/local/lib /etc/ld.so.conf` ]; then 210 | echo "/usr/local/lib" >> /etc/ld.so.conf 211 | fi 212 | 213 | ldconfig 214 | 215 | echo "---------- Set Environment ----------" 216 | 217 | if [ "$INIT_ALIYUN" != "y" ];then 218 | cat >>/etc/security/limits.conf<<-EOF 219 | * soft nproc 65535 220 | * hard nproc 65535 221 | * soft nofile 65535 222 | * hard nofile 65535 223 | EOF 224 | ulimit -v unlimited 225 | 226 | cat >>/etc/sysctl.conf<<-EOF 227 | fs.file-max=65535 228 | EOF 229 | sysctl -p 230 | fi 231 | 232 | echo "---------- Dependent Packages ----------" 233 | 234 | yum -y install make cmake autoconf autoconf213 gcc gcc-c++ libtool 235 | yum -y install wget elinks bison patch unzip tar 236 | yum -y install openssl openssl-devel 237 | yum -y install zlib zlib-devel 238 | yum -y install freetype freetype-devel 239 | yum -y install libxml2 libxml2-devel 240 | yum -y install libdhash libdhash-devel 241 | yum -y install curl curl-devel 242 | yum -y install xmlrpc-c xmlrpc-c-devel 243 | yum -y install libevent libevent-devel 244 | yum -y install ncurses ncurses-devel 245 | yum -y install libc-client libc-client-devel 246 | 247 | ####################### Extract Function ######################## 248 | 249 | Extract(){ 250 | local TARBALL_TYPE 251 | if [ -n $1 ]; then 252 | SOFTWARE_NAME=`echo $1 | awk -F/ '{print $NF}'` 253 | TARBALL_TYPE=`echo $1 | awk -F. '{print $NF}'` 254 | wget -c -t3 -T3 $1 -P $LANMP_PATH/ 255 | if [ $? != "0" ];then 256 | rm -rf $LANMP_PATH/$SOFTWARE_NAME 257 | wget -c -t3 -T60 $2 -P $LANMP_PATH/ 258 | SOFTWARE_NAME=`echo $2 | awk -F/ '{print $NF}'` 259 | TARBALL_TYPE=`echo $2 | awk -F. '{print $NF}'` 260 | fi 261 | else 262 | SOFTWARE_NAME=`echo $2 | awk -F/ '{print $NF}'` 263 | TARBALL_TYPE=`echo $2 | awk -F. '{print $NF}'` 264 | wget -c -t3 -T3 $2 -P $LANMP_PATH/ || exit 265 | fi 266 | EXTRACTED_DIR=`tar tf $LANMP_PATH/$SOFTWARE_NAME | tail -n 1 | awk -F/ '{print $1}'` 267 | case $TARBALL_TYPE in 268 | gz|tgz) 269 | tar zxf $LANMP_PATH/$SOFTWARE_NAME -C $LANMP_PATH/ && cd $LANMP_PATH/$EXTRACTED_DIR || return 1 270 | ;; 271 | bz2|tbz) 272 | tar jxf $LANMP_PATH/$SOFTWARE_NAME -C $LANMP_PATH/ && cd $LANMP_PATH/$EXTRACTED_DIR || return 1 273 | ;; 274 | tar|Z) 275 | tar xf $LANMP_PATH/$SOFTWARE_NAME -C $LANMP_PATH/ && cd $LANMP_PATH/$EXTRACTED_DIR || return 1 276 | ;; 277 | *) 278 | echo "$SOFTWARE_NAME is wrong tarball type ! " 279 | esac 280 | } 281 | 282 | echo "===================== MySQL Install ====================" 283 | 284 | cd $LANMP_PATH 285 | rm -rf /etc/my.cnf /etc/mysql/ 286 | 287 | groupadd mysql 288 | useradd -g mysql -M -s /bin/false mysql 289 | 290 | if [ ! -s mysql-*.tar.gz ]; then 291 | LATEST_MYSQL_LINK=`elinks ftp://mirror.csclub.uwaterloo.ca/mysql/Downloads/MySQL-5.6/ | awk '/ftp:.+\.[0-9][0-9][a-z]?\.tar\.gz$/{print $2}' | tail -n 1` 292 | BACKUP_MYSQL_LINK='http://wangyan.org/download/lanmp-src/mysql-latest.tar.gz' 293 | Extract ${LATEST_MYSQL_LINK} ${BACKUP_MYSQL_LINK} 294 | else 295 | tar -zxf mysql-*.tar.gz 296 | cd mysql-* 297 | fi 298 | 299 | cmake . \ 300 | -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ 301 | -DEXTRA_CHARSETS=all \ 302 | -DDEFAULT_CHARSET=utf8 \ 303 | -DDEFAULT_COLLATION=utf8_general_ci \ 304 | -DWITH_MYISAM_STORAGE_ENGINE=1 \ 305 | -DWITH_INNOBASE_STORAGE_ENGINE=1 \ 306 | -DWITH_MEMORY_STORAGE_ENGINE=1 \ 307 | -DWITH_READLINE=1 \ 308 | -DENABLED_LOCAL_INFILE=1 \ 309 | -DENABLE_DOWNLOADS=0 310 | make install 311 | 312 | #cd ../ 313 | #cp conf/my.cnf /etc/my.cnf 314 | cp support-files/my-default.cnf /etc/my.cnf 315 | 316 | cd /usr/local/mysql 317 | scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --explicit_defaults_for_timestamp 318 | chown -R root:root /usr/local/mysql/. 319 | chown -R mysql /usr/local/mysql/data 320 | 321 | cp support-files/mysql.server /etc/init.d/mysql 322 | chmod 755 /etc/init.d/mysql 323 | chkconfig mysql on 324 | 325 | if [ ! `grep -iqw /usr/local/mysql/lib /etc/ld.so.conf` ]; then 326 | echo "/usr/local/mysql/lib" >> /etc/ld.so.conf 327 | fi 328 | ldconfig 329 | 330 | cd /usr/local/mysql/bin 331 | for i in *; do ln -s /usr/local/mysql/bin/$i /usr/bin/$i; done 332 | 333 | /etc/init.d/mysql start 334 | /usr/local/mysql/bin/mysqladmin -u root password $MYSQL_ROOT_PWD 335 | 336 | echo "===================== Apache Install ====================" 337 | 338 | if [ "$SOFTWARE" != "1" ]; then 339 | 340 | echo "---------- Apache ----------" 341 | 342 | cd $LANMP_PATH/ 343 | 344 | if [ ! -s httpd-*.tar.gz ]; then 345 | LATEST_APACHE_LINK="https://gitcafe.com/wangyan/files/raw/master/httpd-2.2.25.tar.gz" 346 | BACKUP_APACHE_LINK="http://wangyan.org/download/lanmp-src/httpd-2.2.25.tar.gz" 347 | Extract ${LATEST_APACHE_LINK} ${BACKUP_APACHE_LINK} 348 | else 349 | tar -zxf httpd-*.tar.gz 350 | cd httpd-*/ 351 | fi 352 | 353 | ./configure --prefix=/usr/local/apache --enable-mods-shared=most --enable-ssl=shared --with-mpm=prefork 354 | make && make install 355 | 356 | echo "---------- Apache config ----------" 357 | 358 | cd $LANMP_PATH/ 359 | 360 | groupadd www 361 | useradd -g www -M -s /bin/false www 362 | 363 | for i in `ls /usr/local/apache/bin/`; do ln -s /usr/local/apache/bin/$i /usr/bin/$i; done 364 | 365 | cp conf/init.d.httpd /etc/init.d/httpd 366 | chmod 755 /etc/init.d/httpd 367 | chkconfig httpd on 368 | 369 | mv /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.old 370 | cp conf/httpd.conf /usr/local/apache/conf/httpd.conf 371 | chmod 644 /usr/local/apache/conf/httpd.conf 372 | 373 | mv /usr/local/apache/conf/extra/httpd-mpm.conf /usr/local/apache/conf/extra/httpd-mpm.conf.bak 374 | cp conf/httpd-mpm.conf /usr/local/apache/conf/extra/httpd-mpm.conf 375 | chmod 644 /usr/local/apache/conf/extra/httpd-mpm.conf 376 | 377 | mkdir /usr/local/apache/conf/vhosts 378 | chmod 711 /usr/local/apache/conf/vhosts 379 | mkdir -p $WEBROOT 380 | cp conf/p.php $WEBROOT 381 | 382 | echo "---------- Apache SSL ----------" 383 | 384 | cd $LANMP_PATH/ 385 | 386 | mkdir /usr/local/apache/conf/ssl 387 | chmod 711 /usr/local/apache/conf/ssl 388 | cp conf/server* /usr/local/apache/conf/ssl 389 | chmod 644 /usr/local/apache/conf/ssl/* 390 | 391 | mv /usr/local/apache/conf/extra/httpd-ssl.conf /usr/local/apache/conf/extra/httpd-ssl.conf.bak 392 | cp conf/httpd-ssl.conf /usr/local/apache/conf/extra/httpd-ssl.conf 393 | chmod 644 /usr/local/apache/conf/extra/httpd-ssl.conf 394 | sed -i 's,WEBROOT,'$WEBROOT',g' /usr/local/apache/conf/extra/httpd-ssl.conf 395 | 396 | if [ "$SOFTWARE" = "2" ]; then 397 | sed -i 's,#Include conf/extra/httpd-s,Include conf/extra/httpd-s,g' /usr/local/apache/conf/httpd.conf 398 | fi 399 | 400 | echo "---------- Apache frontend ----------" 401 | 402 | if [ "$SOFTWARE" = "2" ]; then 403 | sed -i 's/\#Listen 80/Listen 80/g' /usr/local/apache/conf/httpd.conf 404 | 405 | cat >/usr/local/apache/conf/extra/httpd-vhosts.conf<<-EOF 406 | NameVirtualHost *:80 407 | 408 | 409 | ServerAdmin webmaster@example.com 410 | DocumentRoot "$WEBROOT" 411 | ServerName 127.0.0.1 412 | ErrorLog "logs/error_log" 413 | CustomLog "logs/access_log" combinedio 414 | 415 | Options +Includes +Indexes 416 | php_admin_flag engine ON 417 | php_admin_value open_basedir "$WEBROOT:/tmp:/proc" 418 | 419 | 420 | 421 | Include /usr/local/apache/conf/vhosts/*.conf 422 | EOF 423 | fi 424 | 425 | echo "---------- Apache backend ----------" 426 | 427 | cd $LANMP_PATH/ 428 | 429 | if [ "$SOFTWARE" = "3" ]; then 430 | 431 | echo "---------- RPAF Moudle ----------" 432 | 433 | if [ ! -s mod_rpaf-*.tar.gz ]; then 434 | LATEST_RPAF_LINK="https://gitcafe.com/wangyan/files/raw/master/mod_rpaf-0.6.tar.gz" 435 | BACKUP_RPAF_LINK="http://wangyan.org/download/lanmp-src/mod_rpaf-latest.tar.gz" 436 | Extract ${LATEST_RPAF_LINK} ${BACKUP_RPAF_LINK} 437 | else 438 | tar zxf mod_rpaf-*.tar.gz 439 | cd mod_rpaf-*/ 440 | fi 441 | /usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c 442 | 443 | sed -i 's/\#Listen 127/Listen 127/g' /usr/local/apache/conf/httpd.conf 444 | sed -i 's/\#LoadModule rpaf/LoadModule rpaf/g' /usr/local/apache/conf/httpd.conf 445 | 446 | echo "---------- Backend Config ----------" 447 | 448 | cat >/usr/local/apache/conf/extra/httpd-vhosts.conf<<-EOF 449 | NameVirtualHost 127.0.0.1:8080 450 | 451 | 452 | ServerAdmin webmaster@example.com 453 | DocumentRoot "$WEBROOT" 454 | ServerName 127.0.0.1 455 | ErrorLog "logs/error_log" 456 | CustomLog "logs/access_log" combinedio 457 | 458 | Options +Includes +Indexes 459 | php_admin_flag engine ON 460 | php_admin_value open_basedir "$WEBROOT:/tmp:/proc" 461 | 462 | 463 | 464 | Include /usr/local/apache/conf/vhosts/*.conf 465 | EOF 466 | fi 467 | fi 468 | 469 | echo "===================== PHP5 Install ====================" 470 | 471 | echo "---------- libpng ----------" 472 | 473 | cd $LANMP_PATH/ 474 | 475 | if [ ! -s libpng-*.tar.gz ]; then 476 | LATEST_LIBPNG_LINK="https://gitcafe.com/wangyan/files/raw/master/libpng-1.6.3.tar.gz" 477 | BACKUP_LIBPNG_LINK="http://wangyan.org/download/lanmp-src/libpng-latest.tar.gz" 478 | Extract ${LATEST_LIBPNG_LINK} ${BACKUP_LIBPNG_LINK} 479 | else 480 | tar -zxf libpng-*.tar.gz 481 | cd libpng-*/ 482 | fi 483 | ./configure --prefix=/usr/local 484 | make && make install 485 | 486 | echo "---------- libjpeg ----------" 487 | 488 | cd $LANMP_PATH/ 489 | 490 | if [ ! -s jpegsrc.*.tar.gz ]; then 491 | LATEST_LIBJPEG_LINK="https://gitcafe.com/wangyan/files/raw/master/jpegsrc.v9.tar.gz" 492 | BACKUP_LIBJPEG_LINK="http://wangyan.org/download/lanmp-src/jpegsrc.latest.tar.gz" 493 | Extract ${LATEST_LIBJPEG_LINK} ${BACKUP_LIBJPEG_LINK} 494 | else 495 | tar -zxf jpegsrc.*.tar.gz 496 | cd jpeg-*/ 497 | fi 498 | ./configure --prefix=/usr/local 499 | make && make install 500 | 501 | echo "---------- libiconv ----------" 502 | 503 | cd $LANMP_PATH/ 504 | 505 | if [ ! -s libiconv-*.tar.gz ]; then 506 | LATEST_LIBICONV_LINK="https://gitcafe.com/wangyan/files/raw/master/libiconv-1.14.tar.gz" 507 | BACKUP_LIBICONV_LINK="http://wangyan.org/download/lanmp-src/libiconv-latest.tar.gz" 508 | Extract ${LATEST_LIBICONV_LINK} ${BACKUP_LIBICONV_LINK} 509 | else 510 | tar -zxf libiconv-*.tar.gz 511 | cd libiconv-*/ 512 | fi 513 | ./configure --prefix=/usr/local 514 | make && make install 515 | 516 | echo "---------- libmcrypt ----------" 517 | 518 | cd $LANMP_PATH/ 519 | 520 | if [ ! -s libmcrypt-*.tar.gz ]; then 521 | LATEST_LIBMCRYPT_LINK="https://gitcafe.com/wangyan/files/raw/master/libmcrypt-2.5.8.tar.gz" 522 | BACKUP_LIBMCRYPT_LINK="http://wangyan.org/download/lanmp-src/libmcrypt-latest.tar.gz" 523 | Extract ${LATEST_LIBMCRYPT_LINK} ${BACKUP_LIBMCRYPT_LINK} 524 | else 525 | tar -zxf libmcrypt-*.tar.gz 526 | cd libmcrypt-*/ 527 | fi 528 | ./configure --prefix=/usr/local 529 | make && make install 530 | 531 | echo "---------- mhash ----------" 532 | 533 | cd $LANMP_PATH/ 534 | 535 | if [ ! -s mhash-*.tar.gz ]; then 536 | LATEST_MHASH_LINK="https://gitcafe.com/wangyan/files/raw/master/mhash-0.9.9.9.tar.gz" 537 | BACKUP_MHASH_LINK="http://wangyan.org/download/lanmp-src/mhash-latest.tar.gz" 538 | Extract ${LATEST_MHASH_LINK} ${BACKUP_MHASH_LINK} 539 | else 540 | tar -zxf mhash-*.tar.gz 541 | cd mhash-*/ 542 | fi 543 | ./configure --prefix=/usr/local 544 | make && make install && ldconfig 545 | 546 | echo "---------- mcrypt ----------" 547 | 548 | cd $LANMP_PATH/ 549 | 550 | if [ ! -s mcrypt-*.tar.gz ]; then 551 | LATEST_MCRYPT_LINK="https://gitcafe.com/wangyan/files/raw/master/mcrypt-2.6.8.tar.gz" 552 | BACKUP_MCRYPT_LINK="http://wangyan.org/download/lanmp-src/mcrypt-latest.tar.gz" 553 | Extract ${LATEST_MCRYPT_LINK} ${BACKUP_MCRYPT_LINK} 554 | else 555 | tar -zxf mcrypt-*.tar.gz 556 | cd mcrypt-*/ 557 | fi 558 | ./configure --prefix=/usr/local 559 | make && make install 560 | 561 | echo "---------- php5 ----------" 562 | 563 | cd $LANMP_PATH/ 564 | 565 | groupadd www 566 | useradd -g www -M -s /bin/false www 567 | 568 | if [ "$PHP_VER" = "1" ]; then 569 | if [ ! -s php-5.2.17.tar.gz ]; then 570 | wget -c -t3 -T3 https://gitcafe.com/wangyan/files/raw/master/php-5.2.17.tar.gz 571 | if [ $? != "0" ];then 572 | rm -rf php-5.2.17.tar.gz 573 | wget -c -t3 -T60 http://wangyan.org/download/lanmp-src/php-5.2.17.tar.gz 574 | fi 575 | fi 576 | tar -zxf php-5.2.17.tar.gz 577 | 578 | if [ ! -s php-5.2.17-fpm-0.5.14.diff.gz ]; then 579 | wget -c -t3 -T3 https://gitcafe.com/wangyan/files/raw/master/php-5.2.17-fpm-0.5.14.diff.gz 580 | if [ $? != "0" ];then 581 | rm -rf php-5.2.17-fpm-0.5.14.diff.gz 582 | wget -c -t3 -T60 http://wangyan.org/download/lanmp-src/php-5.2.17-fpm-0.5.14.diff.gz 583 | fi 584 | fi 585 | gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1 586 | 587 | if [ ! -s php-5.2.17-max-input-vars.patch ]; then 588 | wget -c -t3 -T3 https://gitcafe.com/wangyan/files/raw/master/php-5.2.17-max-input-vars.patch 589 | if [ $? != "0" ];then 590 | rm -rf php-5.2.17-max-input-vars.patch 591 | wget -c -t3 -T60 http://wangyan.org/download/lanmp-src/php-5.2.17-max-input-vars.patch 592 | fi 593 | fi 594 | patch -d php-5.2.17 -p1 < php-5.2.17-max-input-vars.patch 595 | 596 | if [ ! -s debian_patches_disable_SSLv2_for_openssl_1_0_0.patch ]; then 597 | wget -c -t3 -T3 https://gitcafe.com/wangyan/files/raw/master/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch 598 | if [ $? != "0" ];then 599 | rm -rf debian_patches_disable_SSLv2_for_openssl_1_0_0.patch 600 | wget -c -t3 -T60 http://wangyan.org/download/lanmp-src/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch 601 | fi 602 | fi 603 | patch -d php-5.2.17/ext/openssl/ -p3 < debian_patches_disable_SSLv2_for_openssl_1_0_0.patch 604 | cd php-5.2.17/ 605 | else 606 | if [ ! -s php-5.5.*.tar.gz ]; then 607 | LATEST_PHP_VERSION=`curl -s http://php.net/downloads.php | awk '/Current Stable/{print $3}'` 608 | LATEST_PHP_LINK="http://php.net/distributions/php-${LATEST_PHP_VERSION}.tar.gz" 609 | BACKUP_PHP_LINK="http://wangyan.org/download/lanmp-src/php-latest.tar.gz" 610 | Extract ${LATEST_PHP_LINK} ${BACKUP_PHP_LINK} 611 | else 612 | tar -zxf php-5.5.*.tar.gz 613 | cd php-5.5.*/ 614 | fi 615 | fi 616 | 617 | if [[ "$SOFTWARE" = "1" && "$PHP_VER" = "1" ]]; then 618 | ./buildconf --force 619 | ./configure \ 620 | --prefix=/usr/local/php \ 621 | --with-curl \ 622 | --with-curlwrappers \ 623 | --with-freetype-dir \ 624 | --with-gettext \ 625 | --with-gd \ 626 | --with-iconv-dir \ 627 | --with-jpeg-dir \ 628 | --with-libxml-dir \ 629 | --with-mcrypt \ 630 | --with-mhash \ 631 | --with-mysql=/usr/local/mysql \ 632 | --with-mysqli=/usr/local/mysql/bin/mysql_config \ 633 | --with-mime-magic \ 634 | --with-openssl \ 635 | --with-pear \ 636 | --with-png-dir \ 637 | --with-xmlrpc \ 638 | --with-zlib \ 639 | --enable-bcmath \ 640 | --enable-calendar \ 641 | --enable-discard-path \ 642 | --enable-exif \ 643 | --enable-fastcgi \ 644 | --enable-force-cgi-redirect \ 645 | --enable-fpm \ 646 | --enable-ftp \ 647 | --enable-gd-native-ttf \ 648 | --enable-inline-optimization \ 649 | --enable-magic-quotes \ 650 | --enable-mbregex \ 651 | --enable-mbstring \ 652 | --enable-pcntl \ 653 | --enable-shmop \ 654 | --enable-soap \ 655 | --enable-sockets \ 656 | --enable-sysvsem \ 657 | --enable-sysvshm \ 658 | --enable-xml \ 659 | --enable-zend-multibyte \ 660 | --enable-zip 661 | elif [[ "$SOFTWARE" = "1" && "$PHP_VER" = "2" ]]; then 662 | ./configure \ 663 | --prefix=/usr/local/php \ 664 | --with-curl \ 665 | --with-freetype-dir \ 666 | --with-gettext \ 667 | --with-gd \ 668 | --with-iconv-dir \ 669 | --with-jpeg-dir \ 670 | --with-libxml-dir \ 671 | --with-mcrypt \ 672 | --with-mhash \ 673 | --with-mysql=/usr/local/mysql \ 674 | --with-mysqli=/usr/local/mysql/bin/mysql_config \ 675 | --with-openssl \ 676 | --with-pear \ 677 | --with-png-dir \ 678 | --with-xmlrpc \ 679 | --with-zlib \ 680 | --enable-bcmath \ 681 | --enable-calendar \ 682 | --enable-exif \ 683 | --enable-fpm \ 684 | --enable-ftp \ 685 | --enable-gd-native-ttf \ 686 | --enable-inline-optimization \ 687 | --enable-mbregex \ 688 | --enable-mbstring \ 689 | --enable-pcntl \ 690 | --enable-shmop \ 691 | --enable-soap \ 692 | --enable-sockets \ 693 | --enable-sysvsem \ 694 | --enable-sysvshm \ 695 | --enable-xml \ 696 | --enable-zip 697 | elif [ "$SOFTWARE" != "1" ]; then 698 | ./configure \ 699 | --prefix=/usr/local/php \ 700 | --with-apxs2=/usr/local/apache/bin/apxs \ 701 | --with-curl \ 702 | --with-curlwrappers \ 703 | --with-freetype-dir \ 704 | --with-gettext \ 705 | --with-gd \ 706 | --with-iconv-dir \ 707 | --with-jpeg-dir \ 708 | --with-libxml-dir \ 709 | --with-mcrypt \ 710 | --with-mhash \ 711 | --with-mysql=/usr/local/mysql \ 712 | --with-mysqli=/usr/local/mysql/bin/mysql_config \ 713 | --with-openssl \ 714 | --with-pear \ 715 | --with-png-dir \ 716 | --with-xmlrpc \ 717 | --with-zlib \ 718 | --enable-bcmath \ 719 | --enable-calendar \ 720 | --enable-exif \ 721 | --enable-ftp \ 722 | --enable-gd-native-ttf \ 723 | --enable-inline-optimization \ 724 | --enable-mbregex \ 725 | --enable-mbstring \ 726 | --enable-shmop \ 727 | --enable-soap \ 728 | --enable-sockets \ 729 | --enable-sysvsem \ 730 | --enable-sysvshm \ 731 | --enable-xml \ 732 | --enable-zip 733 | fi 734 | 735 | make ZEND_EXTRA_LIBS='-liconv' 736 | make install 737 | 738 | echo "---------- PDO MYSQL Extension ----------" 739 | 740 | cd ext/pdo_mysql/ 741 | /usr/local/php/bin/phpize 742 | ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql 743 | make && make install 744 | 745 | echo "---------- Memcache Extension ----------" 746 | 747 | cd $LANMP_PATH/ 748 | 749 | if [ ! -s memcache-*.tgz ]; then 750 | LATEST_MEMCACHE_LINK="https://gitcafe.com/wangyan/files/raw/master/memcache-2.2.6.tgz" 751 | BACKUP_MEMCACHE_LINK="http://wangyan.org/download/lanmp-src/memcache-latest.tgz" 752 | Extract ${LATEST_MEMCACHE_LINK} ${BACKUP_MEMCACHE_LINK} 753 | else 754 | tar -zxf memcache-*.tgz 755 | cd memcache-*/ 756 | fi 757 | /usr/local/php/bin/phpize 758 | ./configure --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir --enable-memcache 759 | make && make install 760 | 761 | echo "---------- PHP Config ----------" 762 | 763 | cd $LANMP_PATH/ 764 | 765 | for i in `ls /usr/local/php/bin`; do ln -s /usr/local/php/bin/$i /usr/bin/$i; done 766 | 767 | if [ "$PHP_VER" = "1" ];then 768 | cp php-*/php.ini-recommended /usr/local/php/lib/php.ini 769 | sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\n#g' /usr/local/php/lib/php.ini 770 | else 771 | cp php-*/php.ini-production /usr/local/php/lib/php.ini 772 | sed -i 's#; extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\n#g' /usr/local/php/lib/php.ini 773 | fi 774 | 775 | sed -i 's/short_open_tag = Off/short_open_tag = On/g' /usr/local/php/lib/php.ini 776 | sed -i 's/disable_functions =/disable_functions = system,passthru,exec,shell_exec,popen,symlink,dl/g' /usr/local/php/lib/php.ini 777 | sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /usr/local/php/lib/php.ini 778 | sed -i 's/post_max_size = 8M/post_max_size = 80M/g' /usr/local/php/lib/php.ini 779 | sed -i 's/magic_quotes_gpc = Off/magic_quotes_gpc = On/g' /usr/local/php/lib/php.ini 780 | sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php/lib/php.ini 781 | sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 20M/g' /usr/local/php/lib/php.ini 782 | sed -i 's#;date.timezone =#date.timezone = Asia/Shanghai#g' /usr/local/php/lib/php.ini 783 | sed -i 's#;sendmail_path =#sendmail_path = /usr/sbin/sendmail -t -i#g' /usr/local/php/lib/php.ini 784 | 785 | if [[ "$SOFTWARE" = "1" && "$PHP_VER" = "1" ]]; then 786 | cp conf/init.d.php-fpm /etc/init.d/php-fpm 787 | chmod 755 /etc/init.d/php-fpm 788 | chkconfig php-fpm on 789 | cp conf/php-fpm-p2.conf /usr/local/php/etc/php-fpm.conf 790 | /etc/init.d/php-fpm start 791 | elif [[ "$SOFTWARE" = "1" && "$PHP_VER" = "2" ]]; then 792 | cp php-5.5.*/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 793 | chmod 755 /etc/init.d/php-fpm 794 | chkconfig php-fpm on 795 | cp conf/php-fpm-p4.conf /usr/local/php/etc/php-fpm.conf 796 | /etc/init.d/php-fpm start 797 | elif [ "$SOFTWARE" != "1" ]; then 798 | /etc/init.d/httpd start 799 | fi 800 | 801 | echo "---------- Xcache Extension ----------" 802 | 803 | cd $LANMP_PATH/ 804 | 805 | if [[ "$INSTALL_XC" = "y" && $PHP_VER = "1" ]];then 806 | 807 | if [ ! -s xcache-*.tar.gz ]; then 808 | LATEST_XCACHE_LINK="https://gitcafe.com/wangyan/files/raw/master/xcache-3.0.3.tar.gz" 809 | BACKUP_XCACHE_LINK="http://wangyan.org/download/lanmp-src/xcache-latest.tar.gz" 810 | Extract ${LATEST_XCACHE_LINK} ${BACKUP_XCACHE_LINK} 811 | else 812 | tar zxf xcache-*.tar.gz 813 | cd xcache-*/ 814 | fi 815 | /usr/local/php/bin/phpize 816 | ./configure --enable-xcache --enable-xcache-optimizer --enable-xcache-coverager 817 | make && make install 818 | 819 | mkdir -p $WEBROOT/ 820 | cp -r admin/ $WEBROOT/xcache 821 | chmod -R 755 $WEBROOT/xcache 822 | 823 | mkdir /tmp/{pcov,phpcore} 824 | chown www:www /tmp/{pcov,phpcore} 825 | chmod 700 /tmp/{pcov,phpcore} 826 | 827 | if [ "$PHP_VER" = "1" ]; then 828 | cat >>/usr/local/php/lib/php.ini<<-EOF 829 | [xcache-common] 830 | zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so 831 | EOF 832 | else 833 | cat >>/usr/local/php/lib/php.ini<<-EOF 834 | [xcache-common] 835 | zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xcache.so 836 | EOF 837 | fi 838 | cat >>/usr/local/php/lib/php.ini<<-EOF 839 | 840 | [xcache.admin] 841 | xcache.admin.user = admin 842 | xcache.admin.pass = e10adc3949ba59abbe56e057f20f883e 843 | xcache.admin.enable_auth = On 844 | xcache.test = Off 845 | xcache.coredump_directory = /tmp/phpcore 846 | xcache.disable_on_crash = "" 847 | 848 | [xcache] 849 | xcache.cacher = On 850 | xcache.size = 64M 851 | xcache.count = 4 852 | xcache.slots = 8K 853 | xcache.ttl = 3600 854 | xcache.gc_interval = 60 855 | xcache.var_size = 1M 856 | xcache.var_count = 4 857 | xcache.var_slots = 8K 858 | xcache.var_ttl = 3600 859 | xcache.var_maxttl = 0 860 | xcache.var_gc_interval = 60 861 | xcache.readonly_protection = Off 862 | xcache.mmap_path = /dev/zero 863 | 864 | [xcache.optimizer] 865 | xcache.optimizer = On 866 | 867 | [xcache.coverager] 868 | xcache.coverager = On 869 | xcache.coveragedump_directory = /tmp/pcov 870 | 871 | EOF 872 | elif [[ "$INSTALL_XC" = "y" && $PHP_VER = "2" ]]; then 873 | cat >>/usr/local/php/lib/php.ini<<-EOF 874 | 875 | [opcache] 876 | zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/opcache.so 877 | opcache.enable_cli=1 878 | opcache.memory_consumption=128 879 | opcache.interned_strings_buffer=8 880 | opcache.max_accelerated_files=4000 881 | opcache.revalidate_freq=1 882 | opcache.fast_shutdown=1 883 | 884 | EOF 885 | fi 886 | 887 | echo "---------- Ioncube Extension ----------" 888 | 889 | cd $LANMP_PATH 890 | 891 | if [[ "$INSTALL_IONCUBE" = "y" && $PHP_VER = "1" ]];then 892 | if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then 893 | if [ ! -s ioncube_loaders_lin_x86-64.tar.gz ]; then 894 | LATEST_IONCUBE_LINK="https://gitcafe.com/wangyan/files/raw/master/ioncube_loaders_lin_x86-64.tar.gz" 895 | BACKUP_IONCUBE_LINK="http://wangyan.org/download/lanmp-src/ioncube_loaders_lin_x86-64.tar.gz" 896 | Extract ${LATEST_IONCUBE_LINK} ${BACKUP_IONCUBE_LINK} 897 | else 898 | tar -zxf ioncube_loaders_lin_x86-64.tar.gz 899 | cd ioncube/ 900 | fi 901 | else 902 | if [ ! -s ioncube_loaders_lin_x86.tar.gz ]; then 903 | LATEST_IONCUBE_LINK="https://gitcafe.com/wangyan/files/raw/master/ioncube_loaders_lin_x86.tar.gz" 904 | BACKUP_IONCUBE_LINK="http://wangyan.org/download/lanmp-src/ioncube_loaders_lin_x86.tar.gz" 905 | Extract ${LATEST_IONCUBE_LINK} ${BACKUP_IONCUBE_LINK} 906 | else 907 | tar -zxf ioncube_loaders_lin_x86.tar.gz 908 | cd ioncube/ 909 | fi 910 | fi 911 | 912 | mkdir -p /usr/local/zend/ 913 | if [ "$PHP_VER" = "1" ]; then 914 | cp ioncube_loader_lin_5.2.so /usr/local/zend/ 915 | cat >>/usr/local/php/lib/php.ini<<-EOF 916 | [ioncube loader] 917 | zend_extension = /usr/local/zend/ioncube_loader_lin_5.2.so 918 | EOF 919 | else 920 | cp ioncube_loader_lin_5.4.so /usr/local/zend/ 921 | cat >>/usr/local/php/lib/php.ini<<-EOF 922 | [ioncube loader] 923 | zend_extension = /usr/local/zend/ioncube_loader_lin_5.4.so 924 | EOF 925 | fi 926 | fi 927 | 928 | echo "---------- ZendOptimizer Extension ----------" 929 | 930 | cd $LANMP_PATH/ 931 | 932 | if [ "$INSTALL_ZEND" = "y" ];then 933 | 934 | if [ "$PHP_VER" = "1" ]; then 935 | if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then 936 | if [ ! -s ZendOptimizer-*-linux-glibc23-x86_64.tar.gz ]; then 937 | LATEST_ZEND_LINK="https://gitcafe.com/wangyan/files/raw/master/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz" 938 | BACKUP_ZEND_LINK="http://wangyan.org/download/lanmp-src/ZendOptimizer-latest-linux-glibc23-x86_64.tar.gz" 939 | Extract ${LATEST_ZEND_LINK} ${BACKUP_ZEND_LINK} 940 | else 941 | tar zxf ZendOptimizer-*-linux-glibc23-x86_64.tar.gz 942 | cd ZendOptimizer-*-linux-glibc23-x86_64/ 943 | fi 944 | else 945 | if [ ! -s ZendOptimizer-*-linux-glibc23-i386.tar.gz ]; then 946 | LATEST_ZEND_LINK="https://gitcafe.com/wangyan/files/raw/master/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz" 947 | BACKUP_ZEND_LINK="http://wangyan.org/download/lanmp-src/ZendOptimizer-latest-linux-glibc23-i386.tar.gz" 948 | Extract ${LATEST_ZEND_LINK} ${BACKUP_ZEND_LINK} 949 | else 950 | tar zxf ZendOptimizer-*-linux-glibc23-i386.tar.gz 951 | cd ZendOptimizer-*-linux-glibc23-i386/ 952 | fi 953 | fi 954 | mkdir -p /usr/local/zend/ 955 | cp data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/ 956 | cat >>/usr/local/php/lib/php.ini<<-EOF 957 | 958 | [Zend Optimizer] 959 | zend_extension = /usr/local/zend/ZendOptimizer.so 960 | zend_loader.enable = 1 961 | EOF 962 | else 963 | if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then 964 | if [ ! -s ZendGuardLoader-*-linux-glibc23-x86_64.tar.gz ]; then 965 | LATEST_GUARD_LINK="https://gitcafe.com/wangyan/files/raw/master/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz" 966 | BACKUP_GUARD_LINK="http://wangyan.org/download/lanmp-src/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz" 967 | Extract ${LATEST_GUARD_LINK} ${BACKUP_GUARD_LINK} 968 | else 969 | tar -zxf ZendGuardLoader-*-linux-glibc23-x86_64.tar.gz 970 | cd ZendGuardLoader-*-linux-glibc23-x86_64/ 971 | fi 972 | else 973 | if [ ! -s ZendGuardLoader-*-linux-glibc23-i386.tar.gz ]; then 974 | LATEST_GUARD_LINK="https://gitcafe.com/wangyan/files/raw/master/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz" 975 | BACKUP_GUARD_LINK="http://wangyan.org/download/lanmp-src/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz" 976 | Extract ${LATEST_GUARD_LINK} ${BACKUP_GUARD_LINK} 977 | else 978 | tar -zxf ZendGuardLoader-*-linux-glibc23-i386.tar.gz 979 | cd ZendGuardLoader-*-linux-glibc23-i386/ 980 | fi 981 | fi 982 | mkdir -p /usr/local/zend/ 983 | cp php-5.4.x/ZendGuardLoader.so /usr/local/zend/ 984 | cat >>/usr/local/php/lib/php.ini<<-EOF 985 | 986 | [Zend GuardLoader] 987 | zend_extension = /usr/local/zend/ZendGuardLoader.so 988 | zend_loader.enable = 1 989 | EOF 990 | fi 991 | fi 992 | 993 | if [ "$SOFTWARE" = "1" ]; then 994 | /etc/init.d/php-fpm restart 995 | else 996 | /usr/local/apache/bin/httpd -k restart 997 | fi 998 | 999 | echo "===================== Nginx Install ====================" 1000 | 1001 | if [ "$SOFTWARE" != "2" ]; then 1002 | 1003 | groupadd www 1004 | useradd -g www -M -s /bin/false www 1005 | 1006 | echo "---------- Pcre ----------" 1007 | 1008 | cd $LANMP_PATH/ 1009 | 1010 | if [ ! -s pcre-*.tar.gz ]; then 1011 | LATEST_PCRE_LINK="https://gitcafe.com/wangyan/files/raw/master/pcre-8.33.tar.gz" 1012 | BACKUP_PCRE_LINK="http://wangyan.org/download/lanmp-src/pcre-latest.tar.gz" 1013 | Extract ${LATEST_PCRE_LINK} ${BACKUP_PCRE_LINK} 1014 | else 1015 | tar -zxf pcre-*.tar.gz 1016 | cd pcre-*/ 1017 | fi 1018 | ./configure 1019 | make && make install && ldconfig 1020 | 1021 | echo "---------- Nginx ----------" 1022 | 1023 | cd $LANMP_PATH/ 1024 | mkdir -p /var/tmp/nginx 1025 | 1026 | if [ ! -s nginx-*.tar.gz ]; then 1027 | LATEST_NGINX_VERSION=`curl -s http://nginx.org/| awk -F- '/nginx-/{print $6}' | head -1|cut -d '<' -f 1` 1028 | LATEST_NGINX_LINK="http://nginx.org/download/nginx-${LATEST_NGINX_VERSION}.tar.gz" 1029 | BACKUP_NGINX_LINK="http://wangyan.org/download/lanmp-src/nginx-latest.tar.gz" 1030 | Extract ${LATEST_NGINX_LINK} ${BACKUP_NGINX_LINK} 1031 | else 1032 | tar -zxf nginx-*.tar.gz 1033 | cd nginx-*/ 1034 | fi 1035 | 1036 | ./configure \ 1037 | --pid-path=/var/run/nginx.pid \ 1038 | --lock-path=/var/lock/nginx.lock \ 1039 | --user=www \ 1040 | --group=www \ 1041 | --with-http_ssl_module \ 1042 | --with-http_dav_module \ 1043 | --with-http_flv_module \ 1044 | --with-http_realip_module \ 1045 | --with-http_gzip_static_module \ 1046 | --with-http_stub_status_module \ 1047 | --with-mail \ 1048 | --with-mail_ssl_module \ 1049 | --with-pcre \ 1050 | --with-debug \ 1051 | --with-ipv6 \ 1052 | --http-client-body-temp-path=/var/tmp/nginx/client \ 1053 | --http-proxy-temp-path=/var/tmp/nginx/proxy \ 1054 | --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \ 1055 | --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ 1056 | --http-scgi-temp-path=/var/tmp/nginx/scgi 1057 | make && make install 1058 | 1059 | echo "---------- Nginx Config----------" 1060 | 1061 | cd $LANMP_PATH/ 1062 | mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak 1063 | cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf 1064 | chmod 644 /usr/local/nginx/conf/nginx.conf 1065 | 1066 | mkdir /usr/local/nginx/conf/ssl 1067 | chmod 711 /usr/local/nginx/conf/ssl 1068 | cp conf/server* /usr/local/nginx/conf/ssl/ 1069 | chmod 644 /usr/local/nginx/conf/ssl/* 1070 | 1071 | mkdir /usr/local/nginx/conf/vhosts 1072 | chmod 711 /usr/local/nginx/conf/vhosts 1073 | mkdir /usr/local/nginx/logs/localhost 1074 | 1075 | if [ "$SOFTWARE" = "1" ]; then 1076 | cp conf/nginx-vhost-original.conf /usr/local/nginx/conf/vhosts/localhost.conf 1077 | else 1078 | cp conf/nginx-vhost-localhost.conf /usr/local/nginx/conf/vhosts/localhost.conf 1079 | cp conf/proxy_cache.inc /usr/local/nginx/conf/proxy_cache.inc 1080 | fi 1081 | chmod 644 /usr/local/nginx/conf/vhosts/localhost.conf 1082 | sed -i 's,www.DOMAIN,,g' /usr/local/nginx/conf/vhosts/localhost.conf 1083 | sed -i 's,DOMAIN/,localhost/,g' /usr/local/nginx/conf/vhosts/localhost.conf 1084 | sed -i 's,DOMAIN,'$IP_ADDRESS',g' /usr/local/nginx/conf/vhosts/localhost.conf 1085 | sed -i 's,ROOTDIR,'$WEBROOT',g' /usr/local/nginx/conf/vhosts/localhost.conf 1086 | 1087 | if [ ! -d $WEBROOT ]; then 1088 | mkdir -p $WEBROOT 1089 | fi 1090 | \cp conf/p.php $WEBROOT 1091 | 1092 | cp conf/init.d.nginx /etc/init.d/nginx 1093 | chmod 755 /etc/init.d/nginx 1094 | chkconfig nginx on 1095 | 1096 | ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx 1097 | /etc/init.d/nginx stop 1098 | /etc/init.d/nginx start 1099 | fi 1100 | 1101 | echo "================phpMyAdmin Install===============" 1102 | 1103 | cd $LANMP_PATH/ 1104 | /etc/init.d/mysql restart 1105 | 1106 | if [ ! -s phpMyAdmin-*-all-languages.tar.gz ]; then 1107 | PMA_VERSION=`elinks http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/ | awk -F/ '{print $7F}' | sort -n | grep -iv '-' | tail -1` 1108 | PMA_LINK="http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/" 1109 | LATEST_PMA_LINK="${PMA_LINK}${PMA_VERSION}/phpMyAdmin-${PMA_VERSION}-all-languages.tar.gz" 1110 | BACKUP_PMA_LINK="http://wangyan.org/download/lanmp-src/phpMyAdmin-latest-all-languages.tar.gz" 1111 | Extract ${LATEST_PMA_LINK} ${BACKUP_PMA_LINK} 1112 | mkdir -p $WEBROOT/phpmyadmin 1113 | mv * $WEBROOT/phpmyadmin 1114 | else 1115 | PMA_VERSION=`ls phpMyAdmin-*-all-languages.tar.gz | awk -F- '{print $2}'` 1116 | tar -zxf phpMyAdmin-*-all-languages.tar.gz -C $WEBROOT 1117 | mv $WEBROOT/phpMyAdmin-*-all-languages $WEBROOT/phpmyadmin 1118 | fi 1119 | 1120 | cd $LANMP_PATH/ 1121 | cp conf/config.inc.php $WEBROOT/phpmyadmin/config.inc.php 1122 | sed -i 's/PMAPWD/'$PMAPWD'/g' $WEBROOT/phpmyadmin/config.inc.php 1123 | 1124 | cp conf/control_user.sql /tmp/control_user.sql 1125 | sed -i 's/PMAPWD/'$PMAPWD'/g' /tmp/control_user.sql 1126 | /usr/local/mysql/bin/mysql -u root -p$MYSQL_ROOT_PWD -h localhost < /tmp/control_user.sql 1127 | 1128 | if [ -s $WEBROOT/phpmyadmin/scripts/create_tables.sql ]; then 1129 | cp $WEBROOT/phpmyadmin/scripts/create_tables.sql /tmp/create_tables.sql 1130 | else 1131 | cp $WEBROOT/phpmyadmin/examples/create_tables.sql /tmp/create_tables.sql 1132 | sed -i 's/pma__/pma_/g' $WEBROOT/phpmyadmin/examples/create_tables.sql 1133 | fi 1134 | 1135 | /usr/local/mysql/bin/mysql -u root -p$MYSQL_ROOT_PWD -h localhost < $WEBROOT/phpmyadmin/examples/create_tables.sql 1136 | 1137 | rm -rf /usr/local/mysql/data/test/ 1138 | 1139 | echo -e "phpmyadmin\t${PMA_VERSION}" >> version.txt 2>&1 1140 | 1141 | if [ ! -d "src/" ];then 1142 | mkdir -p src/ 1143 | fi 1144 | \mv ./{*gz,*-*/,*patch,ioncube,package.xml} ./src >/dev/null 2>&1 1145 | 1146 | clear 1147 | echo "" 1148 | echo "===================== Install completed =====================" 1149 | echo "" 1150 | echo "LANMP install completed!" 1151 | echo "For more information please visit http://wangyan.org/blog/lanmp.html" 1152 | echo "" 1153 | echo "Server ip address: $IP_ADDRESS" 1154 | echo "MySQL root password: $MYSQL_ROOT_PWD" 1155 | echo "MySQL pma password: $PMAPWD" 1156 | echo "" 1157 | echo "php config file at: /usr/local/php/lib/php.ini" 1158 | echo "Pear config file at: /usr/local/php/etc/pear.conf" 1159 | [ "$SOFTWARE" = "1" ] && echo "php-fpm config file at: /usr/local/php/etc/php-fpm.conf" 1160 | [ "$SOFTWARE" != "2" ] && echo "nginx config file at: /usr/local/nginx/conf/nginx.conf" 1161 | [ "$SOFTWARE" != "1" ] && echo "httpd config file at: /usr/local/apache/conf/httpd.conf" 1162 | echo "" 1163 | echo "WWW root dir: $WEBROOT" 1164 | echo "PHP prober: http://$IP_ADDRESS/p.php" 1165 | echo "phpMyAdmin: http://$IP_ADDRESS/phpmyadmin/" 1166 | echo "" 1167 | echo "=============================================================" 1168 | echo "" 1169 | -------------------------------------------------------------------------------- /deb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 3 | export PATH 4 | 5 | if [ $(id -u) != "0" ]; then 6 | printf "Error: You must be root to run this script!" 7 | exit 1 8 | fi 9 | 10 | LANMP_PATH=`pwd` 11 | if [ `echo $LANMP_PATH | awk -F/ '{print $NF}'` != "lanmp" ]; then 12 | clear && echo "Please enter lanmp script path:" 13 | read -p "(Default path: ${LANMP_PATH}/lanmp):" LANMP_PATH 14 | [ -z "$LANMP_PATH" ] && LANMP_PATH=$(pwd)/lanmp 15 | cd $LANMP_PATH/ 16 | fi 17 | 18 | clear 19 | echo "#############################################################" 20 | echo "# Linux + Apache + Nginx + MySQL + PHP Auto Install Script" 21 | echo "# Env: Debian/Ubuntu" 22 | echo "# Intro: https://wangyan.org/blog/lanmp.html" 23 | echo "# Version: $(awk '/version/{print $2}' $LANMP_PATH/Changelog)" 24 | echo "#" 25 | echo "# Copyright (c) 2012, WangYan " 26 | echo "# All rights reserved." 27 | echo "# Distributed under the GNU General Public License, version 3.0." 28 | echo "#" 29 | echo "#############################################################" 30 | echo "" 31 | 32 | echo "Please enter the server IP address:" 33 | TEMP_IP=`ifconfig |grep 'inet' | grep -Evi '(inet6|127.0.0.1)' | awk '{print $2}' | cut -d: -f2 | tail -1` 34 | read -p "(e.g: $TEMP_IP):" IP_ADDRESS 35 | if [ -z $IP_ADDRESS ]; then 36 | IP_ADDRESS="$TEMP_IP" 37 | fi 38 | echo "---------------------------" 39 | echo "IP address = $IP_ADDRESS" 40 | echo "---------------------------" 41 | echo "" 42 | 43 | echo "Please enter the webroot dir:" 44 | read -p "(Default webroot dir: /var/www):" WEBROOT 45 | if [ -z $WEBROOT ]; then 46 | WEBROOT="/var/www" 47 | fi 48 | echo "---------------------------" 49 | echo "Webroot dir=$WEBROOT" 50 | echo "---------------------------" 51 | echo "" 52 | 53 | echo "Please enter the MySQL root password:" 54 | read -p "(Default password: 123456):" MYSQL_ROOT_PWD 55 | if [ -z $MYSQL_ROOT_PWD ]; then 56 | MYSQL_ROOT_PWD="123456" 57 | fi 58 | echo "---------------------------" 59 | echo "MySQL root password = $MYSQL_ROOT_PWD" 60 | echo "---------------------------" 61 | echo "" 62 | 63 | echo "Please enter the MySQL pma password:" 64 | read -p "(Default password: 123456):" PMAPWD 65 | if [ -z $PMAPWD ]; then 66 | PMAPWD="123456" 67 | fi 68 | echo "---------------------------" 69 | echo "PMA password = $PMAPWD" 70 | echo "---------------------------" 71 | echo "" 72 | 73 | echo "Please choose webserver software! (1:nginx,2:apache,3:nginx+apache) (1/2/3)" 74 | read -p "(Default: 3):" SOFTWARE 75 | if [ -z $SOFTWARE ]; then 76 | SOFTWARE="3" 77 | fi 78 | echo "---------------------------" 79 | echo "You choose = $SOFTWARE" 80 | echo "---------------------------" 81 | echo "" 82 | 83 | echo "Please choose the version of PHP: (1:php-5.2.x,2:php-5.5.x) (1/2)" 84 | read -p "(Default version: 2):" PHP_VER 85 | if [ -z $PHP_VER ]; then 86 | PHP_VER="2" 87 | fi 88 | echo "---------------------------" 89 | echo "PHP Version = $PHP_VER" 90 | echo "---------------------------" 91 | echo "" 92 | 93 | echo "Do you want to initialize aliyun ? (y/n)" 94 | read -p "(Default: n):" INIT_ALIYUN 95 | if [ -z $INIT_ALIYUN ]; then 96 | INIT_ALIYUN="n" 97 | fi 98 | echo "---------------------------" 99 | echo "You choose = $INIT_ALIYUN" 100 | echo "---------------------------" 101 | echo "" 102 | 103 | echo "Do you want to install xcache ? (y/n)" 104 | read -p "(Default: y):" INSTALL_XC 105 | if [ -z $INSTALL_XC ]; then 106 | INSTALL_XC="y" 107 | fi 108 | echo "---------------------------" 109 | echo "You choose = $INSTALL_XC" 110 | echo "---------------------------" 111 | echo "" 112 | 113 | echo "Do you want to install ioncube ? (y/n)" 114 | read -p "(Default: y):" INSTALL_IONCUBE 115 | if [ -z $INSTALL_IONCUBE ]; then 116 | INSTALL_IONCUBE="y" 117 | fi 118 | echo "---------------------------" 119 | echo "You choose = $INSTALL_IONCUBE" 120 | echo "---------------------------" 121 | echo "" 122 | 123 | echo "Do you want to install Zend Optimizer ? (y/n)" 124 | read -p "(Default: y):" INSTALL_ZEND 125 | if [ -z $INSTALL_ZEND ]; then 126 | INSTALL_ZEND="y" 127 | fi 128 | echo "---------------------------" 129 | echo "You choose = $INSTALL_ZEND" 130 | echo "---------------------------" 131 | echo "" 132 | 133 | get_char() 134 | { 135 | SAVEDSTTY=`stty -g` 136 | stty -echo 137 | stty cbreak 138 | dd if=/dev/tty bs=1 count=1 2> /dev/null 139 | stty -raw 140 | stty echo 141 | stty $SAVEDSTTY 142 | } 143 | echo "Press any key to start install..." 144 | echo "Or Ctrl+C cancel and exit ?" 145 | echo "" 146 | char=`get_char` 147 | 148 | echo "---------- Network Check ----------" 149 | 150 | ping -c 1 baidu.com &>/dev/null && PING=1 || PING=0 151 | 152 | if [ -d "$LANMP_PATH/src" ];then 153 | \mv $LANMP_PATH/src/* $LANMP_PATH 154 | fi 155 | 156 | if [ "$PING" = 0 ];then 157 | echo "Network Failed!" 158 | [ ! -s mysql-*.tar.gz ] && exit 159 | else 160 | echo "Network OK" 161 | fi 162 | 163 | echo "---------- Aliyun Initialize ----------" 164 | 165 | if [ "$INIT_ALIYUN" = "y" ]; then 166 | $LANMP_PATH/aliyun_init.sh 167 | fi 168 | 169 | echo "---------- Remove Packages ----------" 170 | 171 | dpkg -P apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils 172 | dpkg -P mysql-common libmysqlclient15off libmysqlclient15-dev 173 | dpkg -P php 174 | 175 | if [ -s /etc/ld.so.conf.d/libc6-xen.conf ]; then 176 | sed -i 's/hwcap 1 nosegneg/hwcap 0 nosegneg/g' /etc/ld.so.conf.d/libc6-xen.conf 177 | fi 178 | 179 | echo "---------- Set Timezone ----------" 180 | 181 | rm -rf /etc/localtime 182 | ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 183 | 184 | apt-get -y install ntpdate 185 | [ "$PING" = 1 ] && ntpdate -d cn.pool.ntp.org 186 | 187 | echo "---------- Disable SeLinux ----------" 188 | 189 | if [ -s /etc/selinux/config ]; then 190 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 191 | fi 192 | 193 | echo "---------- Set Library ----------" 194 | 195 | if [ ! `grep -iqw /lib /etc/ld.so.conf` ]; then 196 | echo "/lib" >> /etc/ld.so.conf 197 | fi 198 | 199 | if [ ! `grep -iqw /usr/lib /etc/ld.so.conf` ]; then 200 | echo "/usr/lib" >> /etc/ld.so.conf 201 | fi 202 | 203 | if [ -d "/usr/lib64" ] && [ ! `grep -iqw /usr/lib64 /etc/ld.so.conf` ]; then 204 | echo "/usr/lib64" >> /etc/ld.so.conf 205 | fi 206 | 207 | if [ ! `grep -iqw /usr/local/lib /etc/ld.so.conf` ]; then 208 | echo "/usr/local/lib" >> /etc/ld.so.conf 209 | fi 210 | 211 | ldconfig 212 | 213 | echo "---------- Set Environment ----------" 214 | 215 | if [ "$INIT_ALIYUN" != "y" ];then 216 | cat >>/etc/security/limits.conf<<-EOF 217 | * soft nproc 65535 218 | * hard nproc 65535 219 | * soft nofile 65535 220 | * hard nofile 65535 221 | EOF 222 | ulimit -v unlimited 223 | 224 | cat >>/etc/sysctl.conf<<-EOF 225 | fs.file-max=65535 226 | EOF 227 | sysctl -p 228 | fi 229 | 230 | echo "---------- Dependent Packages ----------" 231 | 232 | apt-get update 233 | apt-get -y autoremove 234 | apt-get -fy install 235 | apt-get -y --force-yes install make cmake autoconf2.13 gcc g++ libtool build-essential 236 | apt-get -y --force-yes install wget elinks bison unzip tar 237 | apt-get -y --force-yes install openssl libssl0.9 libssl-dev libsasl2-2 libsasl2-dev 238 | apt-get -y --force-yes install zlibc zlib1g zlib1g-dev 239 | apt-get -y --force-yes install libfreetype6 libfreetype6-dev 240 | apt-get -y --force-yes install libxml2 libxml2-dev 241 | apt-get -y --force-yes install libmhash2 libmhash-dev 242 | apt-get -y --force-yes install curl libcurl3 libcurl4-openssl-dev 243 | apt-get -y --force-yes install libxmlrpc-c3 libxmlrpc-c3-dev 244 | apt-get -y --force-yes install libevent-dev 245 | apt-get -y --force-yes install libncurses5 libncurses5-dev 246 | apt-get -y --force-yes install libltdl7 libltdl-dev 247 | apt-get -y --force-yes install libc-client2007e libc-client2007e-dev 248 | apt-get -y autoremove 249 | apt-get -fy install 250 | 251 | ####################### Extract Function ######################## 252 | 253 | Extract(){ 254 | local TARBALL_TYPE 255 | if [ -n $1 ]; then 256 | SOFTWARE_NAME=`echo $1 | awk -F/ '{print $NF}'` 257 | TARBALL_TYPE=`echo $1 | awk -F. '{print $NF}'` 258 | wget -c -t3 -T3 $1 -P $LANMP_PATH/ 259 | if [ $? != "0" ];then 260 | rm -rf $LANMP_PATH/$SOFTWARE_NAME 261 | wget -c -t3 -T60 $2 -P $LANMP_PATH/ 262 | SOFTWARE_NAME=`echo $2 | awk -F/ '{print $NF}'` 263 | TARBALL_TYPE=`echo $2 | awk -F. '{print $NF}'` 264 | fi 265 | else 266 | SOFTWARE_NAME=`echo $2 | awk -F/ '{print $NF}'` 267 | TARBALL_TYPE=`echo $2 | awk -F. '{print $NF}'` 268 | wget -c -t3 -T3 $2 -P $LANMP_PATH/ || exit 269 | fi 270 | EXTRACTED_DIR=`tar tf $LANMP_PATH/$SOFTWARE_NAME | tail -n 1 | awk -F/ '{print $1}'` 271 | case $TARBALL_TYPE in 272 | gz|tgz) 273 | tar zxf $LANMP_PATH/$SOFTWARE_NAME -C $LANMP_PATH/ && cd $LANMP_PATH/$EXTRACTED_DIR || return 1 274 | ;; 275 | bz2|tbz) 276 | tar jxf $LANMP_PATH/$SOFTWARE_NAME -C $LANMP_PATH/ && cd $LANMP_PATH/$EXTRACTED_DIR || return 1 277 | ;; 278 | tar|Z) 279 | tar xf $LANMP_PATH/$SOFTWARE_NAME -C $LANMP_PATH/ && cd $LANMP_PATH/$EXTRACTED_DIR || return 1 280 | ;; 281 | *) 282 | echo "$SOFTWARE_NAME is wrong tarball type ! " 283 | esac 284 | } 285 | 286 | echo "===================== MySQL Install ====================" 287 | 288 | cd $LANMP_PATH 289 | rm -rf /etc/my.cnf /etc/mysql/ 290 | 291 | groupadd mysql 292 | useradd -g mysql -s /bin/false mysql 293 | 294 | if [ ! -s mysql-*.tar.gz ]; then 295 | LATEST_MYSQL_LINK=`elinks ftp://mirror.csclub.uwaterloo.ca/mysql/Downloads/MySQL-5.6/ | awk '/ftp:.+\.[0-9][0-9][a-z]?\.tar\.gz$/{print $2}' | tail -n 1` 296 | BACKUP_MYSQL_LINK='http://wangyan.org/download/lanmp-src/mysql-latest.tar.gz' 297 | Extract ${LATEST_MYSQL_LINK} ${BACKUP_MYSQL_LINK} 298 | else 299 | tar -zxf mysql-*.tar.gz 300 | cd mysql-* 301 | fi 302 | 303 | cmake . \ 304 | -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ 305 | -DEXTRA_CHARSETS=all \ 306 | -DDEFAULT_CHARSET=utf8 \ 307 | -DDEFAULT_COLLATION=utf8_general_ci \ 308 | -DWITH_MYISAM_STORAGE_ENGINE=1 \ 309 | -DWITH_INNOBASE_STORAGE_ENGINE=1 \ 310 | -DWITH_MEMORY_STORAGE_ENGINE=1 \ 311 | -DWITH_READLINE=1 \ 312 | -DENABLED_LOCAL_INFILE=1 \ 313 | -DENABLE_DOWNLOADS=0 314 | make install 315 | 316 | #cd ../ 317 | #cp conf/my.cnf /etc/my.cnf 318 | cp support-files/my-default.cnf /etc/my.cnf 319 | 320 | cd /usr/local/mysql 321 | scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --explicit_defaults_for_timestamp 322 | chown -R root:root /usr/local/mysql/. 323 | chown -R mysql /usr/local/mysql/data 324 | 325 | cp support-files/mysql.server /etc/init.d/mysql 326 | chmod 755 /etc/init.d/mysql 327 | update-rc.d -f mysql defaults 328 | 329 | if [ ! `grep -iqw /usr/local/mysql/lib /etc/ld.so.conf` ]; then 330 | echo "/usr/local/mysql/lib" >> /etc/ld.so.conf 331 | fi 332 | ldconfig 333 | 334 | cd /usr/local/mysql/bin 335 | for i in *; do ln -s /usr/local/mysql/bin/$i /usr/bin/$i; done 336 | 337 | /etc/init.d/mysql start 338 | /usr/local/mysql/bin/mysqladmin -u root password $MYSQL_ROOT_PWD 339 | 340 | echo "===================== Apache Install ====================" 341 | 342 | if [ "$SOFTWARE" != "1" ]; then 343 | 344 | echo "---------- Apache ----------" 345 | 346 | cd $LANMP_PATH/ 347 | 348 | if [ ! -s httpd-*.tar.gz ]; then 349 | LATEST_APACHE_LINK="https://gitcafe.com/wangyan/files/raw/master/httpd-2.2.25.tar.gz" 350 | BACKUP_APACHE_LINK="http://wangyan.org/download/lanmp-src/httpd-2.2.25.tar.gz" 351 | Extract ${LATEST_APACHE_LINK} ${BACKUP_APACHE_LINK} 352 | else 353 | tar -zxf httpd-*.tar.gz 354 | cd httpd-*/ 355 | fi 356 | 357 | ./configure --prefix=/usr/local/apache --enable-mods-shared=most --enable-ssl=shared --with-mpm=prefork 358 | make && make install 359 | 360 | echo "---------- Apache config ----------" 361 | 362 | cd $LANMP_PATH/ 363 | 364 | groupadd www 365 | useradd -g www -s /bin/false www 366 | 367 | for i in `ls /usr/local/apache/bin/`; do ln -s /usr/local/apache/bin/$i /usr/bin/$i; done 368 | 369 | cp conf/init.d.httpd /etc/init.d/httpd 370 | chmod 755 /etc/init.d/httpd 371 | update-rc.d -f httpd defaults 372 | 373 | mv /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.old 374 | cp conf/httpd.conf /usr/local/apache/conf/httpd.conf 375 | chmod 644 /usr/local/apache/conf/httpd.conf 376 | 377 | mv /usr/local/apache/conf/extra/httpd-mpm.conf /usr/local/apache/conf/extra/httpd-mpm.conf.bak 378 | cp conf/httpd-mpm.conf /usr/local/apache/conf/extra/httpd-mpm.conf 379 | chmod 644 /usr/local/apache/conf/extra/httpd-mpm.conf 380 | 381 | mkdir /usr/local/apache/conf/vhosts 382 | chmod 711 /usr/local/apache/conf/vhosts 383 | mkdir -p $WEBROOT 384 | cp conf/p.php $WEBROOT 385 | 386 | echo "---------- Apache SSL ----------" 387 | 388 | cd $LANMP_PATH/ 389 | 390 | mkdir /usr/local/apache/conf/ssl 391 | chmod 711 /usr/local/apache/conf/ssl 392 | cp conf/server* /usr/local/apache/conf/ssl 393 | chmod 644 /usr/local/apache/conf/ssl/* 394 | 395 | mv /usr/local/apache/conf/extra/httpd-ssl.conf /usr/local/apache/conf/extra/httpd-ssl.conf.bak 396 | cp conf/httpd-ssl.conf /usr/local/apache/conf/extra/httpd-ssl.conf 397 | chmod 644 /usr/local/apache/conf/extra/httpd-ssl.conf 398 | sed -i 's,WEBROOT,'$WEBROOT',g' /usr/local/apache/conf/extra/httpd-ssl.conf 399 | 400 | if [ "$SOFTWARE" = "2" ]; then 401 | sed -i 's,#Include conf/extra/httpd-s,Include conf/extra/httpd-s,g' /usr/local/apache/conf/httpd.conf 402 | fi 403 | 404 | echo "---------- Apache frontend ----------" 405 | 406 | cd $LANMP_PATH/ 407 | 408 | if [ "$SOFTWARE" = "2" ]; then 409 | sed -i 's/\#Listen 80/Listen 80/g' /usr/local/apache/conf/httpd.conf 410 | 411 | cat >/usr/local/apache/conf/extra/httpd-vhosts.conf<<-EOF 412 | NameVirtualHost *:80 413 | 414 | 415 | ServerAdmin webmaster@example.com 416 | DocumentRoot "$WEBROOT" 417 | ServerName 127.0.0.1 418 | ErrorLog "logs/error_log" 419 | CustomLog "logs/access_log" combinedio 420 | 421 | Options +Includes +Indexes 422 | php_admin_flag engine ON 423 | php_admin_value open_basedir "$WEBROOT:/tmp:/proc" 424 | 425 | 426 | 427 | Include /usr/local/apache/conf/vhosts/*.conf 428 | EOF 429 | fi 430 | 431 | echo "---------- Apache backend ----------" 432 | 433 | cd $LANMP_PATH/ 434 | 435 | if [ "$SOFTWARE" = "3" ]; then 436 | 437 | echo "---------- RPAF Moudle ----------" 438 | 439 | if [ ! -s mod_rpaf-*.tar.gz ]; then 440 | LATEST_RPAF_LINK="https://gitcafe.com/wangyan/files/raw/master/mod_rpaf-0.6.tar.gz" 441 | BACKUP_RPAF_LINK="http://wangyan.org/download/lanmp-src/mod_rpaf-latest.tar.gz" 442 | Extract ${LATEST_RPAF_LINK} ${BACKUP_RPAF_LINK} 443 | else 444 | tar zxf mod_rpaf-*.tar.gz 445 | cd mod_rpaf-*/ 446 | fi 447 | /usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c 448 | 449 | sed -i 's/\#Listen 127/Listen 127/g' /usr/local/apache/conf/httpd.conf 450 | sed -i 's/\#LoadModule rpaf/LoadModule rpaf/g' /usr/local/apache/conf/httpd.conf 451 | 452 | echo "---------- Backend Config ----------" 453 | 454 | cat >/usr/local/apache/conf/extra/httpd-vhosts.conf<<-EOF 455 | NameVirtualHost 127.0.0.1:8080 456 | 457 | 458 | ServerAdmin webmaster@example.com 459 | DocumentRoot "$WEBROOT" 460 | ServerName 127.0.0.1 461 | ErrorLog "logs/error_log" 462 | CustomLog "logs/access_log" combinedio 463 | 464 | Options +Includes +Indexes 465 | php_admin_flag engine ON 466 | php_admin_value open_basedir "$WEBROOT:/tmp:/proc" 467 | 468 | 469 | 470 | Include /usr/local/apache/conf/vhosts/*.conf 471 | EOF 472 | fi 473 | fi 474 | 475 | echo "===================== PHP5 Install ====================" 476 | 477 | echo "---------- libpng ----------" 478 | 479 | cd $LANMP_PATH/ 480 | 481 | if [ ! -s libpng-*.tar.gz ]; then 482 | LATEST_LIBPNG_LINK="https://gitcafe.com/wangyan/files/raw/master/libpng-1.6.3.tar.gz" 483 | BACKUP_LIBPNG_LINK="http://wangyan.org/download/lanmp-src/libpng-latest.tar.gz" 484 | Extract ${LATEST_LIBPNG_LINK} ${BACKUP_LIBPNG_LINK} 485 | else 486 | tar -zxf libpng-*.tar.gz 487 | cd libpng-*/ 488 | fi 489 | ./configure --prefix=/usr/local 490 | make && make install 491 | 492 | echo "---------- libjpeg ----------" 493 | 494 | cd $LANMP_PATH/ 495 | 496 | if [ ! -s jpegsrc.*.tar.gz ]; then 497 | LATEST_LIBJPEG_LINK="https://gitcafe.com/wangyan/files/raw/master/jpegsrc.v9.tar.gz" 498 | BACKUP_LIBJPEG_LINK="http://wangyan.org/download/lanmp-src/jpegsrc.latest.tar.gz" 499 | Extract ${LATEST_LIBJPEG_LINK} ${BACKUP_LIBJPEG_LINK} 500 | else 501 | tar -zxf jpegsrc.*.tar.gz 502 | cd jpeg-*/ 503 | fi 504 | ./configure --prefix=/usr/local 505 | make && make install 506 | 507 | echo "---------- libiconv ----------" 508 | 509 | cd $LANMP_PATH/ 510 | 511 | if [ ! -s libiconv-*.tar.gz ]; then 512 | LATEST_LIBICONV_LINK="https://gitcafe.com/wangyan/files/raw/master/libiconv-1.14.tar.gz" 513 | BACKUP_LIBICONV_LINK="http://wangyan.org/download/lanmp-src/libiconv-latest.tar.gz" 514 | Extract ${LATEST_LIBICONV_LINK} ${BACKUP_LIBICONV_LINK} 515 | else 516 | tar -zxf libiconv-*.tar.gz 517 | cd libiconv-*/ 518 | fi 519 | ./configure --prefix=/usr/local 520 | make && make install 521 | 522 | echo "---------- libmcrypt ----------" 523 | 524 | cd $LANMP_PATH/ 525 | 526 | if [ ! -s libmcrypt-*.tar.gz ]; then 527 | LATEST_LIBMCRYPT_LINK="https://gitcafe.com/wangyan/files/raw/master/libmcrypt-2.5.8.tar.gz" 528 | BACKUP_LIBMCRYPT_LINK="http://wangyan.org/download/lanmp-src/libmcrypt-latest.tar.gz" 529 | Extract ${LATEST_LIBMCRYPT_LINK} ${BACKUP_LIBMCRYPT_LINK} 530 | else 531 | tar -zxf libmcrypt-*.tar.gz 532 | cd libmcrypt-*/ 533 | fi 534 | ./configure --prefix=/usr/local 535 | make && make install 536 | 537 | echo "---------- mhash ----------" 538 | 539 | cd $LANMP_PATH/ 540 | 541 | if [ ! -s mhash-*.tar.gz ]; then 542 | LATEST_MHASH_LINK="https://gitcafe.com/wangyan/files/raw/master/mhash-0.9.9.9.tar.gz" 543 | BACKUP_MHASH_LINK="http://wangyan.org/download/lanmp-src/mhash-latest.tar.gz" 544 | Extract ${LATEST_MHASH_LINK} ${BACKUP_MHASH_LINK} 545 | else 546 | tar -zxf mhash-*.tar.gz 547 | cd mhash-*/ 548 | fi 549 | ./configure --prefix=/usr/local 550 | make && make install && ldconfig 551 | 552 | echo "---------- mcrypt ----------" 553 | 554 | cd $LANMP_PATH/ 555 | 556 | if [ ! -s mcrypt-*.tar.gz ]; then 557 | LATEST_MCRYPT_LINK="https://gitcafe.com/wangyan/files/raw/master/mcrypt-2.6.8.tar.gz" 558 | BACKUP_MCRYPT_LINK="http://wangyan.org/download/lanmp-src/mcrypt-latest.tar.gz" 559 | Extract ${LATEST_MCRYPT_LINK} ${BACKUP_MCRYPT_LINK} 560 | else 561 | tar -zxf mcrypt-*.tar.gz 562 | cd mcrypt-*/ 563 | fi 564 | ./configure --prefix=/usr/local 565 | make && make install 566 | 567 | echo "---------- php5 ----------" 568 | 569 | cd $LANMP_PATH/ 570 | 571 | groupadd www 572 | useradd -g www -s /bin/false www 573 | 574 | if [ "$PHP_VER" = "1" ]; then 575 | if [ ! -s php-5.2.17.tar.gz ]; then 576 | wget -c -t3 -T3 https://gitcafe.com/wangyan/files/raw/master/php-5.2.17.tar.gz 577 | if [ $? != "0" ];then 578 | rm -rf php-5.2.17.tar.gz 579 | wget -c -t3 -T60 http://wangyan.org/download/lanmp-src/php-5.2.17.tar.gz 580 | fi 581 | fi 582 | tar -zxf php-5.2.17.tar.gz 583 | 584 | if [ ! -s php-5.2.17-fpm-0.5.14.diff.gz ]; then 585 | wget -c -t3 -T3 https://gitcafe.com/wangyan/files/raw/master/php-5.2.17-fpm-0.5.14.diff.gz 586 | if [ $? != "0" ];then 587 | rm -rf php-5.2.17-fpm-0.5.14.diff.gz 588 | wget -c -t3 -T60 http://wangyan.org/download/lanmp-src/php-5.2.17-fpm-0.5.14.diff.gz 589 | fi 590 | fi 591 | gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1 592 | 593 | if [ ! -s php-5.2.17-max-input-vars.patch ]; then 594 | wget -c -t3 -T3 https://gitcafe.com/wangyan/files/raw/master/php-5.2.17-max-input-vars.patch 595 | if [ $? != "0" ];then 596 | rm -rf php-5.2.17-max-input-vars.patch 597 | wget -c -t3 -T60 http://wangyan.org/download/lanmp-src/php-5.2.17-max-input-vars.patch 598 | fi 599 | fi 600 | patch -d php-5.2.17 -p1 < php-5.2.17-max-input-vars.patch 601 | 602 | if [ ! -s debian_patches_disable_SSLv2_for_openssl_1_0_0.patch ]; then 603 | wget -c -t3 -T3 https://gitcafe.com/wangyan/files/raw/master/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch 604 | if [ $? != "0" ];then 605 | rm -rf debian_patches_disable_SSLv2_for_openssl_1_0_0.patch 606 | wget -c -t3 -T60 http://wangyan.org/download/lanmp-src/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch 607 | fi 608 | fi 609 | patch -d php-5.2.17/ext/openssl/ -p3 < debian_patches_disable_SSLv2_for_openssl_1_0_0.patch 610 | cd php-5.2.17/ 611 | else 612 | if [ ! -s php-5.5.*.tar.gz ]; then 613 | LATEST_PHP_VERSION=`curl -s http://php.net/downloads.php | awk '/Current Stable/{print $3}'` 614 | LATEST_PHP_LINK="http://php.net/distributions/php-${LATEST_PHP_VERSION}.tar.gz" 615 | BACKUP_PHP_LINK="http://wangyan.org/download/lanmp-src/php-latest.tar.gz" 616 | Extract ${LATEST_PHP_LINK} ${BACKUP_PHP_LINK} 617 | else 618 | tar -zxf php-5.5.*.tar.gz 619 | cd php-5.5.*/ 620 | fi 621 | fi 622 | 623 | if [[ "$SOFTWARE" = "1" && "$PHP_VER" = "1" ]]; then 624 | ./buildconf --force 625 | ./configure \ 626 | --prefix=/usr/local/php \ 627 | --with-curl \ 628 | --with-curlwrappers \ 629 | --with-freetype-dir \ 630 | --with-gettext \ 631 | --with-gd \ 632 | --with-iconv-dir \ 633 | --with-jpeg-dir \ 634 | --with-libxml-dir \ 635 | --with-mcrypt \ 636 | --with-mhash \ 637 | --with-mysql=/usr/local/mysql \ 638 | --with-mysqli=/usr/local/mysql/bin/mysql_config \ 639 | --with-mime-magic \ 640 | --with-openssl \ 641 | --with-pear \ 642 | --with-png-dir \ 643 | --with-xmlrpc \ 644 | --with-zlib \ 645 | --enable-bcmath \ 646 | --enable-calendar \ 647 | --enable-discard-path \ 648 | --enable-exif \ 649 | --enable-fastcgi \ 650 | --enable-force-cgi-redirect \ 651 | --enable-fpm \ 652 | --enable-ftp \ 653 | --enable-gd-native-ttf \ 654 | --enable-inline-optimization \ 655 | --enable-magic-quotes \ 656 | --enable-mbregex \ 657 | --enable-mbstring \ 658 | --enable-pcntl \ 659 | --enable-shmop \ 660 | --enable-soap \ 661 | --enable-sockets \ 662 | --enable-sysvsem \ 663 | --enable-sysvshm \ 664 | --enable-xml \ 665 | --enable-zend-multibyte \ 666 | --enable-zip 667 | elif [[ "$SOFTWARE" = "1" && "$PHP_VER" = "2" ]]; then 668 | ./configure \ 669 | --prefix=/usr/local/php \ 670 | --with-curl \ 671 | --with-freetype-dir \ 672 | --with-gettext \ 673 | --with-gd \ 674 | --with-iconv-dir \ 675 | --with-jpeg-dir \ 676 | --with-libxml-dir \ 677 | --with-mcrypt \ 678 | --with-mhash \ 679 | --with-mysql=/usr/local/mysql \ 680 | --with-mysqli=/usr/local/mysql/bin/mysql_config \ 681 | --with-openssl \ 682 | --with-pear \ 683 | --with-png-dir \ 684 | --with-xmlrpc \ 685 | --with-zlib \ 686 | --enable-bcmath \ 687 | --enable-calendar \ 688 | --enable-exif \ 689 | --enable-fpm \ 690 | --enable-ftp \ 691 | --enable-gd-native-ttf \ 692 | --enable-inline-optimization \ 693 | --enable-mbregex \ 694 | --enable-mbstring \ 695 | --enable-pcntl \ 696 | --enable-shmop \ 697 | --enable-soap \ 698 | --enable-sockets \ 699 | --enable-sysvsem \ 700 | --enable-sysvshm \ 701 | --enable-xml \ 702 | --enable-zip 703 | elif [ "$SOFTWARE" != "1" ]; then 704 | ./configure \ 705 | --prefix=/usr/local/php \ 706 | --with-apxs2=/usr/local/apache/bin/apxs \ 707 | --with-curl \ 708 | --with-curlwrappers \ 709 | --with-freetype-dir \ 710 | --with-gettext \ 711 | --with-gd \ 712 | --with-iconv-dir \ 713 | --with-jpeg-dir \ 714 | --with-libxml-dir \ 715 | --with-mcrypt \ 716 | --with-mhash \ 717 | --with-mysql=/usr/local/mysql \ 718 | --with-mysqli=/usr/local/mysql/bin/mysql_config \ 719 | --with-openssl \ 720 | --with-pear \ 721 | --with-png-dir \ 722 | --with-xmlrpc \ 723 | --with-zlib \ 724 | --enable-bcmath \ 725 | --enable-calendar \ 726 | --enable-exif \ 727 | --enable-ftp \ 728 | --enable-gd-native-ttf \ 729 | --enable-inline-optimization \ 730 | --enable-mbregex \ 731 | --enable-mbstring \ 732 | --enable-shmop \ 733 | --enable-soap \ 734 | --enable-sockets \ 735 | --enable-sysvsem \ 736 | --enable-sysvshm \ 737 | --enable-xml \ 738 | --enable-zip 739 | fi 740 | 741 | make ZEND_EXTRA_LIBS='-liconv' 742 | make install 743 | 744 | echo "---------- PDO MYSQL Extension ----------" 745 | 746 | cd ext/pdo_mysql/ 747 | /usr/local/php/bin/phpize 748 | ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql 749 | make && make install 750 | 751 | echo "---------- Memcache Extension ----------" 752 | 753 | cd $LANMP_PATH/ 754 | 755 | if [ ! -s memcache-*.tgz ]; then 756 | LATEST_MEMCACHE_LINK="https://gitcafe.com/wangyan/files/raw/master/memcache-2.2.6.tgz" 757 | BACKUP_MEMCACHE_LINK="http://wangyan.org/download/lanmp-src/memcache-latest.tgz" 758 | Extract ${LATEST_MEMCACHE_LINK} ${BACKUP_MEMCACHE_LINK} 759 | else 760 | tar -zxf memcache-*.tgz 761 | cd memcache-*/ 762 | fi 763 | /usr/local/php/bin/phpize 764 | ./configure --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir --enable-memcache 765 | make && make install 766 | 767 | echo "---------- PHP Config ----------" 768 | 769 | cd $LANMP_PATH/ 770 | 771 | for i in `ls /usr/local/php/bin`; do ln -s /usr/local/php/bin/$i /usr/bin/$i; done 772 | 773 | if [ "$PHP_VER" = "1" ];then 774 | cp php-*/php.ini-recommended /usr/local/php/lib/php.ini 775 | sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\n#g' /usr/local/php/lib/php.ini 776 | else 777 | cp php-*/php.ini-production /usr/local/php/lib/php.ini 778 | sed -i 's#; extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\n#g' /usr/local/php/lib/php.ini 779 | fi 780 | 781 | sed -i 's/short_open_tag = Off/short_open_tag = On/g' /usr/local/php/lib/php.ini 782 | sed -i 's/disable_functions =/disable_functions = system,passthru,exec,shell_exec,popen,symlink,dl/g' /usr/local/php/lib/php.ini 783 | sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /usr/local/php/lib/php.ini 784 | sed -i 's/post_max_size = 8M/post_max_size = 80M/g' /usr/local/php/lib/php.ini 785 | sed -i 's/magic_quotes_gpc = Off/magic_quotes_gpc = On/g' /usr/local/php/lib/php.ini 786 | sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php/lib/php.ini 787 | sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 20M/g' /usr/local/php/lib/php.ini 788 | sed -i 's#;date.timezone =#date.timezone = Asia/Shanghai#g' /usr/local/php/lib/php.ini 789 | sed -i 's#;sendmail_path =#sendmail_path = /usr/sbin/sendmail -t -i#g' /usr/local/php/lib/php.ini 790 | 791 | if [[ "$SOFTWARE" = "1" && "$PHP_VER" = "1" ]]; then 792 | cp conf/init.d.php-fpm /etc/init.d/php-fpm 793 | chmod 755 /etc/init.d/php-fpm 794 | update-rc.d -f php-fpm defaults 795 | cp conf/php-fpm-p2.conf /usr/local/php/etc/php-fpm.conf 796 | /etc/init.d/php-fpm start 797 | elif [[ "$SOFTWARE" = "1" && "$PHP_VER" = "2" ]]; then 798 | cp php-5.5.*/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 799 | chmod 755 /etc/init.d/php-fpm 800 | update-rc.d -f php-fpm defaults 801 | cp conf/php-fpm-p4.conf /usr/local/php/etc/php-fpm.conf 802 | /etc/init.d/php-fpm start 803 | elif [ "$SOFTWARE" != "1" ]; then 804 | /etc/init.d/httpd start 805 | fi 806 | 807 | echo "---------- Xcache Extension ----------" 808 | 809 | cd $LANMP_PATH/ 810 | 811 | if [[ "$INSTALL_XC" = "y" && $PHP_VER = "1" ]];then 812 | 813 | if [ ! -s xcache-*.tar.gz ]; then 814 | LATEST_XCACHE_LINK="https://gitcafe.com/wangyan/files/raw/master/xcache-3.0.3.tar.gz" 815 | BACKUP_XCACHE_LINK="http://wangyan.org/download/lanmp-src/xcache-latest.tar.gz" 816 | Extract ${LATEST_XCACHE_LINK} ${BACKUP_XCACHE_LINK} 817 | else 818 | tar zxf xcache-*.tar.gz 819 | cd xcache-*/ 820 | fi 821 | /usr/local/php/bin/phpize 822 | ./configure --enable-xcache --enable-xcache-optimizer --enable-xcache-coverager 823 | make && make install 824 | 825 | mkdir -p $WEBROOT/ 826 | cp -r admin/ $WEBROOT/xcache 827 | chmod -R 755 $WEBROOT/xcache 828 | 829 | mkdir /tmp/{pcov,phpcore} 830 | chown www:www /tmp/{pcov,phpcore} 831 | chmod 700 /tmp/{pcov,phpcore} 832 | 833 | if [ "$PHP_VER" = "1" ]; then 834 | cat >>/usr/local/php/lib/php.ini<<-EOF 835 | [xcache-common] 836 | zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so 837 | EOF 838 | else 839 | cat >>/usr/local/php/lib/php.ini<<-EOF 840 | [xcache-common] 841 | zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xcache.so 842 | EOF 843 | fi 844 | cat >>/usr/local/php/lib/php.ini<<-EOF 845 | 846 | [xcache.admin] 847 | xcache.admin.user = admin 848 | xcache.admin.pass = e10adc3949ba59abbe56e057f20f883e 849 | xcache.admin.enable_auth = On 850 | xcache.test = Off 851 | xcache.coredump_directory = /tmp/phpcore 852 | xcache.disable_on_crash = "" 853 | 854 | [xcache] 855 | xcache.cacher = On 856 | xcache.size = 64M 857 | xcache.count = 4 858 | xcache.slots = 8K 859 | xcache.ttl = 3600 860 | xcache.gc_interval = 60 861 | xcache.var_size = 1M 862 | xcache.var_count = 4 863 | xcache.var_slots = 8K 864 | xcache.var_ttl = 3600 865 | xcache.var_maxttl = 0 866 | xcache.var_gc_interval = 60 867 | xcache.readonly_protection = Off 868 | xcache.mmap_path = /dev/zero 869 | 870 | [xcache.optimizer] 871 | xcache.optimizer = On 872 | 873 | [xcache.coverager] 874 | xcache.coverager = On 875 | xcache.coveragedump_directory = /tmp/pcov 876 | 877 | EOF 878 | elif [[ "$INSTALL_XC" = "y" && $PHP_VER = "2" ]]; then 879 | cat >>/usr/local/php/lib/php.ini<<-EOF 880 | 881 | [opcache] 882 | zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/opcache.so 883 | opcache.enable_cli=1 884 | opcache.memory_consumption=128 885 | opcache.interned_strings_buffer=8 886 | opcache.max_accelerated_files=4000 887 | opcache.revalidate_freq=1 888 | opcache.fast_shutdown=1 889 | 890 | EOF 891 | fi 892 | 893 | echo "---------- Ioncube Extension ----------" 894 | 895 | cd $LANMP_PATH/ 896 | 897 | if [[ "$INSTALL_IONCUBE" = "y" && $PHP_VER = "1" ]];then 898 | if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then 899 | if [ ! -s ioncube_loaders_lin_x86-64.tar.gz ]; then 900 | LATEST_IONCUBE_LINK="https://gitcafe.com/wangyan/files/raw/master/ioncube_loaders_lin_x86-64.tar.gz" 901 | BACKUP_IONCUBE_LINK="http://wangyan.org/download/lanmp-src/ioncube_loaders_lin_x86-64.tar.gz" 902 | Extract ${LATEST_IONCUBE_LINK} ${BACKUP_IONCUBE_LINK} 903 | else 904 | tar -zxf ioncube_loaders_lin_x86-64.tar.gz 905 | cd ioncube/ 906 | fi 907 | else 908 | if [ ! -s ioncube_loaders_lin_x86.tar.gz ]; then 909 | LATEST_IONCUBE_LINK="https://gitcafe.com/wangyan/files/raw/master/ioncube_loaders_lin_x86.tar.gz" 910 | BACKUP_IONCUBE_LINK="http://wangyan.org/download/lanmp-src/ioncube_loaders_lin_x86.tar.gz" 911 | Extract ${LATEST_IONCUBE_LINK} ${BACKUP_IONCUBE_LINK} 912 | else 913 | tar -zxf ioncube_loaders_lin_x86.tar.gz 914 | cd ioncube/ 915 | fi 916 | fi 917 | 918 | mkdir -p /usr/local/zend/ 919 | if [ "$PHP_VER" = "1" ]; then 920 | cp ioncube_loader_lin_5.2.so /usr/local/zend/ 921 | cat >>/usr/local/php/lib/php.ini<<-EOF 922 | [ioncube loader] 923 | zend_extension = /usr/local/zend/ioncube_loader_lin_5.2.so 924 | EOF 925 | else 926 | cp ioncube_loader_lin_5.4.so /usr/local/zend/ 927 | cat >>/usr/local/php/lib/php.ini<<-EOF 928 | [ioncube loader] 929 | zend_extension = /usr/local/zend/ioncube_loader_lin_5.4.so 930 | EOF 931 | fi 932 | fi 933 | 934 | echo "---------- ZendOptimizer Extension ----------" 935 | 936 | cd $LANMP_PATH/ 937 | 938 | if [ "$INSTALL_ZEND" = "y" ];then 939 | 940 | if [ "$PHP_VER" = "1" ]; then 941 | if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then 942 | if [ ! -s ZendOptimizer-*-linux-glibc23-x86_64.tar.gz ]; then 943 | LATEST_ZEND_LINK="https://gitcafe.com/wangyan/files/raw/master/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz" 944 | BACKUP_ZEND_LINK="http://wangyan.org/download/lanmp-src/ZendOptimizer-latest-linux-glibc23-x86_64.tar.gz" 945 | Extract ${LATEST_ZEND_LINK} ${BACKUP_ZEND_LINK} 946 | else 947 | tar zxf ZendOptimizer-*-linux-glibc23-x86_64.tar.gz 948 | cd ZendOptimizer-*-linux-glibc23-x86_64/ 949 | fi 950 | else 951 | if [ ! -s ZendOptimizer-*-linux-glibc23-i386.tar.gz ]; then 952 | LATEST_ZEND_LINK="https://gitcafe.com/wangyan/files/raw/master/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz" 953 | BACKUP_ZEND_LINK="http://wangyan.org/download/lanmp-src/ZendOptimizer-latest-linux-glibc23-i386.tar.gz" 954 | Extract ${LATEST_ZEND_LINK} ${BACKUP_ZEND_LINK} 955 | else 956 | tar zxf ZendOptimizer-*-linux-glibc23-i386.tar.gz 957 | cd ZendOptimizer-*-linux-glibc23-i386/ 958 | fi 959 | fi 960 | mkdir -p /usr/local/zend/ 961 | cp data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/ 962 | cat >>/usr/local/php/lib/php.ini<<-EOF 963 | 964 | [Zend Optimizer] 965 | zend_extension = /usr/local/zend/ZendOptimizer.so 966 | zend_loader.enable = 1 967 | EOF 968 | else 969 | if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then 970 | if [ ! -s ZendGuardLoader-*-linux-glibc23-x86_64.tar.gz ]; then 971 | LATEST_GUARD_LINK="https://gitcafe.com/wangyan/files/raw/master/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz" 972 | BACKUP_GUARD_LINK="http://wangyan.org/download/lanmp-src/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz" 973 | Extract ${LATEST_GUARD_LINK} ${BACKUP_GUARD_LINK} 974 | else 975 | tar -zxf ZendGuardLoader-*-linux-glibc23-x86_64.tar.gz 976 | cd ZendGuardLoader-*-linux-glibc23-x86_64/ 977 | fi 978 | else 979 | if [ ! -s ZendGuardLoader-*-linux-glibc23-i386.tar.gz ]; then 980 | LATEST_GUARD_LINK="https://gitcafe.com/wangyan/files/raw/master/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz" 981 | BACKUP_GUARD_LINK="http://wangyan.org/download/lanmp-src/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz" 982 | Extract ${LATEST_GUARD_LINK} ${BACKUP_GUARD_LINK} 983 | else 984 | tar -zxf ZendGuardLoader-*-linux-glibc23-i386.tar.gz 985 | cd ZendGuardLoader-*-linux-glibc23-i386/ 986 | fi 987 | fi 988 | mkdir -p /usr/local/zend/ 989 | cp php-5.4.x/ZendGuardLoader.so /usr/local/zend/ 990 | cat >>/usr/local/php/lib/php.ini<<-EOF 991 | 992 | [Zend GuardLoader] 993 | zend_extension = /usr/local/zend/ZendGuardLoader.so 994 | zend_loader.enable = 1 995 | EOF 996 | fi 997 | fi 998 | 999 | if [ "$SOFTWARE" = "1" ]; then 1000 | /etc/init.d/php-fpm restart 1001 | else 1002 | /usr/local/apache/bin/httpd -k restart 1003 | fi 1004 | 1005 | echo "===================== Nginx Install ====================" 1006 | 1007 | if [ "$SOFTWARE" != "2" ]; then 1008 | 1009 | groupadd www 1010 | useradd -g www -s /bin/false www 1011 | 1012 | echo "---------- Pcre ----------" 1013 | 1014 | cd $LANMP_PATH/ 1015 | 1016 | if [ ! -s pcre-*.tar.gz ]; then 1017 | LATEST_PCRE_LINK="https://gitcafe.com/wangyan/files/raw/master/pcre-8.33.tar.gz" 1018 | BACKUP_PCRE_LINK="http://wangyan.org/download/lanmp-src/pcre-latest.tar.gz" 1019 | Extract ${LATEST_PCRE_LINK} ${BACKUP_PCRE_LINK} 1020 | else 1021 | tar -zxf pcre-*.tar.gz 1022 | cd pcre-*/ 1023 | fi 1024 | ./configure 1025 | make && make install && ldconfig 1026 | 1027 | echo "---------- Nginx ----------" 1028 | 1029 | cd $LANMP_PATH/ 1030 | mkdir -p /var/tmp/nginx 1031 | 1032 | if [ ! -s nginx-*.tar.gz ]; then 1033 | LATEST_NGINX_VERSION=`curl -s http://nginx.org/| awk -F- '/nginx-/{print $6}' | head -1|cut -d '<' -f 1` 1034 | LATEST_NGINX_LINK="http://nginx.org/download/nginx-${LATEST_NGINX_VERSION}.tar.gz" 1035 | BACKUP_NGINX_LINK="http://wangyan.org/download/lanmp-src/nginx-latest.tar.gz" 1036 | Extract ${LATEST_NGINX_LINK} ${BACKUP_NGINX_LINK} 1037 | else 1038 | tar -zxf nginx-*.tar.gz 1039 | cd nginx-*/ 1040 | fi 1041 | 1042 | ./configure \ 1043 | --pid-path=/var/run/nginx.pid \ 1044 | --lock-path=/var/lock/nginx.lock \ 1045 | --user=www \ 1046 | --group=www \ 1047 | --with-http_ssl_module \ 1048 | --with-http_dav_module \ 1049 | --with-http_flv_module \ 1050 | --with-http_realip_module \ 1051 | --with-http_gzip_static_module \ 1052 | --with-http_stub_status_module \ 1053 | --with-mail \ 1054 | --with-mail_ssl_module \ 1055 | --with-pcre \ 1056 | --with-debug \ 1057 | --with-ipv6 \ 1058 | --http-client-body-temp-path=/var/tmp/nginx/client \ 1059 | --http-proxy-temp-path=/var/tmp/nginx/proxy \ 1060 | --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \ 1061 | --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ 1062 | --http-scgi-temp-path=/var/tmp/nginx/scgi 1063 | make && make install 1064 | 1065 | echo "---------- Nginx Config----------" 1066 | 1067 | cd $LANMP_PATH/ 1068 | mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak 1069 | cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf 1070 | chmod 644 /usr/local/nginx/conf/nginx.conf 1071 | 1072 | mkdir /usr/local/nginx/conf/ssl 1073 | chmod 711 /usr/local/nginx/conf/ssl 1074 | cp conf/server* /usr/local/nginx/conf/ssl/ 1075 | chmod 644 /usr/local/nginx/conf/ssl/* 1076 | 1077 | mkdir /usr/local/nginx/conf/vhosts 1078 | chmod 711 /usr/local/nginx/conf/vhosts 1079 | mkdir /usr/local/nginx/logs/localhost 1080 | 1081 | if [ "$SOFTWARE" = "1" ]; then 1082 | cp conf/nginx-vhost-original.conf /usr/local/nginx/conf/vhosts/localhost.conf 1083 | else 1084 | cp conf/nginx-vhost-localhost.conf /usr/local/nginx/conf/vhosts/localhost.conf 1085 | cp conf/proxy_cache.inc /usr/local/nginx/conf/proxy_cache.inc 1086 | fi 1087 | chmod 644 /usr/local/nginx/conf/vhosts/localhost.conf 1088 | sed -i 's,www.DOMAIN,,g' /usr/local/nginx/conf/vhosts/localhost.conf 1089 | sed -i 's,DOMAIN/,localhost/,g' /usr/local/nginx/conf/vhosts/localhost.conf 1090 | sed -i 's,DOMAIN,'$IP_ADDRESS',g' /usr/local/nginx/conf/vhosts/localhost.conf 1091 | sed -i 's,ROOTDIR,'$WEBROOT',g' /usr/local/nginx/conf/vhosts/localhost.conf 1092 | 1093 | if [ ! -d $WEBROOT ]; then 1094 | mkdir -p $WEBROOT 1095 | fi 1096 | \cp conf/p.php $WEBROOT 1097 | 1098 | cp conf/init.d.nginx /etc/init.d/nginx 1099 | chmod 755 /etc/init.d/nginx 1100 | update-rc.d -f nginx defaults 1101 | 1102 | ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx 1103 | /etc/init.d/nginx stop 1104 | /etc/init.d/nginx start 1105 | fi 1106 | 1107 | echo "================phpMyAdmin Install===============" 1108 | 1109 | cd $LANMP_PATH/ 1110 | /etc/init.d/mysql restart 1111 | 1112 | if [ ! -s phpMyAdmin-*-all-languages.tar.gz ]; then 1113 | PMA_VERSION=`elinks http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/ | awk -F/ '{print $7F}' | sort -n | grep -iv '-' | tail -1` 1114 | PMA_LINK="http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/" 1115 | LATEST_PMA_LINK="${PMA_LINK}${PMA_VERSION}/phpMyAdmin-${PMA_VERSION}-all-languages.tar.gz" 1116 | BACKUP_PMA_LINK="http://wangyan.org/download/lanmp-src/phpMyAdmin-latest-all-languages.tar.gz" 1117 | Extract ${LATEST_PMA_LINK} ${BACKUP_PMA_LINK} 1118 | mkdir -p $WEBROOT/phpmyadmin 1119 | mv * $WEBROOT/phpmyadmin 1120 | else 1121 | PMA_VERSION=`ls phpMyAdmin-*-all-languages.tar.gz | awk -F- '{print $2}'` 1122 | tar -zxf phpMyAdmin-*-all-languages.tar.gz -C $WEBROOT 1123 | mv $WEBROOT/phpMyAdmin-*-all-languages $WEBROOT/phpmyadmin 1124 | fi 1125 | 1126 | cd $LANMP_PATH/ 1127 | cp conf/config.inc.php $WEBROOT/phpmyadmin/config.inc.php 1128 | sed -i 's/PMAPWD/'$PMAPWD'/g' $WEBROOT/phpmyadmin/config.inc.php 1129 | 1130 | cp conf/control_user.sql /tmp/control_user.sql 1131 | sed -i 's/PMAPWD/'$PMAPWD'/g' /tmp/control_user.sql 1132 | /usr/local/mysql/bin/mysql -u root -p$MYSQL_ROOT_PWD -h localhost < /tmp/control_user.sql 1133 | 1134 | if [ -s $WEBROOT/phpmyadmin/scripts/create_tables.sql ]; then 1135 | cp $WEBROOT/phpmyadmin/scripts/create_tables.sql /tmp/create_tables.sql 1136 | else 1137 | cp $WEBROOT/phpmyadmin/examples/create_tables.sql /tmp/create_tables.sql 1138 | sed -i 's/pma__/pma_/g' $WEBROOT/phpmyadmin/examples/create_tables.sql 1139 | fi 1140 | 1141 | /usr/local/mysql/bin/mysql -u root -p$MYSQL_ROOT_PWD -h localhost < $WEBROOT/phpmyadmin/examples/create_tables.sql 1142 | 1143 | rm -rf /usr/local/mysql/data/test/ 1144 | 1145 | echo -e "phpmyadmin\t${PMA_VERSION}" >> version.txt 2>&1 1146 | 1147 | if [ ! -d "src/" ];then 1148 | mkdir -p src/ 1149 | fi 1150 | \mv ./{*gz,*-*/,*patch,ioncube,package.xml} ./src >/dev/null 2>&1 1151 | 1152 | clear 1153 | echo "" 1154 | echo "===================== Install completed =====================" 1155 | echo "" 1156 | echo "LANMP install completed!" 1157 | echo "For more information please visit http://wangyan.org/blog/lanmp.html" 1158 | echo "" 1159 | echo "Server ip address: $IP_ADDRESS" 1160 | echo "MySQL root password: $MYSQL_ROOT_PWD" 1161 | echo "MySQL pma password: $PMAPWD" 1162 | echo "" 1163 | echo "php config file at: /usr/local/php/lib/php.ini" 1164 | echo "Pear config file at: /usr/local/php/etc/pear.conf" 1165 | [ "$SOFTWARE" = "1" ] && echo "php-fpm config file at: /usr/local/php/etc/php-fpm.conf" 1166 | [ "$SOFTWARE" != "2" ] && echo "nginx config file at: /usr/local/nginx/conf/nginx.conf" 1167 | [ "$SOFTWARE" != "1" ] && echo "httpd config file at: /usr/local/apache/conf/httpd.conf" 1168 | echo "" 1169 | echo "WWW root dir: $WEBROOT" 1170 | echo "PHP prober: http://$IP_ADDRESS/p.php" 1171 | echo "phpMyAdmin: http://$IP_ADDRESS/phpmyadmin/" 1172 | echo "" 1173 | echo "=============================================================" 1174 | echo "" 1175 | --------------------------------------------------------------------------------