Setting up the lamp environment on Ubuntu
The following * Refer to this article from the OSC *
There is a lamp configuration course on the website that speaks well, and also speaks about some of the extended knowledge of Ubuntu and Linux.
Installation
sudo apt-get install apache2
(A new directory will be created after installation/var/www)
sudo apt-get install mysql-server mysql-client
sudo apt-get install php5 libapache2-mod-php5
sudo /etc/init.d/apache2 restart
Restart Apache to load the PHP module
-
Configuration
-
sudo vim/etc/apache2/apache2.conf
Document last added: addtype application/ x-httpd-php. php. html. htm
Then you need to add the default character set: adddefaultcharset UTF-8
Add the access order of the home page file as needed:
<ifmodule dir_module>
directoryindex index.htm index.html index.php
</ifmodule>
then modify the default path for Apache: sudo vim/etc/apache2/sites-enabled/000- default.conf
found in the document documentroot/var/www/html
changed to /var/www
Restart Apache: Service apache2 Restart
-
sudo vim/etc/php5/apache2/php.ini
Modify the default time zone to suit your needs, find ; Date.timezone=
instead of DATE.TIMEZONE=PRC
-
sudo vim/etc/mysql/my.cnf
The default is to allow only local access to the database, if you want to remotely access MySQL, comment out bind-address 127.0.0.1
Test
- Enter localhost in the browser to access the index.html in the/var/www directory
sudo netstat -tap | grep mysql
If you can see tcp 0 0 localhost:mysql *.* LISTEN 1060/mysqld
something like that, it means that it works, and if it doesn't work,
mysql:sudo /etc/init.d/mysql restart
sudo chmod -R 777 /var/www
Create a new file test.php in the/var/www directory and write the following code <?php phpinfo(); ?>
Visit localhost/test.php If you can see a page of PHP parameters that PHP is working properly.
Welcome to the Csdn-markdown Editor