Configure the lamp environment in ubuntu and migrate the window code to the linux System

Source: Internet
Author: User

Configure the lamp environment in ubuntu and migrate the window code to the linux System
Because we need to implement a function in the project recently, the better way is http://i.cnblogs.com/EditPosts.aspx?opt=1linux . So I recently migrated all my code to linux. I encountered many problems and shared them with you. I hope they will help you. First, configure the lamp environment. Everyone knows that the lamp environment is linux, apache (the server can also be nginx), mysql (mongodb), and php. Not to mention linux. you can install a linux system on your computer or use a virtual machine to build a linux system on Windows. Therefore, you must first install the apache server. In the ubuntu System Software Center, you have prepared an apache server for everyone. Therefore, you need to download and install apache, installation command: apt-get install apache2. Complete the installation as prompted. After the installation is complete, enter localhost (or 127.0.0.1) in the address bar of the browser. If it appears, as shown in, it indicates that the apache server in lamp has been installed successfully! The second step is to install the php environment. Installation command: sudo apt-get install php5. install it as prompted. After installation, You need to test whether the installation is successful. Add a new test under var/www/html. php file, which is written to phpinfo (). This code is used to display the current php version information. In the browser address bar, enter: http://localhost/test.php If the installation is successful after you press enter, as shown in, it indicates that php5 is successfully installed! The third step is to install mysql. The installation command is apt-get install mysql-server mysql-client. Install mysql as prompted. During the installation process, you will be prompted to set the password for the root user of mysql. Therefore, remember to set the password. Due to my negligence when installing mysql, I directly press Enter next without setting a password. Later I did not know what was set during phpmyadmin, so I could not log on to the mysql server with a blank password of the root user. In this case, you need to reset the root user password and find the debian user (cd/etc/mysql/debian. cnf) in mysql by using the command ). In this file, you can find the password of the current debian-sys-maint user, copy and paste the user, log on to the mysql server with the password, and log on to the mysql server using the "select * from user; "Check whether the root user exists in the user table. If the current root user exists, Run" update user set passward = passward ("new_pwd") where user = "root"; flush privileges; and then restart the mysql service: sudo service mysql restart. After restart, you can log on to the mysql server through the root user and the new password: mysql-u root-p new_pwd. Phpmyadmin installation: After mysql is installed, there is no graphical operation interface by default. We can only perform operations through the terminal, which is very inconvenient and messy when viewing data. Phpmyadmin is a good web-based mysql graphical interface tool. Installation command: sudo apt-get install phpmyadmin. Wait for the installation. In the installation process, select the server. When I install apache, select the server of apache2. After the server is selected, you need to set the password. When setting the password, you need to set the password to the password of the mysql root User. After the installation is complete, access phpmyadmin and you will find the 404 error. This is because phpmyadmin is only installed. You also need to map the directory to apache2: sudo ln-s/usr/share/phpmyadmin/var/www/html. After executing the preceding command, access phpmyadmin in the browser and the logon interface will appear. Enter our user name and password to log on. After logging on to phpmyadmin, you will find that there are still problems with phpmyadmin. (unfortunately, I have encountered all the problems, alas, and sadly .). The first problem is that the user Connection Control defined in the configuration file fails. No way. If there is any problem, find a solution on the Internet and find that the user and password are incorrect due to the configuration file. Find the config. inc. php file (cd/etc/phpmyadmin/config. inc. php) under phpmyadmin ). Find $ cfg ['servers'] [$ I] ['user'] = 'enter _ username_here '; $ cfg ['servers'] [$ I] ['Password'] = 'enter _ password_here '; replace it with your logon user and password. The second problem is that the phpMyAdmin advanced features are not fully set, and some features are not activated. To solve this problem, we need to find the SQL file examples under phpmyadmin, and then import the file to produce a phpmyadmin database. phpmyadmin appears when you view the database data. 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', and change the underline next to pma to two, go back to phpmyadmin and you will find that this error is gone. We can also access the data in the database normally. The third problem is the lack of mcrypt extensions. Check the PHP configuration. When looking for a solution to this problem, you find that you need to install an apt-get install php5-mcrypt. After the installation is complete, the problem can be solved, but I don't know what the problem is. I have installed this extension, but this error will still be prompted during access. However, I don't seem to have any influence when running the project, so I don't care. If you know why, please let me know. Thank you very much! After solving the above problems, our environment has been set up. If you want to write php programs happily, you need a good editor. I used programming on the terminal, So I installed a vim. After installation, we can use vim to open the file and write it in the file. The last problem is to migrate the project code on our window to linux. Because linux uses permissions to control files, the copied and pasted file has no access permission, so we need to modify the code permission. We can use the command chmod-R 777 files to modify all the permissions of the entire file, you can also find the file, right-click it, find the property-> permission, and manually modify the permission. After the permission is modified, we can access our project in the browser. After completing the above work, we can happily write php code!

Related Article

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.