Browse Source

support ThinkPHP URL rewrite

lj2007331 9 years ago
parent
commit
e27cbf1835
5 changed files with 10 additions and 5 deletions
  1. 4 0
      config/thinkphp.conf
  2. 1 1
      include/init_CentOS.sh
  3. 1 1
      include/tomcat-7.sh
  4. 1 1
      include/tomcat-8.sh
  5. 3 2
      vhost.sh

+ 4 - 0
config/thinkphp.conf

@@ -0,0 +1,4 @@
+if (!-e $request_filename) {
+    rewrite ^/(.*)$ /index.php/$1;
+    #rewrite ^/subdir/(.*)$ /subdir/index.php/$1;
+}

+ 1 - 1
include/init_CentOS.sh

@@ -46,7 +46,7 @@ fi
 #[ "$sendmail_yn" == 'y' ] && yum -y install sendmail && service sendmail restart
 
 # closed Unnecessary services and remove obsolete rpm package
-for Service in `chkconfig --list | grep 3:on | awk '{print $1}' | grep -vE 'nginx|httpd|tomcat|mysqld|php-fpm|pureftpd|redis-server|memcached|supervisord'`;do chkconfig --level 3 $Service off;done
+for Service in `chkconfig --list | grep 3:on | awk '{print $1}' | grep -vE 'nginx|httpd|tomcat|mysqld|php-fpm|pureftpd|redis-server|memcached|supervisord|aegis'`;do chkconfig --level 3 $Service off;done
 for Service in sshd network crond iptables messagebus irqbalance syslog rsyslog sendmail;do chkconfig --level 3 $Service on;done
 
 # Close SELINUX

+ 1 - 1
include/tomcat-7.sh

@@ -58,7 +58,7 @@ EOF
         /bin/mv $tomcat_install_dir/conf/server.xml{,_bk} 
         cd $oneinstack_dir/src
         /bin/cp ../config/server.xml $tomcat_install_dir/conf
-        sed -i "s@/usr/local/tomcat@$tomcat_install_dir@" $tomcat_install_dir/conf
+        sed -i "s@/usr/local/tomcat@$tomcat_install_dir@g" $tomcat_install_dir/conf/server.xml
         [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
         cat > $tomcat_install_dir/conf/vhost/localhost.xml << EOF
 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">

+ 1 - 1
include/tomcat-8.sh

@@ -58,7 +58,7 @@ EOF
         /bin/mv $tomcat_install_dir/conf/server.xml{,_bk} 
         cd $oneinstack_dir/src
         /bin/cp ../config/server.xml $tomcat_install_dir/conf
-        sed -i "s@/usr/local/tomcat@$tomcat_install_dir@" $tomcat_install_dir/conf
+        sed -i "s@/usr/local/tomcat@$tomcat_install_dir@g" $tomcat_install_dir/conf/server.xml
         [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
         cat > $tomcat_install_dir/conf/vhost/localhost.xml << EOF
 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">

+ 3 - 2
vhost.sh

@@ -243,12 +243,13 @@ if [ "$rewrite_yn" == 'n' ];then
 else
     echo
     echo "Please input the rewrite of programme :"
-    echo "${CMSG}wordpress${CEND},${CMSG}discuz${CEND},${CMSG}opencart${CEND},${CMSG}laravel${CEND},${CMSG}typecho${CEND},${CMSG}ecshop${CEND},${CMSG}drupal${CEND},${CMSG}joomla${CEND} rewrite was exist."
+    echo "${CMSG}wordpress${CEND},${CMSG}discuz${CEND},${CMSG}opencart${CEND},${CMSG}thinkphp${CEND},${CMSG}laravel${CEND},${CMSG}typecho${CEND},${CMSG}ecshop${CEND},${CMSG}drupal${CEND},${CMSG}joomla${CEND} rewrite was exist."
     read -p "(Default rewrite: other):" rewrite
     if [ "$rewrite" == "" ]; then
     	rewrite="other"
     fi
-    echo "You choose rewrite=${CMSG}$rewrite${CEND}" 
+    echo "You choose rewrite=${CMSG}$rewrite${CEND}"
+    [ "$NGX_FLAG" == 'php' -a "$rewrite" == "thinkphp" ] && NGX_CONF=$(echo -e "location ~ \.php {\n    #fastcgi_pass remote_php_ip:9000;\n    fastcgi_pass unix:/dev/shm/php-cgi.sock;\n    fastcgi_index index.php;\n    include fastcgi_params;\n    set \$real_script_name \$fastcgi_script_name;\n        if (\$fastcgi_script_name ~ \"^(.+?\.php)(/.+)\$\") {\n        set \$real_script_name \$1;\n        set \$path_info \$2;\n        }\n    fastcgi_param SCRIPT_FILENAME \$document_root\$real_script_name;\n    fastcgi_param SCRIPT_NAME \$real_script_name;\n    fastcgi_param PATH_INFO \$path_info;\n    }")
     if [ -e "config/$rewrite.conf" ];then
     	/bin/cp config/$rewrite.conf $web_install_dir/conf/$rewrite.conf
     else