For many PHP beginner developers, to build a lamp environment can be used for production is a time-consuming and laborious thing, this article takes ubuntu-server14.04 as an example, gives a tutorial to build the environment for everyone to reference;
1. Update the SOFTWARE source
sudo Apt-get Update
2. Installing Apache
sudo apt-get Install apache2
3. See if Apache is installed successfully
Apache2–v
As shown below, indicates a successful build
4. Access the server's IP through the browser, if an Apache welcome interface appears, the installation succeeds as follows:
5. Installing PHP5
sudo Install PHP5
6. View the version of PHP5
Php5–v
Indicates that the PHP5 has been installed successfully.
7. Check to see if Apache has loaded the Libphp5.so module, a module that Apache uses to command PHP parsers to execute PHP code.
Cat /etc/apache2/mods-enabled/php5.load
Indicates that the module has been loaded
8. Install MySQL, the installation process will let the input database root user password, two times input can continue installation to complete, note that this password is not the system root account password, but the database you installed the default user root password
sudo Install Mysql-server
9. Check if mysql.so extension is loaded, PHP performs curd operation via the extension link MySQL, if prompt no such file or directory means PHP does not have an extension of the operational database installed by default, it needs to install itself
Cat /etc/php5/mods-available/mysql.ini,
10. If the previous step is unsuccessful, perform this step to install the MySQL extension for PHP
sudo Install Php5-mysql
11. See if the extension is installed successfully, the different versions may be stored in different locations
Cat /etc/php5/mods-available/mysql.ini
Indicates that the mysql.so extension has been installed successfully.
12. Restart MySQL and Apache
sudosudo service apache2 restart
13. Create a PHP file to test if the environment is installed successfully.
cd/var/www/info. php
PHP File Contents:
Echo mysql_connect (' localhost ', ' root ', ' 123456 ')? "Success" :"fail"; Echo Phpinfo ();
Note that you must use the LocalHost address as the address of the test database connection, because so far we have not opened the account service for MySQL remote connection.
14. Access the file ip/info.php to see if the connection was successful
Indicates a successful connection, so far our PHP and MySQL as well as Apache have been installed and have been configured to work properly.
15. Install Common Extensions for PHP
sudo Install php5-gd Curl libcurl3 Libcurl3-dev Php5-curl
The installation time of the process is longer, please wait patiently;
16. After the installation is complete, restart Apache
sudo service apache2 restart
17. Back to the browser info.php refresh, to see if the expansion just installed is loaded, search Gd,curl, etc., if the installation was successful, should be able to display in the phpinfo loaded;
18. If you need to upload or manipulate files, you need to use the root account for SSH login, you need to modify the Ubuntu system allows the root user ssh login,
cd/etc/ssh/ sudo vim sshd_config : Set nu 28G
Find Permitrootlogin instead of Yes to save the exit, restart the SSH service, you can use the root account login.
sudo SSH Restart
19. Install the phpMyAdmin (preferably installed, easy to operate and set the remote login account behind)
sudo Install phpMyAdmin
The installation process will prompt for a password, etc., directly input can be installed by default in the/usr/share/phpmyadmin directory, in order to enable us through the Web Access, here need to establish a soft connection to the Apache default directory
sudo LN -S/USR/SHARE/PHPMYADMIN/VAR/WWW/HTML/PMA
Here we have established a PMA soft connection pointing to the actual phpMyAdmin directory.
20. Directly access phpMyAdmin in the browser, enter IP/PMA as follows:
Enter the user name password to log in.
21. Turn on MySQL remote access permission,
sudo Vim/etc/mysql/my.cnf
Find Bind-address, comment out it, save exit, then log in to phpMyAdmin, create a new user in the permissions, as follows:
Finally restart the MySQL service
sudo service mysql restart
This allows MySQL to be connected via remote connection tools such as Navicat, so that a simple lamp environment can be built successfully.
ubuntu-server14.04 Build Lamp environment