: This article mainly introduces how to build the PHP 7 environment in Linux. if you are interested in the PHP Tutorial, refer to it. Note: my environment is Ubuntu. if The Linux version is different, the commands for installing some plug-ins will be different.
Because some details are not consistent with my specific environment, this article is based on.
If you have any questions, please refer to the comments below for o (^) o
I. Apache
1. go to the official website to download http://httpd.apache.org/download.cgi
2. decompress
Tar-zxvf httpd-2.2.22.tar.gz
3. create the target folder (note that all of the following operations are performed under the root user)
Mkdir/usr/local/apache2
That is to say, wait for the installed apache2 to be installed in this folder.
4. configuration
Return to the original decompressed folder
./Configure -- prefix =/usr/local/apache2 -- enable-module = shared
Add the following parameters. otherwise, php cannot be used.-enable-module = shared indicates that Apache can dynamically load modules.
Many problems have occurred at this step:
1). checking for APR... no
Configure: error: APR not found. Please read the documentation.
Install APR and APR-util respectively. the installation method is as follows: Download the two files, decompress them, and enter the decompressed directory, then install APR and APR-util in the/usr/local/folder respectively. The specific installation method of APR is as follows:
[Root @ localhost 52 lamp] # tar-zxvf apr-1.4.2.tar.gz // unzip-o apr-1.4.2.zip
[Root @ localhost 52 lamp] # 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
Other steps are similar.
Finally, switch to the httpd directory and 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) there will be many problems in the middle of the previous step.
① Install the c ++ environment, sudo apt-get install build-essential (update the source before installation, in/etc/apt/source. list, and then execute sudo apt-get update)
② If the three things cannot 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 the three items
5. Compile
Make
6. Installation
Make install
7. start, restart, and stop. switch to the directory/usr/local/apache2/bin after installation.
./Apachectl-k start
./Apachectl-k restart
./Apachectl-k stop
8. configuration file (for the most basic configuration)
Edit the/usr/local/apache2/conf/httpd. conf file
Find:
AddType application/x-compress. Z
AddType application/x-gzip. gz. tgz
Add:
AddType application/x-httpd-php. php (enable Apcche to support PHP)
Find:
DirectoryIndex index.html
Add:
DirectoryIndex index.html index. php
Find:
# ServerName www.example.com: 80
To:
ServerName 127.0.0.1: 80 or ServerName localhost: 80
Remember to remove the previous "#"
Note that this place requires a lot of knowledge of Linux file operations, specific commands please refer to the http://www.cnblogs.com/88999660/articles/1581524.html
Appendix: delete the current row dd
9. test
Enter http: // 127.0.0.1 in the browser
If It Works Appears! Description successful
10. modify the default Web Site Directory
The default directory is "/usr/local/apache2/htdocs". modify the apache configuration file httpd. conf. for example, you can create a/home/gyw/WebSite directory as the apache Site Directory.
Find the DocumentRoot line and change it to DocumentRoot "/home/gyw/WebSite"
Find This line is changed:
Test: An error occurred while modifying to a folder:
"You don't have permission to access/index.html on this server ."
Solution:
Open the apache configuration file httpd. conf and find the following section:
Options Indexes FollowSymLinks
AllowOverride None
Here's why Directory is modified like this, take a look at the http://blog.sina.com.cn/s/blog_6151984a0100f1tj.html
Although I did not understand at last =
II. install PHP
1. Download
Http://www.php.net/downloads.php
2. decompress
Tar-zxvf php-7.0.3.tar.gz, the version here varies according to your needs.
3. create the target folder
Mkdir/usr/local/php
That is to say, wait for the php to be installed in this folder.
4. configuration
Return to the decompressed folder.
./Configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache/bin/apxs
Note that there is a-with-apxs2 =/usr/local/apache/bin/apxs option, where apxs is generated when Apache is installed, apxs is a tool for compiling and installing extension modules for the Apache HTTP Server. it can be loaded to the Apache server at runtime using the LoadModule command provided by mod_so. In my understanding, this tool dynamically loads the PHP module into Apache.
Error: 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
III. install MySql
1. Download
Download mysql-5.1.65.tar.gz to the official website (note the Source Code package). select MySql Community Sever and select Source Code below. here I download the latest version mysql5.7 and use cmake to install it.
2. decompress
Tar-zxvf mysql-5.1.65.tar.gz, if it is less than 5.2 can be directly installed./configure, the above needs to be installed with cmake
3. create the target folder
Mkdir/usr/local/mysql
That is to say, wait for the mysql to be installed in this folder.
4. configuration
Use cmake to configure and install 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 ):
Solution: If no boost package exists, add the corresponding option cmake.-DDOWNLOAD_BOOST = 1-DWITH_BOOST =/usr/local/boost during pre-compilation.
2) CMake Error at cmake/readline. cmake: 64 (MESSAGE ):
Curses library not found. Please install appropriate package,
Remove CMakeCache.txt and rerun cmake. On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Solution: ① almost every release of Linux has an installation package of 'ncurses 'and 'ncurses-devel'. then, according to the error message of the second command above, "there is no available software package ncurses, but it is referenced by other software packages." It can be determined that the Ubuntu Software Manager server has been modified. So go to Ubuntu Package archive (http://packages.ubuntu.com/) to search for whether the installation Package exists, and use 'ncurses-devel' as the keyword to search without any results. Many results are returned when you search for 'curses. According to the description of each returned search result, we can find that in Ubuntu, 'ncurses-devel' is named 'libncurses5-Dev.
# Sudo apt-get install libncurses5-dev (installation process does not prompt any errors, installation successful)
Delete cmakecache.txt
Find the location of all cmakecache.txt documents through 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 the files and then re-run cmake.
5. Compile and install
Make & make install
6.
Switch to the/usr/local/mysql/bin directory and execute. /mysqld -- initialize -- datadir =/usr/local/mysql/data/to create the following data directory. several lines of code will appear at this time, remember the temporary password of the last code. I re-installed mysql just because I didn't remember it. I was so drunk.
Then change the password:./mysqladmin-u root-p password
Go to mysql and run mysql-u root-p.
To test, run 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 ');
4. Combine PHP with MySql
Http://www.111cn.net/sys/linux/69046.htm
The above describes how to set up the PHP 7 environment in Linux, including the following content. I hope my friends who are interested in the PHP Tutorial can help me.