Installation and configuration of Apache + PHP + MySql, apachemysql

Source: Internet
Author: User

Installation and configuration of Apache + PHP + MySql, apachemysql

When there are more people using each technology, someone will optimize it and make it a simple, practical, and popular tool, which is very convenient for beginners, however, for those who have been studying or working for a long time, it is not advisable for technicians. Therefore, they still need to learn basic practical methods. Therefore, I configured the Apache server in ubuntu for more in-depth learning.

This is a default installation method. If you want to specify

Step 1: Install apache2

1. sudo apt-get install apache2, and then enter the Administrator's password.

Enter "y" and press enter to complete installation.

2. Default website root directory path

After Apache is installed, the default website root directory "/var/www/html" is displayed. The website root directory contains the "“index.html" file. Enter localhost or 127.0.0.1 in the browser to open the page.

3. Modify the website root directory

A. Enter "sudo vi/etc/apache2/apache2.conf" in the terminal window, and then click "enter, find the "<Directory/var/www/>" location --> change "/var/www/" to the new root Directory.

B. In the terminal window, enter "sudo vi/etc/apache2/sites-available/000-default.conf" --> press enter --> find the location of "DocumentRoot/var/www/html" --> change "/var/www/html" to the new root directory, here I change it to "/var/www /". C. re-enter the root directory of the website in the browser to see the default page d. How can I see the project directory, enter "sudo mv/var/www/html/index.html/var/www/index_back.html" on the terminal and then run it in the browser. Step 2. Install PHP1 and sudo add-apt-repository ppa: ondrej/php. You can see PHP5.5, PHP5.6, and PHP7.0. you can install any of them at will. 2. If sudo apt-get update does not run this command and php is directly installed, an error message "several software packages cannot be downloaded. You can run apt-get update ------" appears, the installation fails. 3. sudo apt-get install php7.0 php7.0-cli php7.0-fpm php7.0-gd php7.0-json php7.0-mysql php7.0-readline step 3. install mysql1 and update the source list. Open the terminal window and enter "sudo apt-get update" --> press enter --> "enter the password of the root user" --> press Enter. If you do not run this command and install mysql directly, an error message "you can run apt-get update ------" appears, causing installation failure. 2. Install mysql. Open the terminal window ", enter "sudo apt-get install mysql-server mysql-client" --> press enter --> enter "y" --> press enter --> in the "package Settings dialog box", enter mysql as "root ""user's password --> press enter --> re-enter the password --> press enter, installation is complete.

3. Check whether mysql is successfully installed.

Open the terminal window and enter "sudo service mysql restart" --> press enter --> If mysql is started successfully and is running, mysql is installed successfully.

Step 4. integrate LAMP

1. Integrate php and mysql: sudo apt-get install php7.0-mysql

2. Integration of php and Apache: sudo apt-get install libapache2-mod-php7.03, restart Apache2: sudo service apache2 restart Note: if the above three steps cannot integrate LAM, you can try three steps. 1. Open "terminal window", enter "sudo apt-get install libapache2-mod-auth-mysql" --> press enter --> Installation successful 2. Open "terminal window ", enter "sudo apt-get install php5-mysql" --> press enter --> Installation successful note: Be sure to remember the password of the root user set when installing mysql, the root user of Ubuntu 14.04 is not the same as the root user in mysql. Step 5. Verify that the default Apache website root directory is located in/var/www/html/. Enter this directory and create info. php <? Phpphpinfo ();?> Enter http: // localhost/info. php in the browser. Appendix: troubleshooting if the http: // localhost/info. php page is blank, Please Try Ctrl + F5 to force refresh the page. If it is still blank, some configuration edits are required between php and apache:/etc/apache2/apache2.conf <FilesMatch \. php $> SetHandler application/x-httpd-php </FilesMatch> restart Apachesudo service apache2 restart to refresh http: // localhost/info. php. Now you can see the content in phpinfo.

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.