Configure Apache + PHP + phpMyAdmin + MySQL in Ubuntu10.10 Environment

Source: Internet
Author: User
1, install apache2sudoapt-getinstallapache2 installation is complete, run the following command restart: sudo/etc/init. d/apache2restart in the browser input http: // localhost or http://www.linuxidc.com, if you see "Itworks! ", It means that Apache is successfully installed. By default, Apache creates a www

1. Install apache2
Sudo apt-get install apache2
After the installation is complete, run the following command to restart:
Sudo/etc/init. d/apache2 restart
Enter http: // localhost or http://www.linuxidc.com in your browser, if you see "It works! ", It means that Apache is successfully installed. By default, Apache will create a directory named www under/var, which is the Web directory, all Web files that can be accessed through a browser must be placed in this directory.

2. install php
Sudo apt-get install libapache2-mod-php5 php5
In addition, it is recommended to install the extension php5-gd php5-mysql, the installation method is the same as above.
After installation, restart Apache to load the PHP module:
Sudo/etc/init. d/apache2 restart
Next, we will create a PHP file under the Web directory to test whether PHP can run normally. command:
Sudo gedit/var/www/phpinfo. php (this does not seem to work, but you can go to that directory and create a file phpinfo. php by yourself)
Then enter:
Phpinfo ();
?>
Then, save the file and enter http://www.linuxidc.com/phpinfo.php in the browser. If a page showing the PHP runtime appears, it indicates that PHP is running normally.

3. Install mysql
Sudo apt-get install mysql-sever-5.1 mysql-client-5.1 (Note: mysql-sever installation will report an error, can be installed through the Ubuntu System)
At the end of the installation, it will require you to enter the root password. Note that the root password here is not the Ubuntu root password. It is the root password you want to set for MySQL.

4. Install phpmyadmin-Mysql Database Management
Sudo apt-get install phpmyadmin
Phpmyadmin settings:
During the installation process, You must select Web server: apache2 or lighttpd, select apache2, press the tab key, and click OK. Then, you are required to enter the Mysql database Password of the database's administrative user.
Then, establish a connection between phpmyadmin and apache2. Take my example: the www directory is in the/var/www directory, and the phpmyadmin directory is in the/usr/share/phpmyadmin directory. Therefore, run the following command: connect sudo ln-s/usr/share/phpmyadmin/var/www.
Phpmyadmin test: Open http: // localhost/phpmyadmin in the address bar of the browser.
(Phpmyadmin can be installed as needed)
The basic components of the above ALMP are installed. Next let's take a look at some other settings:
Set the Ubuntu File Read and Write Permissions
After LAMP is installed, the default root directory of the PHP network server is/var/www. Due to the security principle of Linux, only root users are allowed to change the file read and write permissions under the directory. Therefore, you cannot create or delete PHP files in the www folder, you must first modify the read and write permissions of the/var/www directory. You cannot modify the File Permission by right-clicking the attribute in the interface manager. You must run the root terminal command: sudo chmod 777/var/www. Then you can write html or PHP files. If you are not clear about the file permissions indicated by 777, refer to the chmod command.

5. Configure Apache
1. Enable mod_rewrite module
Terminal command: sudo a2enmod rewrite
Restart Apache server: sudo/etc/init. d/apache2 restart
After Apache is restarted, we can test it. Create the file test. php in the/var/www directory and write the code: Save the configuration. Enter http://www.linuxidc.com/test.phpor http://localhost/test.php in the address bar. If the PHP configuration information is displayed in the address bar, it indicates that lamp Apache is working properly (remember to restart the Apache server and try again ).
2. Set apacheto support .htm. html. php
Sudo gedit/etc/apache2/apache2.conf
Add
AddType application/x-httpd-php. php. htm. html.
Configure Mysql Test
The above php and Apache have been tested. Next we will test whether the Mysql database has been correctly enabled.
Create mysql_test.php in the/var/www directory:
$ Link = mysql_connect ("localhost", "root", "020511 ");
If (! $ Link)
{
Die ('could not connect: '. mysql_error ());
}
Else echo "Mysql has been correctly configured ";
Mysql_close ($ link );
?>
Save and exit. Enter http://www.linuxidc.com/mysql_test.php in the address bar. If "Mysql has been correctly configured", it indicates OK. If not, restart the Apache server and try again.
Configure php5
Modify sudo gedit/etc/php5/apache2/php. ini to allow maximum memory usage.
Modify memory_limit = 8 m
Memory_limit = 32 M
Modify the maximum size allowed for upload and search
Upload_max_filesize = 2 MB
Upload_max_filesize = 8 M
Allow the mysql and gd modules to check whether the file finally contains the following code, if not added. (It is added at the end of the configuration file by default. Check it just in case)
Extension = mysql. soextension = gd. so save and close the file.

Related Article

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.