首页 > 数据库 > mysql教程 > Install LAMP Server (Apache, MySQL or MariaDB, PHP) On Ubunt_MySQL

Install LAMP Server (Apache, MySQL or MariaDB, PHP) On Ubunt_MySQL

WBOY
发布: 2016-06-01 13:16:11
原创
1009 人浏览过

MariaDBApacheLAMP

LAMPis a combination of operating system and open-source software stack. The acronym LAMP is derived from first letters of Linux, Apache HTTP Server, MySQL or MariaDB database, and PHP/Perl/Python.

In this tutorial, let us install LAMP server onUbuntu 14.04 Serveredition. My testbox hostname and IP address areserver.unixmen.localand192.168.1.2/24respectively.

Install Apache

Apacheis an open-source multi-platform web server. It provides a full range of web server features including CGI, SSL and virtual domains.

To install Apache, enter the following command from your terminal:

sudo apt-get install apache2
登录后复制

Test Apache:

Open your web browser and navigate tohttp://localhost/orhttp://server-ip-address/.

Apache2 Ubuntu Default Page: It works - Mozilla Firefox_001

Install MySQL

MySQLis a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases, though SQLite probably has more total embedded deployments

sudo apt-get install mysql-server mysql-client
登录后复制

During installation, you’ll be asked to setup the MySQL root user password. Enter the password and click Ok.

sk@server: ~_002

Re-enter the password.

sk@server: ~_003

Now, MySQL server has been installed.

You can verify the MySQL server status using command:

sudo service mysql status
登录后复制
登录后复制

Sample output:

mysql start/running, process 3470
登录后复制

Note:If you want to use MariaDB instead of MySQL, then follow these steps.

Install MariaDB

MariaDBis a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements.

First you have to remove existing MySQL packages if any. To completely uninstall MySQL along with its configuration files, enter the following command:

sudo apt-get purge mysql*
登录后复制

Run the following command to remove unwanted packages.

sudo apt-get autoremove
登录后复制

Now, addMariaDB repository. Run the following commands to add PPA. Hence, MariaDB 5.5 repository is not yet updated to 14.04, we can use the repository of Ubuntu 13.10 instead.

sudo apt-get install software-properties-commonsudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943dbsudo add-apt-repository 'deb http://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/repo/5.5/ubuntu saucy main'
登录后复制

Update the software sources list and install MariaDB using following commands:

sudo apt-get update sudo apt-get install mariadb-server mariadb-client
登录后复制

During installation you will be asked to set mysql‘root’user password.

sk@server: ~_004

Re-enter password:

sk@server: ~_005

Check if mariadb is running or not, using the following command:

sudo service mysql status
登录后复制
登录后复制

Sample output:

 * /usr/bin/mysqladminVer 9.0 Distrib 5.5.37-MariaDB, for debian-linux-gnu on i686Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.Server version5.5.37-MariaDB-1~saucy-logProtocol version10ConnectionLocalhost via UNIX socketUNIX socket/var/run/mysqld/mysqld.sockUptime:2 min 18 secThreads: 1Questions: 566Slow queries: 0Opens: 337Flush tables: 4Open tables: 24Queries per second avg: 4.101
登录后复制

Install PHP

PHP(recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Install PHP with following command:

sudo apt-get install php5 php5-mysql libapache2-mod-php5
登录后复制

Test PHP

Create a sample“testphp.php”file in Apache document root folder.

sudo nano /var/www/html/testphp.php
登录后复制

Add the following lines.

<?phpphpinfo ();?>
登录后复制

Restart apache2 service:

sudo service apache2 restart
登录后复制

Navigate tohttp://server-ip-address/testphp.php. It will display all the details about php such as version, build date and commands etc.

phpinfo() - Mozilla Firefox_006

If you want to install all php modules, enter the commandsudo apt-get install php*and restart the apache2 service. To verify the modules, open web browser and navigate tohttp://server-ip-address/testphp.php. You will able to see all installed php modules.

Manage MySQL Databases (Optional)

Install phpMyAdmin

phpMyAdminis a free open-source web interface tool used to manage your MySQL databases. It is available in the Official Debian repositories. So install it with command:

sudo apt-get install phpmyadmin
登录后复制

Select the Web server you use, in my case it is apache2.

sk@server: ~_007

Select Yes to configure database for phpmyadmin wjth dbconfig-common.

sk@server: ~_008

Enter password of the database’s administrative user.

sk@server: ~_009

Enter MySQL application password phpmyadmin.

sk@server: ~_010

Re-enter the password.

sk@server: ~_011

Success, phpMyAdmin installation has been completed now.

Access phpMyAdmin Web Console

Now you can access the phpmyadmin console by navigating tohttp://server-ip-address/phpmyadmin/from your browser.

Enter your MySQL username and password which you have given in previous steps. In my case its “root” and “ubuntu”.

phpMyAdmin - Mozilla Firefox_012

You will be redirected to PhpMyAdmin main web interface.

192.168.1.2 - localhost | phpMyAdmin 4.0.10deb1 - Mozilla Firefox_013

Now you can manage your MySQL databases from phpMyAdmin web interface.

That’s it. Your LAMP server is up and running now.

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板