Since it is recently necessary to implement a function in the project, it is better to implement it in Http://i.cnblogs.com/EditPosts.aspx?opt=1linux. So recently the code of their own all migrated to Linux, which encountered a lot of problems, come out to share with you, I hope it will help you.
First of all, configure the lamp environment. Lamp environment We all know is Linux,apache (server can also be nginx), MySQL (MongoDB), PHP composed of a user to write PHP code environment. Linux, needless to say, could be a Linux system installed on a computer, or a Linux system built on a window with a virtual machine.
Therefore, the first need to install Apache server, in the Ubuntu System Software Center, has prepared the Apache server, so everyone needs to do is to download Apache to install, install the command: Apt-get installed Apache2, Follow the prompts to complete the installation. After the installation is complete, enter localhost (or 127.0.0.1) in the address bar of the browser, if it appears as shown, prove that the Apache server in lamp has been successfully installed!
The second is the environment where PHP is installed. Install the command: sudo apt-get install PHP5, follow the prompts for installation. After the installation is completed, it is necessary to test, whether the installation is successful, add a new test.php file under Var/www/html, write Phpinfo () in the file, and this code is used to display the current PHP version information. In the browser address bar input: http://localhost/test.php Enter after the execution if appear as shown, it means that PHP5 installation success!
The third is the installation of MySQL, install the command: Apt-get install Mysql-server mysql-client. Follow the prompts to install, and during the installation you will be prompted to set the password for the root user of MySQL, so remember to set the password. Because I was in the installation of MySQL negligence, the direct is the next step, no password, I do not know the phpmyadmin when I set what, resulting in my root user's empty password cannot log on to the MySQL server. In this case, you will need to reset the root user password and find the Debian User (CD/ETC/MYSQL/DEBIAN.CNF) under MySQL by command. Under this file can find the current Debian-sys-maint user's password, and then copy and paste the user, through this user password to log on to the MySQL server, log on through the "select * from User;" To see if there is a root user present in the user table, execute "update user set Passward=passward (" New_pwd ") where user=" root "when the current root user exists; Flush privileges; Exit, and then restart the MySQL service: sudo service mysql restart. After reboot, you can log in to the MySQL server via the root user and the newly set password: Mysql-u root-p new_pwd.
phpMyAdmin installation: After the completion of MySQL installation, the default does not have a graphical interface, we can only operate through the terminal, it is very inconvenient, the data to view the clutter. phpMyAdmin a very good web-based MySQL graphical interface tool. installation command: sudo apt-get install phpMyAdmin. Wait for the installation, in the installation, you should pay attention to select the server selection, I personally installed when the Apache environment, so chose the apache2 server. After the server has been selected to set the password, the password must be set to the password of the MySQL root user. When the installation is complete, accessing phpMyAdmin will find a 404 error, which is due to the fact that our phpMyAdmin is only installed, and we need to map the directory to apache2: sudo ln-s/usr/share/phpmyadmin/var/www/html. After executing the above command, in the browser to access the phpMyAdmin, the login screen will appear, enter our user name and password to log in. After logging in you will find phpMyAdmin still have problems (I unfortunately encountered a seemingly all the problems, alas, sad and hurried ah. )。
The first problem is that using the control user connection defined in the configuration file fails. No way, there are problems on the Internet to find the solution of the big God, found that the original when the user and password errors due to the configuration file. Locate the config.inc.php file (cd/etc/phpmyadmin/config.inc.php) under phpMyAdmin. Then find the $cfg [ ' servers "[$i][ ' ; $cfg [ ' servers "[$i][ '
The second problem is that the PhpMyAdmin advanced feature is not fully set and some features are not activated. To solve this problem, we need to find the SQL file under phpMyAdmin examples, and then import this file, a phpMyAdmin database will appear, and when we view the data of the database Phpmyadmin.pma_table_ Uiprefs doesn ' t exit error we need to find: cd/etc/phpmyadmin/config.inc.php. Find $cfg [' Servers '] [$i] [' table_uiprefs '] = ' pma_table_uiprefs '; Change one of the following in the PMA to two, then go back to the phpMyAdmin and you will find that this error is gone, and we can access the data in the database as usual.
The third problem is the lack of a mcrypt extension. Please check your PHP configuration. When looking for a workaround for this problem, it is found that a Apt-get install php5-mcrypt is required. After the installation of the problem can be resolved, but I do not know what the situation here, I have installed the extension, but the visit will still prompt this error, but, when I run the project does not seem to have any effect, so I did not control, if the great god know why, please tell Ah, must be very grateful!
After solving the above problems, our environment has been set up, now if you want to happily write PHP program, but also need a good editor.
I used to program under the terminal, so I installed a vim, after the installation we can use VIM to open the file, and then write in the file.
The last problem is to move the project code on our window to Linux, because Linux controls the file with permissions, so we have no access to the files that we copy and paste, so we need to modify the code permissions, we can use the command: chmod-r 777 files will modify the entire file permissions, you can find the file, right-click, Find Properties-"Permissions, manually modify permissions. Once the permissions have been modified, we will be able to access our project in the browser.
Do the above work, we can happily write PHP code!
Ubuntu Lamp Environment Configuration and Migration of window code to Linux system