Ubuntu Development Notes

Source: Internet
Author: User
Tags php and mysql phpinfo sublime text

Installing the JDK
Unzip files, folder for JDK 1.8.0_20, and sudo gedit/etc/environment
Add the following lines at a later:
Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/lib/jdk1.7.0/bin"
classpath=.:/ Usr/local/lib/jdk1.7.0/lib
java_home=/usr/local/lib/jdk1.7.0



############################################################################################################### ################################
Install MySQL command
sudo apt-get install Mysql-server


Installing the Graphical interface
sudo apt-get install Mysql-admin


Start the service
sudo service MySQL start


Close Service
sudo service MySQL stop


Installing MySQL Workbench
(Enter the directory where the package is located first)
sudo dpkg-i./mysql-workbench-community-6.1.7-1ubu1404-amd64.deb sql


Next, a series of dependency errors are reported, one to install the default package
sudo apt-get install [package_name]


Just add the Tomcat bin path to the environment variable
Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/richard/ Jdk1.8.0_20/bin:/home/richard/apache-tomcat-8.0.12/bin "
Classpath= "/home/richard/jdk1.8.0_20/lib"
Java_home= "/home/richard/jdk1.8.0_20"


Note that if there is an error later, add Java_home= "/home/richard/jdk1.8.0_20" to the first line of the catalin.sh file


The installation of PHP should be noted:
(1) sudo gedit/etc/apache2/sites-enabled/000-default.conf
(2) Modify DocumentRoot to/var/www/(delete the default/html/)


Apache2 configuration should be noted that the server name will change, so add
#Server Name
ServerName 127.0.0.1


Apache2 Default Path changes
cd/etc/apache2/sites-enabled/
sudo gedit 000-default.conf
Modify the DocumentRoot to
#DocumentRoot/var/www/
documentroot/home/richard/workspace/
<Directory/home/richard/workspace/>
Options Indexes followsymlinks MultiViews
AllowOverride All
Order Allow,deny
Allow from all
</Directory>


Attention!!! Need to modify read and write permissions for the workspace directory
sudo chmod 777-r/home/richard/workspace


PHP5 will change default permissions after installation
cd/etc/apache2/
sudo gedit apache2.conf
Modify the following content
<directory/>
Options FollowSymLinks
AllowOverride None
Require all granted<!--This default is deny, which causes 403,permission denied--
</Directory>


Apache2 Server Restart
Sudo/etc/init.d/apache2 restart


Management Tools phpmyadmin404 Workaround
Include/etc/phpmyadmin/apache.conf
(The directory is the same as the file directory above)


Tomcat set boot up
Cd/etc
sudo gedit rc.local


Add the path to the startup.sh
Cd/home/richard/apache-tomcat-8.0.12/bin &&./startup.sh




############################################################################################################### ################################
Configuring the Java Environment


$sudo gvim/etc/environment




Open the Environment configuration file. By the way, this step is not necessarily to use gvim to open, because you do not necessarily installed Gvim, with Gedit, VI and so on open also. If you are unfamiliar with vim, use Gedit
When you open it, you see:


Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"




A line of text, you may have some discrepancy with me. Modify it to:


Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/lib/jdk1.7.0/bin"
classpath=.:/ Usr/local/lib/jdk1.7.0/lib
java_home=/usr/local/lib/jdk1.7.0




The jvm/jdk1.7.0 and so on, please follow the download of your own installation package and installation directory check changes. Then reload. BASHRC


SOURCE ~/.BASHRC


5, to here after running Javac, Java, and other commands can not be used, and Windows installed after the configuration will be different. Next, execute the following command:


$sudo update-alternatives--install/usr/bin/java Java/home/richard/softwares/jdk1.8.0_25/bin/java 300
$sudo update-alternatives--install/usr/bin/javac Javac/home/richard/softwares/jdk1.8.0_25/bin/javac 300
$sudo update-alternatives--INSTALL/USR/BIN/JAVAP JAVAP/HOME/RICHARD/SOFTWARES/JDK1.8.0_25/BIN/JAVAP 300
$sudo update-alternatives--install/usr/bin/javadoc Javadoc/home/richard/softwares/jdk1.8.0_25/bin/javadoc 300




6,sudo Gedit/etc/profile


Export java_home=/home/richard/softwares/jdk1.8.0_25
Export path= $PATH: $JAVA _home/bin: $JAVA _home/jre/bin
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar








############################################################################################################### ################################
Lamp+phpmyadmin Installation Tutorials
One. Installation
1. Install lamp
Select Edit in the new Rieter Package Manager--use task grouping to mark packages
In the window that opens, tick LAMP SERVER and then OK.
Click the Green Checkmark App button in the main window
All right. The next step is waiting ... Wait for the newly installed automatic download to complete.
In the middle there will be a prompt to enter the password of the root user of MySQL
You can also install from the command line in terminal mode:
sudo apt-get install apache2 libapache2-mod-php5 php5 php5-gd mysql-server php5-mysql phpMyAdmin
2. Installing phpMyAdmin
Running commands in terminal
sudo apt-get install phpMyAdmin
Two. Configuration
1> Apache configuration file path/etc/apache2/apache2.conf
2> php.ini Path/etc/php5/apache2/php5.ini
3> mysql configuration file path/etc/mysql/my.cnf
4> phpmyadmin configuration file path/etc/phpmyadmin/apache.conf
5> Web site root directory/var/www
1. Configure Apache
Using commands in the terminal
sudo gedit/etc/apache2/apache2.conf
Add the following lines to the last side of the configuration file:
Add File type Support
AddType application/x-httpd-php. php. htm. html
Default character set according to your needs
Adddefaultcharset UTF-8
Server address
ServerName 127.0.0.1
Add first page file three order can change the previous access priority (of course you can also add other such as default.php)
DirectoryIndex index.htm index.html index.php
2. Configure PHP5
This is nothing to say, according to the individual's own needs
The following is the default time zone
;d efault.timezone= Remove the preceding semicolon and add a PRC. The People's Republic of China (Gmt+8 time zone)
Default.timezone= PRC
3. Configure MySQL
sudo gedit/etc/mysql/my.cnf
Here's a place to watch.
Because the default is to allow only local access to the database if you have to open it.
Bind-address 127.0.0.1 This sentence is limited to local access to MySQL only. If there is a need for other machine access put this phrase in the # comment out
#bind-address 127.0.0.1
4. Configure phpMyAdmin
phpMyAdmin default is not installed under/var/www, but in/usr/share/phpmyadmin
You can copy the phpMyAdmin over there, or someone on the internet says you can create a link and copy the link to the past (not tried)
Then run the command in the terminal
sudo gedit/etc/phpmyadmin/apache.conf
Then change the path of the following two sentences to/var/www/phpmyadmin
Alias/phpmyadmin/usr/share/phpmyadmin
Switch
Alias/phpmyadmin/var/www/phpmyadmin
Characters: Common commands
1. Restart Apache
Sudo/etc/init.d/apache2 restart
2. Restart MySQL
Sudo/etc/init.d/mysql restart
At this point the lamp environment configuration is successful, try Echo phpinfo (); It!
Lamp is not so mysterious! Removing the download time, the entire configuration process will never take you five minutes.
Installation of GD Library
sudo apt-get install PHP5-GD
Remember to restart Apache after loading
Sudo/etc/init.d/apache2 restart
Enable the Mod_rewrite module
sudo a2enmod rewrite






############################################################################################################### ################################
Sublime Text 2 Installation
Ubuntu 12.04 Sublime Text 2 hack


1. Copy the Sublime_text file and rename it to Sublime_text.bak to make a backup


2. Open the Sublime_text.bak file with sublime text 2, search for 3342 and replace with 3242 (replace All), then save


3. Close the sublime Text 2 application and delete the Sublime_text file and modify the backup file Sublime_text.bak to Sublime_text.bak


4. Enter the serial number


Open Sublime_text, click Help->enter lisence key and paste the following in the popup dialog box: (from--begin to license--)


-–begin license-–
USA
Unlimited User License
ea7e-1640
763d05839ca08bda7b0103b5babf0150
195ee53cc33b569858afd553f080a9bc
1f678c88a1342ac92ca596fe775e7014
5a0ee55dc2f8de3c4ed6b5b02fd4db3c
493fce3ee61fc0588cdafaad731bb47f
fd047777d02a5be92202b3d3eb59a696
a69dfef6687d16fcd4443556912a1f62
82da125263c5bc270cee7664b5d0ceb9
-–end license-–




############################################################################################################### ################################
Ubuntu Nginx Installation and configuration
3.Nginx Installation


3.1 Installing Nginx


(1) Online installation


$sudo Apt-get Install Nginx


The Nginx version is 1.2.1


Ubuntu after installing Nginx file structure is roughly:


All configuration files are under/etc/nginx, and each virtual host is already under/etc/nginx/sites-available


Startup program Files in/usr/sbin/nginx


The logs were placed in the/var/log/nginx, Access.log and Error.log, respectively.


and has created a startup script Nginx under/etc/init.d/


The default virtual host directory is set to/usr/share/nginx/www


(2) Source code installation


: http://nginx.org/download/


I am here to download the nginx-1.3.9.tar.gz, the installation process is very simple, as follows:


$./configure


$make


$make Install


After successful installation, Nginx placed in the/usr/local/nginx directory, the main configuration file is the Conf directory nginx.conf,


Nginx startup file in the Sbin directory of Nginx file.


3.2 Start Nginx


(1) Start-up process of online installation


$sudo/etc/init.d/nginx Start


(2) Source code installation start-up process


$CD/usr/local/nginx


$sbin/nginx


Then you can visit, http://localhost/, everything is OK! If you can't access it, don't go ahead and see what the reason is,


Resolve before continuing.


If your machine has Apache installed at the same time, the above access mode can not be used, and nginx may not start, which is


Because they're all using 80 of this port. We will change the Nginx port to 8080,


Here is the main modification of nginx configuration file nginx.conf, this line


Listen 80;


Revision changed to


Listen 8080;


Then you can access it, http://localhost:8080/.


3.3 Installing PHP and MySQL


$sudo apt-get Install php5-cli php5-cgi mysql-server php5-mysql


3.4 Test Nginx support for PHP


(1) Restart Nginx:


$/etc/init.d/nginx restart


(2) Start fastcgi:


$spawn-fcgi-a 127.0.0.1-p 9000-c 10-u www-data-f/usr/bin/php-cgi


spawn-fcgi Start error, check if php-cgi is installed, if yes, install php5-cgi.


$sudo Apt-get Install php5-cgi


(3) test


Open http://localhost/phpinfo.php


4.Nginx Configuration


The Nginx configuration file is/etc/nginx/nginx.conf, which sets up some of the necessary parameters, and we find one of these statements:


include/etc/nginx/sites-enabled/*


You can see that the/etc/nginx/sites-enabled/default file is also a core configuration file that contains the main configuration information,


such as server and directory, server name, location information, and server information.


For the source code installation Nginx, the configuration file is/usr/local/nginx/conf/nginx.conf.


The following main description of location matching rules:


(1) = prefix instruction strictly matches this query. If found, stop the search.


(2) The remainder of the regular string, the longest match is used first. If this match uses the ^~ prefix, the search stops.


(3) Regular expressions, in the order of the configuration file, the first match is used.


(4) If the third step produces a match, the result is used. Otherwise, the matching result of the second step is used.


You can use regular strings and regular expressions in location.


If you use regular expressions, you must use the following rules:


(1) ~* prefix selection case-insensitive matching


(2) ~ Select a case-sensitive match


Example:


Location =/{


# Match/Query only.


[Configuration A]
}


Location/{


# matches any query, because all requests start with/.


# but regular expression rules and long block rules will be matched by precedence and query.


[Configuration B]


}


Location ^~/images/{


# matches any query that starts with/images/and stops the search.


# any regular expression will not be tested.


[Configuration C]


}


Location ~* \. (Gif|jpg|jpeg) $ {


# matches any request that ends with a gif, JPG, or JPEG.


# However, all requests for/images/directories will use Configuration C.


[Configuration D]


}


Here you also have a certain understanding of the regular expression!!!








############################################################################################################### ################################
The common methods of PDO and its application
Pdo::query () is primarily used for operations that have logged results returned, especially the select operation
Pdo::exec () is primarily for operations returned without a result set, such as INSERT, update, and so on
Pdo::lastinsertid () returns the last insert operation, the primary key column type is the final self-increment ID
Pdostatement::fetch () is used to get a record
Pdostatement::fetchall () is to get all recordsets into one


############################################################################################################### ################################
API Key:
Aizasybfh9myqya7vsiismz5j3i1brjkqyqlsp4



Ubuntu Development Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.