Home > php教程 > php手册 > Installation and configuration of Apache+PHP+MySql

Installation and configuration of Apache+PHP+MySql

WBOY
Release: 2016-08-26 10:13:04
Original
1334 people have browsed it

When more people use each technology, someone will optimize it and make it a simple, practical and popular tool. This is very convenient for beginners, but it is not suitable for long-term study or work. It is not advisable for technical personnel, so it is still necessary to learn basic practical methods. Therefore, I configured the Apache server under ubuntu to learn more in depth.

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 password of the administrator user

Enter "y" and press Enter to complete the installation

2. The path to the default website root directory

The default website root directory "/var/www/html" after Apache is installed. There is an "index.html" file in the website root directory. 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, then click the "Enter" key to find the location of "" -->Change"/ var/www/" is the new root directory.

b. Enter "sudo vi /etc/apache2/sites-available/000-default.conf" in the terminal window--> Enter--> Find the location of "DocumentRoot /var/www/html"-- >Just change "/var/www/html" to the new root directory. Here I change it to "/var/www/".
c. Re-enter the website root directory in the browser, and you will still see the default page just now
d. How to see the project directory? Enter "sudo mv /var/www/html/index.html /var/www/index_back.html" in the terminal, and then run it in the browser again.
Step 2. Install PHP
1. sudo add-apt-repository ppa:ondrej/php
You can see that there are three versions of PHP5.5, PHP5.6, and PHP7.0. You can install any one at will.
2. sudo apt-get update
If you install php directly without running this command, the error message "There are several software packages that cannot be downloaded, you can run apt-get update------" will appear, resulting in failure to install.
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 mysql
1. Update the source list.
 Open the "terminal window", enter "sudo apt-get update"-->Enter-->"Enter the password of the root user"-->Enter, and that's it. If you install mysql directly without running this command, an error message "There are several software packages that cannot be downloaded. You can run apt-get update------" will appear, making the installation impossible.
2. Install mysql.
 Open the "Terminal Window", enter "sudo apt-get install mysql-server mysql-client"-->Enter-->Enter "y"-->Enter-->In "Package Settings" In the dialog box", enter the password of the "root" user in mysql--> Enter--> Enter the password again--> Enter, and the installation is completed.

3. Determine whether mysql is installed successfully

Open the "terminal window" and enter "sudo service mysql restart"-->Enter-->If mysql starts successfully and is in the running state, it means that mysql is installed successfully.

Step 4: Integrate LAMP

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

2. Integrate php and Apache: sudo apt-get install libapache2-mod-php7.0
3. Restart Apache2: sudo service apache2 restart
Note: If the above three steps cannot integrate LAM, you can try the three steps.
1. Open the "terminal window" and enter "sudo apt-get install libapache2-mod-auth-mysql"-->Press Enter-->Installation successful
2. Open the "terminal window" and enter "sudo apt-get install php5-mysql" --> Enter --> Installation successful
Note: Be sure to remember the password of the root user set when installing mysql. The root user in the Ubuntu 14.04 system and the root user in mysql are not the same user.
Step 5. Verify the environment
Apache’s default website root directory is located at /var/www/html/, enter this directory and create info.php
phpinfo();
?>
Enter http://localhost/info.php in your browser.
Attachment: Troubleshooting
If the http://localhost/info.php page is blank, please try Ctrl+F5 to force refresh the page.
If it is still blank, it means that some configuration is needed between php and apache
Edit /etc/apache2/apache2.conf
SetHandler application/x-httpd-php
Restart Apache
sudo service apache2 restart
Refresh http://localhost/info.php. At this point you should be able to see the contents of phpinfo.
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template