In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to install Apache, MySQL, PHP and LAMP in Ubuntu18.04. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Install Apache
$sudo apt update & & sudo apt install apache2
There will be a pause to ask if you want to continue, type y and enter enter.
two。 Test Apache
Check that Apache is installed correctly by checking the status of the Apache service.
$sudo service apache2 status
After checking the status, you need to press Q to exit, Apache server status.
After checking, know that the Apache service has been up, then the next step should look at some Apache web pages.
Enter the IP address into the browser's address bar and enter to see it.
If you don't know what your IP address is, you can check it with the following command:
$sudo ifconfig | grep-Eo 'inet (addr:)? ([0-9] *\.) {3} [0-9] *' | grep-Eo'([0-9] *\.) {3} [0-9] *'| grep-v '127.0.0.1'
When you see the above page in the browser, it means it's done. The page you see is the file.
/ var/www/html/index.html
If you want to modify the page, just modify it / var/www/html/index.html directly.
3. Install MySQL
$sudo apt update & & sudo apt install mysql-server
Enter y and enter to continue.
After the installation is complete, we check to see if the MySQL service is up.
$sudo service mysql status
If you get up, you will see the activation status as follows:
You may need to press Q to check the service status, or you may not. (I don't need it here)
4. Configure MySQL security
For the security configuration of the MySQL server, you should run mysql_secure_installation
$sudo mysql_secure_installation
If you created the root user's password in step 1, you may be prompted to enter it here. Otherwise, you will be asked to create one.
You will be asked if you want to set the authentication password plug-in.
Unless for some reason a strict password policy needs to be enforced, this is not necessary.
To the picture above, just press enter here, if you don't want to set the authentication password plug-in.
After pressing enter, the following situation will occur:
If you did not create a password for the root user in step 1, you must create one here now.
Note that when you enter a password in Linux, what you are typing is not displayed (no asterisks or dots).
Enter y and press Enter to remove anonymous users.
Enter y and press Enter without running root user remote login. This will prevent robots and hackers from trying to guess root user passwords.
Type y and press Enter to remove the test database.
Enter y and press Enter to reload the privilege table.
Then, it's done.
As a test, you can log in to the MySQL server and run the version command.
$sudo mysqladmin-p-u root version
The first password I have here is to switch to the root password, and the second password is the root password of the MySQL that I just set.
Enter the MySQL root password you set earlier, and you should see the following:
MySQL has now been successfully installed and configured!
5. Install PHP
Let's start by updating the repository and installing the PHP package using apt. We will also install two other packages, libapache2-mod-php and PHP-MySQL, which allow PHP to communicate with the MySQL database.
$sudo apt update & & sudo apt install php libapache2-mod-php php-mysql
When prompted to install the PHP package, press y and enter.
6. Test PHP
Once the package is installed, we can test PHP on the command line.
$php-version
If PHP is installed correctly, you should see something like this:
Great. Now, let's test PHP for Apache.
Create a new file named info.php in the document root directory
The default document root directory in Ubuntu 18.04 is / var/www/html/
Once you have determined the location of the document root, you can create a new file called info.php using vi or vim or gedit or another text editor. (if you are not used to vi, it is recommended to use a visual text editor gedit)
In this case, we will create a new file in / var/www/html/
$sudo vi / var/www/html/info.php
The content written to info.php is as follows:
As shown in the following picture
Then save and exit.
Now we can load this file in the browser by typing:
Http://your_ip/info.php
This is 192.168.1.10, so I typed http://192.168.1.10/info.php in the browser.
If you don't know what your IP is, you can know it through the following command:
$sudo ifconfig | grep-Eo 'inet (addr:)? ([0-9] *\.) {3} [0-9] *' | grep-Eo'([0-9] *\.) {3} [0-9] *'| grep-v '127.0.0.1'
Below we can see that the PHP information page is working properly.
Once you have confirmed that PHP is working properly, it is important to delete info.php because it contains information that may be useful to hackers.
$sudo rm / var/www/html/info.php
If you still want to install phpMyAdmin, please continue to check: install phpMyAdmin on Ubuntu 18.04
Thank you for reading! This is the end of the article on "how to install Apache, MySQL, PHP and LAMP in Ubuntu18.04". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.