My server environment is:
Install Apache2:
sudo apt -get install mysql-server
Other module installation:
After installing the above modules, the basic configuration is actually OK, except for some small details.
********************************************** ***
found in apache2.conf
# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods -enabled/*.conf
Add
after it
****************************************************** *Another method is to link these two files to the mods-enabled directory:
sudo ln -s /etc/apache2/mods-available/php5.load /etc/apache2/mods- enabled/php5.load
sudo ln -s /etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php5.conf
This way is better, no Destroy the configuration structure of apache2 itself.
********************************************** ***
3. Change the default directory of apache2 to the current development directory
The default directory of apache2 is configured in the /etc/apache2/sites-enabled/000-default file.
Find the DocumentRoot item in the file, change /var/www to your development directory and it will be OK.
Of course, there is another way that is not to use the default directory, but just create a link to your directory under var/www.
For example, if your directory is in /home/username/phptest, then you only need to
sudo ln -s /home/username/phptest /var/www/phptest This way you can access your working directory through http://localhost/phptest. [Note] The link file name cannot contain ".", otherwise apache2 will try to parse it as a file and cannot achieve the effect of the link directory. I personally recommend the latter method, so that multiple working directories can be developed in parallel. Restart apache
or
echo "Hello, This is my first PHP webpagen";
phpinfo();
?>
< ;/p>
Save and exit.
Press the ESC key to jump to the command mode, then:
:w Save the file without exiting vi;
:w file Save the modifications to file without exiting vi;
:w! Force save without exiting vi ;
:wq Save the file and exit vi;
:wq! Force save the file and exit vi;
q: Exit vi without saving the file;
:q! Force exit vi without saving the file;
:e! Give up everything Modify, start editing from the last time you saved the file;
Open the browser, enter: localhost/phptest/test.php, you can see the running results of our PHP. Good Luck! :-)
The above introduces how to build a PHP environment in Ubuntu, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.