Build a php+java+mysql project in Linux system
1. Check out the code from a version control system.
From svn:
svn co svn+ssh://user@127.0.0.1/filepath/trunk localpath
note: keep the structure in the version control system.
2. Install php, java, mysql, and php-mysql, php5-curl
For the mysql 5.6 installation. You can check on my other blog Install MYSQL 5.6 in ubuntu 12.04 and set password
If you get error as below:
set the $CLASSPATH for java project, there are three ways to set the value.
solution 1:
~$ export CLASSPATH=$CLASSPATH:/path/to/external/lib:/path/to/external/jar/file/example.jar
This is only available in your currently open terminal.
solution 2:
Add the CLASSPATH value in .profile. Open .profile in the user root folder and add the line below at the end of the file:
export CLASSPATH=$CLASSPATH:/path/to/external/lib:/path/to/external/jar/file/example.jar
solution 3:
Add the same line above in the shell file before running a java script if you use a shell file to call the java script.
solution 4:
It is possible that for some reasons, the above 3 methods do not work (maybe environment setting issues). and then we use solution 4 to add the lib path on the command line, pay attention to the 2 tricky part:
java -cp .:/usr/lib/jvm/java-1.6.0-openjdk-i386/jre/lib/*:/usr/lib/jvm/java-1.6.0-openjdk-common/jre/lib/ext/*:/more/jarlib/*:/more/otherclasses YourCompleedClass
And if you use package in your java class:
~$cd package/parent/
~package/parent/$ java -cp .:/usr/lib/jvm/java-1.6.0-openjdk-i386/jre/lib/*:/usr/lib/jvm/java-1.6.0-openjdk-common/jre/lib/ext/*:/more/jarlib/*:/more/otherclasses packagepath/YourCompleedClass
4. Make your database remote accessible.
When you are in developing process, it is necessary to set your database server can be accessed remotely, then needs to configure the setting in the my.cnf file.
Comment these lines in my.cnf:
From svn:
svn co svn+ssh://user@127.0.0.1/filepath/trunk localpath
note: keep the structure in the version control system.
2. Install php, java, mysql, and php-mysql, php5-curl
For the mysql 5.6 installation. You can check on my other blog Install MYSQL 5.6 in ubuntu 12.04 and set password
If you get error as below:
Fatal error: Call to undefined function mysql_connect()
It is most possible that your php-mysql is not correctly installed. And needs to be installed:shell>sudo apt-get install php5-mysql
If you get error as below:PHP Notice: Use of undefined constant CURLOPT_RETURNTRANSFER
It is because you do not install php5-curl, and you can install it like this:
shell>sudo apt-get install php5-curl3. set the java lib path
set the $CLASSPATH for java project, there are three ways to set the value.
solution 1:
~$ export CLASSPATH=$CLASSPATH:/path/to/external/lib:/path/to/external/jar/file/example.jar
This is only available in your currently open terminal.
solution 2:
Add the CLASSPATH value in .profile. Open .profile in the user root folder and add the line below at the end of the file:
export CLASSPATH=$CLASSPATH:/path/to/external/lib:/path/to/external/jar/file/example.jar
solution 3:
Add the same line above in the shell file before running a java script if you use a shell file to call the java script.
solution 4:
It is possible that for some reasons, the above 3 methods do not work (maybe environment setting issues). and then we use solution 4 to add the lib path on the command line, pay attention to the 2 tricky part:
java -cp .:/usr/lib/jvm/java-1.6.0-openjdk-i386/jre/lib/*:/usr/lib/jvm/java-1.6.0-openjdk-common/jre/lib/ext/*:/more/jarlib/*:/more/otherclasses YourCompleedClass
And if you use package in your java class:
~$cd package/parent/
~package/parent/$ java -cp .:/usr/lib/jvm/java-1.6.0-openjdk-i386/jre/lib/*:/usr/lib/jvm/java-1.6.0-openjdk-common/jre/lib/ext/*:/more/jarlib/*:/more/otherclasses packagepath/YourCompleedClass
4. Make your database remote accessible.
When you are in developing process, it is necessary to set your database server can be accessed remotely, then needs to configure the setting in the my.cnf file.
Comment these lines in my.cnf:
skip-networking
bind-address = 127.0.0.1
Comments
Post a Comment