Linux hand-built lamp environment

Source: Internet
Author: User
Tags install php

When you see the "Manual Build" in the title, do you think that it's hard to get "auto-build"? Of course...... No, the "manual build" here refers to the step-by-step construction of Apache, MySQL, and PHP environments, relative to the integration package. So are you able to guess that I'm going to sort through an article that builds a lamp environment through an integrated package?

In fact, about the lamp environment, I have not used, a lot of things do not understand why to do so, at the outset, just a whim, want to build a wiki, so just started to study. I'm not doing PHP, not the backend, the amount ... is not exposed too much, just to build the environment and build the environment, write this article, but also just want to record their own toss of the process, maybe later I also started to make PHP, perhaps can come back to see.

Installing Apache under Linux

  First, prepare

1. Install Apr

: http://apr.apache.org/download.cgi

[Email protected] work]# TAR-ZXVF apr-1.5.2.tar.gz
[Email protected] apr-1.5.2]#/configure--prefix=/usr/local/apr //own address
[[email protected] apr-1.5.2]# make
[[email protected] apr-1.5.2]# make install

2, Installation Apr-util

: http://apr.apache.org/download.cgi

[Email protected] work]# TAR-ZXVF apr-util-1.5.4.tar.gz
[Email protected] apr-util-1.5.4]#/configure--prefix=/usr/local/apr-util //own address
[[email protected] apr-util-1.5.4]# make
[[email protected] apr-util-1.5.4]# make install

3, Installation Pcre

: http://pcre.org/

[Email protected] work]# TAR-ZXVF pcre-8.36.tar.gz
[Email protected] pcre-8.36]#/configure--prefix=/usr/local/pcre //own address
[[email protected] pcre-8.36]# make
[[email protected] pcre-8.36]# make install

  Second, installation

: http://httpd.apache.org/

[Email protected] work]# TAR-ZXVF httpd-2.4.16.tar.gz
[Email protected] httpd-2.4.16]#/configure--prefix=/usr/local/apache--with-apr=/usr/local/apr--with-apr-util=/ Usr/local/apr-util--with-pcre=/usr/local/pcre
[[email protected] httpd-2.4.16]# make
[[email protected] httpd-2.4.16]# make install

  Third, the configuration

1. Modify the configuration file

Open conf/httpd.conf, change # ServerName www.example.com:80 to ServerName localhost:80 //ip:80.

  2. Start

    [[email protected]/usr/local/apache]#./bin/apachectl start

Enter HTTP://IP in the browser and see "It works!" as normal.

3. Set Boot start

    [Email protected] ~]# vi/etc/rc.local

Added:/usr/local/apache/bin/apachectl start

  4. Modify Apache's default Site Directory

After the Apache HTTP server is installed, the default site directory is located in the Htdocs folder under its installation directory, and the default home page is the index.html file for that folder.
Modification Method:
(1) to the Apache installation directory to find the Conf folder, the folder will have httpd.conf such a text document, it is the Apache configuration file, is responsible for command Apache operation.
(2) Open this document, look for "documentroot" (with double quotation marks), find out, after the string "DocumentRoot" after the double quotation marks to modify the string to the site directory you want to set.
(3) After completing the 2nd step above, do not close the httpd.conf file, continue to find, find "<directory""(with English double quotation marks), find"<directory"", The first " Directory "string in double quotes after the string is modified to the site directory that you want to set.
(4) Save exit, restart Apache server.

Install MySQL under Linux

  First, prepare

1. Check if the system has MySQL installed

[Email protected] ~]# Rpm-qa | grep MySQL

    This command will check if the MySQL database is already installed on the operating system.

If it is not installed, no content is output, and if it is already installed, the appropriate version information is displayed.

[[email protected] ~]# rpm-e MySQL

    Normal Delete mode

    [[email protected] ~]# rpm-e--nodeps MySQL

    Brute Force Delete mode, if you use the above command to delete, prompting for other dependent files, then use this command can be strongly deleted

  Second, installation

[email protected] ~]# Yum List | grep MySQL
We can use the command to view the downloaded MySQL version information on Yum, and then use the following command to install the database.
[email protected] ~]# yum install-y mysql-server MySQL Mysql-deve
But
CentOS 7 's Yum source does not appear to be properly installed when MySQL mysql-sever file, need to go to official Web download:
[Email protected] ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
[Email protected] ~]# RPM-IVH mysql-community-release-el7-5.noarch.rpm
[email protected] ~]# Yum install Mysql-community-server
After successful installation, restart the MySQL service:
[Email protected] ~]# service mysqld restart
MySQL after installation is no password, you can directly through the
[[email protected] ~]# MySQL
Login, if the Welcome to the MySQL monitor is displayed, the MySQL installation is successful.

  Third, the configuration

After the MySQL installation can only be logged on by the local computer, it can not be connected remotely, if using navicat and other MySQL client connection, will error error 1130:host ***.***.***.*** is not allowed to connect to the My SQL Server. Indicates that the connected user account does not have remote connection permission and can only log on natively (localhost), change the host entry in the user table in the MySQL database,localhostSwitch
     Specific steps:
Log in to MySQL,
mysql > User mysql;
MySQL > Update user set host= '% ' where user = ' root ';
(This time will error error 1062 (23000): Duplicate entry '%-root ' for key ' PRIMARY ', this no tube)
MySQL > select host from user where user = ' root ';
       +-----------------------+
| host |
+-----------------------+
|% |
| 127.0.0.1 |
| localhost.localdomain |
+-----------------------+
3 rows in Set (0.00 sec)
The host already has the% value, so run the command directly:
MySQL > Flush privileges;
Use the Navicat connection again to succeed.
   or you can change the permissions of MySQL with the following more general commands:

1. Set access to individual database permissions
Mysql>grant all privileges in test.* to ' root ' ('% ');
Description: Set the user name to root, the password is empty, access to the database test
2. Set access to all database permissions
Mysql>grant all privileges on * * to ' root ' @ '% ';
Description: Set user name to root, password is empty, access all databases *
3. Setting the specified user name access rights
Mysql>grant all privileges on * * to ' liuhui ' @ '% ';
Description: Set the specified user name to Liuhui and the password to be empty to access all databases *
4. Set Password access rights
Mysql>grant all privileges on * * to ' liuhui ' @ '% ' identified by ' Liuhui ';
Description: Set the specified user name to Liuhui, password to Liuhui, and access to all databases *
5. Set specified accessible host permissions
Mysql>grant all privileges on * * to ' liuhui ' @ ' 10.2.1.11 ';
Description: Set the specified user name Liuhui to access all databases *, only 10.2.1.11 this machine has access to

Install PHP under Linux

  First, prepare

1, installation LIBXML2

1), download libxml2:http://xmlsoft.org/downloads.html
2), Installation:
[Email protected] work]# TAR-ZXVF libxml2-2.7.2.tar.gz
[Email protected] work]# CD libxml2-2.7.2
[Email protected] libxml2-2.7.2]#/configure--PREFIX=/USR/LOCAL/LIBXML2
[[email protected] libxml2-2.7.2]# make
[[email protected] libxml2-2.7.2]# make install
If the installation succeeds, the bin, include, Lib, man, and share five directories will be generated under the/usr/local/libxml2/directory. When you install the configuration of the PHP5 source package later, you specify the location where the LIBXML2 library files are installed by adding the "--with-libxml-dir=/usr/local/libxml2" option in the options for the Configure command.

  Second, installation

1. Download PHP5
http://www.php.net/downloads.php
2. Installation
[Email protected] work]# TAR-ZXVF php-5.6.14.tar.gz
[Email protected] work]# CD php-5.6.14
[Email protected] php-5.6.14]#/configure--prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--WITH-APXS=/USR/LOCAL/APACHE/BIN/APXS \
--with-libxml-dir=/usr/local/libxml2
(If you are installing apache2, use--WITH-APXS2=/USR/LOCAL/APACHE/BIN/APXS)
(If an error occurs: The MySQL client library is not bundled anymore! the PHP compile support MySQL problem, if you do not know where the MySQL library, you can configure this:
--WITH-MYSQL=MYSQLND \
--WITH-MYSQLI=MYSQLND \
--with-pdo-mysql=mysqlnd
)
[[email protected] php-5.6.14]# make
[[email protected] php-5.6.14]# make install
3. Configuration
Reconfigure Apache2 to let him support PHP.
Configurationhttpd.confLet Apache support PHP:
[Email protected] ~]# vi/usr/local/apache/conf/httpd.conf
Found itAddType application/x-gzip. gz. tgzUnder it, add the following:
AddType application/x-httpd-php. PHP (with spaces in front)
AddType Application/x-httpd-php-source. PHPS (front with spaces)
Save exit.
Copy the PHP configuration file:
[Email protected] ~]# Cp/usr/work/php-5.6.14/php.ini.dist/usr/local/php/lib/php.ini
(If nophp.ini.dist, you putphp.ini-development php.ini-productionAny one of the php.ini.dist can be renamed)
4. Testing
Write a PHP test page info.php, put it inApache2/htdocsIn
<?php
Phpinfo ();
?>;
Launch Apache, enter in the browser: http://server address/info.php, if you can display the PHP information correctly, then apche+mysql+php installation success!

Linux hand-built lamp environment

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.