Build Lamp for PHP7 environment on Linux

Source: Internet
Author: User
Note: My environment is different from the version of Ubuntu,linux, the command will be different when I install some plugins.
Because there are some details and my specific environment is not, this article is based on http://www.cnblogs.com/lufangtao/archive/2012/12/30/2839679.html rewrite, reproduced please indicate the source, thank you for your cooperation.
Do you have any questions please indicate in the comment section below that O (^▽^) o
First, Apache
1, to the official website download http://httpd.apache.org/download.cgi
2. Decompression
TAR-ZXVF httpd-2.2.22.tar.gz
3. Set up the target folder (note that all of the following actions are performed under the root user)
Mkdir/usr/local/apache2
That is to say, wait for the installation of the apache2 to install in this folder
4. Configuration
Back to the folder created after the original decompression
./configure--prefix=/usr/local/apache2--enable-module=shared
To add a later parameter, you cannot use php,-enable-module=shared to indicate that Apache can dynamically load modules
There are a number of issues that come up in this step:
1). Checking for APR ... no
Configure:error:APR not found. Please read the documentation.
Install Apr and apr-util respectively, install the method is: First download these two files, then unzip, into the extracted directory, and then the APR and Apr-util respectively installed into the/usr/local/folder Apr and Apr-util folder. The specific installation method for APR is:
[Root@localhost 52lamp]# tar-zxvf apr-1.4.2.tar.gz//unzip-o apr-1.4.2.zip
[Root@localhost 52lamp]# CD apr-1.4.2
[Root@localhost apr-1.4.2]#./configure--prefix=/usr/local/apr
[Root@localhost apr-1.4.2]# make
[Root@localhost apr-1.4.2]# make install
Install Apr-util in./confiure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR
The other steps are similar.
Finally, switch to the directory of the HTTPd folder, execute./configure--prefix=/usr/local/apache2--enable-module=shared--WITH-APR=/USR/LOCAL/APR-- With-apr-util=/usr/local/apr-util--with-pcre=/usr/local/pcre
2). In the previous step, there were a lot of problems in the middle.
① Install C + + environment, sudo apt-get install build-essential (need to update the source before installation, under/etc/apt/source.list, and then execute sudo apt-get update)
② if it comes up and installs those three things that can't be found, change the last sentence./configure--prefix=/home/tnuser/apache/--with-apr=/home/tnuser/apr/--with-apr-util =/home/tnuser/apr-util/--with-pcre=/home/tnuser/pcre/Specify the location of three things
5. Compiling
Make
6. Installation
Make install
7, start, restart and stop, first switch to the installation after the completion of the directory/usr/local/apache2/bin
./apachectl-k Start
./apachectl-k Restart
./apachectl-k Stop
8, configuration files (to meet the most basic configuration)
Edit/usr/local/apache2/conf/httpd.conf File
Found it:
AddType application/x-compress. Z
AddType application/x-gzip. gz. tgz
Add in the following:
AddType application/x-httpd-php. PHP (enables Apcche to support PHP)
Found it:

DirectoryIndex index.html

Add to:

DirectoryIndex index.html index.php

Found it:
#servername www.example.com:80
Modified to:
ServerName 127.0.0.1:80 or ServerName localhost:80
Remember to remove the "#" from the front.
Note that this place requires a lot of knowledge of Linux file operation, please refer to http://www.cnblogs.com/88999660/articles/1581524.html for specific commands.
Attachment: Delete Current line DD
9. Testing
Enter http://127.0.0.1 in the browser
If the IT works! instructions succeed
10. Modify the Default Web site Directory
The default directory is "/usr/local/apache2/htdocs", modify the Apache configuration file httpd.conf, for example, create a new/home/gyw/website directory as the Apache site Directory
Find DocumentRoot This line is modified to: DocumentRoot "/home/gyw/website"
Found it This line is modified to:
Test: Error occurred while modifying to folder:
"You don ' t has permission to access/index.html in this server."
Workaround:
Open the Apache configuration file httpd.conf and find this section:

Options Indexes FollowSymLinks
AllowOverride None

Why is directory here so modified to look at http://blog.sina.com.cn/s/blog_6151984a0100f1tj.html
Even though I didn't see it at last.
Second, install PHP

1. Download
http://www.php.net/downloads.php
2. Decompression
TAR-ZXVF php-7.0.3.tar.gz, here the version according to their own needs, can be different.
3. Set up the target folder
mkdir/usr/local/php
That is, wait for the installed PHP to be installed in this folder
4. Configuration
Back to the original unpacked folder
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs
Note There is a-with-apxs2=/usr/local/apache/bin/apxs option, where APXS is generated when Apache is installed, and APXS is a tool for compiling and installing extensions for Apache HTTP servers. Enable it to be loaded into the Apache server at run time with the LoadModule instructions provided by MOD_SO. My understanding is that the PHP module is dynamically loaded into Apache using this tool.
Error occurred: Configure:error:xml2-config not found. Please check your LIBXML2 installation.
sudo apt-get install LIBXML2
sudo apt-get install Libxml2-dev
5.make && make Install
6. Cp/home/xx/downloads/php-7.0.3/php.ini-development/usr/local/php/lib/php.ini
Third, install MySQL
1. Download
To the official website download mysql-5.1.65.tar.gz (note is the source package), select the MySQL Community sever after select Source Code, here I downloaded the latest version mysql5.7, to use CMake to install
2. Decompression
TAR-ZXVF mysql-5.1.65.tar.gz, if it is below 5.2 direct can./configure to install, the above words need to use CMake to install
3. Set up the target folder
Mkdir/usr/local/mysql
In other words, wait for the installation of MySQL to install into this folder
4. Configuration
Use CMake to configure the installation of MySQL, first download cmake,
Apt-get Install CMake
TAR-ZXVF mysql-5.5.14.tar.gz
CD mysql-5.5.14
Cmake-dcmake_install_prefix=/usr/local/mysql
Error:
1) CMake Error at cmake/boost.cmake:81 (MESSAGE):
Workaround: There is no boost package, add the appropriate option at precompilation: CMake. -ddownload_boost=1-dwith_boost=/usr/local/boost
2) CMake Error at cmake/readline.cmake:64 (MESSAGE):
Curses Library not found. Please install the appropriate package,
Remove CMakeCache.txt and rerun CMake. On Debian/ubuntu, package name was Libncurses5-dev, on Redhat and derivates it was ncurses-devel.
Solution: ①linux Almost every distribution will have ' ncurses ' and ' ncurses-devel ' installation package, and then according to the second command above error, "There is no available package ncurses, but it is referenced by other packages." "You can decide that the Ubuntu Software Manager server has been modified. So to Ubuntu package archive (http://packages.ubuntu.com/) search for the presence of the installer, use ' ncurses-devel ' as the keyword search, no results. The search for ' ncurses ' has resulted in a lot of returns. The ' Ncurses-devel ' is named ' Libncurses5-dev ' in Ubuntu based on each of the instructions that return the search results.
# sudo apt-get install Libncurses5-dev (installation process does not prompt for any errors, installation succeeded)
② Delete CMakeCache.txt
Find the location of all the CMakeCache.txt documents by using the Find command
#find/-name CMakeCache.txt
Then delete all:
# Rm-rf/usr/local/src/cmake-2.8.6/tests/complex/cache/cmakecache.txt
# Rm-rf/usr/local/src/cmake-2.8.6/tests/complexoneconfig/cache/cmakecache.txt
# Rm-rf/usr/local/src/cmake-2.8.6/tests/complexrelativepaths/cache/cmakecache.txt
# Rm-rf/usr/local/src/mysql-5.5.18/cmakecache.txt
。。。。。。。
Delete all and then re-cmake on the OK.
5. Compile and install
make&& make Install
6.
Switch to the/usr/local/mysql/bin directory, execute the./mysqld--initialize--datadir=/usr/local/mysql/data/To create a new data directory, and a few lines of code will appear. The last code of the temporary password must remember, I did not remember, I re-installed the MySQL, I was really drunk.
Then change the password:./mysqladmin-u root-p Password
Go to MySQL, execute mysql-u root-p
To test, execute the following code:
mysql> CREATE DATABASE Gywtest;
mysql> use gywtest;
Mysql> CREATE TABLE student (ID int (4) NOT null primary key Auto_increment,stuname char (20));
mysql> INSERT into student (Stuname) VALUES (' Tom ');
Four. Combine PHP with MySQL
Http://www.111cn.net/sys/linux/69046.htm

The above describes the Linux PHP7 environment of the building Lamp, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.