Home > Article > Backend Development > Problems encountered in setting up lamp environment
Today, I migrated the project made by wamp to the lamp environment. Here are the steps and problems encountered.
Online tutorial for setting up the lamp environment. According to this, I did not install it successfully. The following is the online tutorial and the problems I encountered. Solution
The first step is to install Apache2
sudo apt-get install Apache2
The second step is to install the PHP module
sudo apt-get install php5
The third step is to install Mysql
sudo apt-get install mysql- server
sudo apt-get install mysql-client
The fourth step is to install other modules
sudo apt-get install libApache2-mod-php5
sudo apt-get install libApache2-mod-auth-mysql
sudo apt-get install php5-mysql
sudo apt-get install php5-gd
The fifth step is to test whether Apache is working normallyOpen the browser, enter localhost, and see if there is an It Works! web page display. The directory is /var/www
Step 6 Modify permissions /var/www
sudo chomod 777 /var/www
Step 7 Install
phpmyadminsudo apt-get install
phpmyadminSelect
Apache2 during the installation process , click OK. The next choice is to configure the database and enter the password. Step 8 Test
phpmyadminsudo ln -s /usr/share/
phpmyadmin /var/wwwThen run http://localhost/
phpmyadmin directly to see if database management software appears. Configuration process
The first step is to enable the mod_rewrite module
sudo a2enmod rewrite
Restart
ApacheServer: sudo /etc/init.d/Apache2 restart or sudo service Apache2 restartThe second step is to set up
Apache Support .htm .html .phpsudo gedit /etc/
Apache2/Apache2.conf&Add the following sentence: AddType application/x-httpd-php .php .htm .html
The third step is to test the php web page
Edit mysql_test.php code as follows:
$link = mysql_connect("localhost", "root", "password");
if(!$link)
die('Could not connect: ' . mysql_error ());
else
echo "Mysql is configured correctly!";
mysql_close($link);
?>
Visiting http://localhost/mysql_test.php and displaying 'Mysql is configured correctly' means the configuration is correct.
Step 4: The solution after garbled characters appear in the third step
Open the configuration file sudo gedit /etc/
Apache2/Apache2.conf&Add the following code: AddDefaultCharset UTF-8
So far the configuration is OK.
Apache2-mod-php5. Before installing sudo apt-get install Apache2-mpm-itk, please note that if you cannot download it, change the software source
3. Installphp5-cli otherwise entering php in the terminal will prompt that there is no corresponding command
The above introduces the problems encountered in setting up the lamp environment, including Apache, phpmyadmin, and installing Apache. I hope it will be helpful to friends who are interested in PHP tutorials.