Ubuntu Install PHP

Source: Internet
Author: User
According to Unofficial Ubuntu 6.06 (dapper Drake) Linux Starter Guide steps to

First, installation Apache2
sudo apt-get install apache2
And then
open it in Firefox:
http://localhost/
Prompt for Success

After installation, the next step is to start Apache

If it is for local development only, tighten security and set the following:
xiaozhihu@xiaozhihu:~$ Gksudo "gedit/etc/apache2/ports.conf"
Change ports.conf
Listen 127.0.0.1:80

After you save the file, restart Apache.

Start Apache
$ sudo/usr/sbin/apache2ctl Start
Stop Apache
$ sudo/usr/sbin/apache2ctl Stop
Restart Apache
$ sudo/etc/init.d/apache2 Restart

enter http://localhost in the browser or http://127.0.0.1, if you see the "It works!", that means that Apache successfully installed, Apache default installation, will be under the/var to create a directory called WWW, this is the Web directory, All Web files to be accessible through the browser are placed in this directory.

second, the installation PHP5
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5 (according to my actual test, this step does not seem to do, in the last step has been installed, but I suggest you copy/paste this command)
Sudo/etc/init.d/apache2 Restart test PHP5 whether the installation was successful
sudo gedit/var/www/testphp.php
Write <?php Phpinfo in the Inside ();?>
And then
open it in Firefox:

http://localhost/testphp.php


After reading the testphp.php deleted, there may be a security risk

Let's test a small example to verify the following PHP:
Terminal input: sudo gedit/var/www/hello.php
Add the code to the Open hello.php:


<title>World</title>

<body>
<?php echo "Hello World"?>
</body>

Enter http://127.0.0.1/hello.php in the browser address bar

Third, installation MYSQL
sudo apt-get install Mysql-server

MySQL initially allows only native (127.0.0.1) connections, if you want to use multiple machines or open to the Internet, edit/etc/mysql/my.cnf
sudo gedit/etc/mysql/my.cnf
Found it
Bind-address = 127.0.0.1
Use # to comment out, like this
#bind-address = 127.0.0.1

MySQL default does not set the root password, the root of the machine does not have a password, there is a risk, so
Mysqladmin-u Root Password Your-new-password
Mysqladmin-h root@local-machine-name-u root-p Password Your-new-password (here I can not connect to the MySQL server, the last change in the Mysql-admin)
Sudo/etc/init.d/mysql restart

Four install MySQL Administrator
sudo apt-get install Mysql-admin
After installing the gnome-application-System Tools-mysql Administrator

Here I encountered a problem, that is, after running the MySQL administrator, click on the user administrator, the entire MySQL administrator hangs dead, and finally resolved, method see the back

Five install MySQL for Apache HTTP Server
sudo apt-get install Libapache2-mod-auth-mysql
sudo apt-get install Php5-mysql
sudo apt-get install phpMyAdmin

To make PHP work with MySQL, edit
sudo gedit/etc/php5/apache2/php.ini
Uncomment, extension=mysql.so, like this
...
Extension=mysql.so
...

Save the file, and then
Sudo/etc/init.d/apache2 restart

Test:
Http://localhost/phpmyadmin

If the requested Url/phpmyadmin/was not found on this Server error. To establish a soft connection, Linux differs from Windows by copying the entire phpMyAdmin to the site, after using the command to install it in/etc/phpmyadmin and/usr/share/phpmyadmin/ Two directories, we do not need to copy all the files to your site, only the command line to establish a soft connection, you can access the same way.

sudo ln-s/usr/share/phpmyadmin/var/www/

Here I can modify the user, add users, etc., back to solve the previous mentioned click on the user administrator, the entire MySQL administrator hanging dead, see the following URL:
MySQL Administrator hangs after pressing User administration Icon
Experts to solve the different methods, the Main method:
In the terminal:
Export Debug_dont_spawn_fetches=1
Mysql-admin
This will make it easier to modify the user.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.