Build a LAMP development environment on Ubuntu 16.04
(These commands can be copied and pasted by right-clicking, if not right, just type it yourself)
After opening Ubuntu, right click and select open-terminal to enter the terminal command line
The following operations are all lost here
basic settings:
sudo passwd
Switch to root user: su or su-or su root
Switch to normal user: su username or logout
2 . Update source
sudo apt-get update
The file saved by the source is: /etc/apt/sources.list
(If there is a situation where you are asked to enter a password, please enter the one you set before, press Enter, the password is not displayed on the screen, and then if E: Invalid operation updata appears, it’s okay, re-enter sudo apt-get updata and press Enter, it’s good if the following pile appears)
Install common software
sudo apt-get install openssh-server
View status: service ssh status/start/stop/restart
Or: /etc/init.d/ssh status/start/stop/retsrt
In fact, the service command is to execute the /etc/init.d script, and the functions of the two are the same
(These tools may be used in the future. It doesn’t matter if you don’t know it now. After inputting the command, the picture above appears, just hit y and press Enter)
sudo apt-get install vim
(Also enter the command and press Enter, just follow the steps, if it has been installed, it will prompt, like the picture above, at this time, English is especially important haha)
sudo apt-get install tree
sudo apt-get install git
Build a LAMP [this is the point]
sudo apt-get install apache2
Test: The browser visits the IP of http://Ubuntu (ie http://localhost), and the It Works! webpage appears.
(Open the Firefox browser and enter the URL in the search bar)
(The picture above is ok)
Check the status: service apache2 status/start/stop/restart
Web directory: /var/www
Installation directory: /etc/apache2/
Global configuration: /etc/apache2/apache2.conf
Listening port: /etc/apache2/ports.conf
Virtual host: /etc/apache2/sites-enabled/000-default.conf
(These may be used in the future, just ignore it)
sudo apt-get install mysql-server mysql-client
1
Press y
Test: mysql -u root -p
(If the installation is successful, you will enter the mysql command line, mysql> looks like this, and press quit to exit; just ok)
View status: service mysql status/start/stop/retart
View the status of the listening port: netstat -tunpl or netstat -tap
sudo apt-get install php7.0
1
(I should have installed it, just follow the steps without installation)
Test: php7.0 -v
sudo apt-get install libapache2-mod-php7.0
sudo apt-get install php7.0-mysql
1
Restart service
service apache2 restart
(You will be asked to enter the password when restarting, just enter the one you set before)
service mysql restart
Test whether Apache can parse PHP
sudo vim /var/www/html/phpinfo.php
This is the case after entering
Press i to enter insert mode
Then write in the file: , Press Esc after typing
Press Shift+ again: Enter one: then enter wq and press Enter
Browser access: http://ubuntu address/phpinfo.php (ie http://localhost/phpinfo.php), the PHP Version webpage appears
(This is ok)
sudo chmod 777 /var/www
sudo apt-get install phpmyadmin
Installation: Select apache2 and click OK. The next choice is to configure the database and enter the password.
(You will be allowed to choose in the middle, just choose apache2, then choose ok, set a password, enter the password again, it's fine, remember to set a password that you will not forget)
Create phpMyAdmin shortcut: sudo ln -s /usr/share/phpmyadmin /var/www/html
Enable Apache mod_rewrite module: sudo a2enmod rewrite
Restart the service:
service php7.0-fpm restart
service apache2 restart
(You will still be asked to enter the password, just enter it)
Test: Browser visit: http://ubuntu address/phpmyadmin (ie http://localhost/phpmyadmin)
(This is ok)
Sudo vim /etc/apache2/apache2.conf
1
After opening the file
Press i first and then slide to the end of the page
Add to:
AddType application/x-httpd-php .php .htm .html
AddDefaultCharset UTF-8
Then press Esc to enter: wq enter and exit (w is to save q is to exit)
Restart Apache service
service apache2 restart
the lamp is built
Recommended Posts