Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ installation and configuration of the PHP environment (Apache2) under Linux     - Elasticsearch 2.20 Highlight (Server)

- The next key to install Linux bash script PowerShell (Linux)

- CentOS7 installed MySQL (Database)

- MyCAT separate read and write to achieve MySQL Practice (Database)

- JBPM6 Tutorial - Fast Fun JBPM table (Linux)

- Android media library of analysis: MediaProvider (Programming)

- Linux system package manager (rpm, yum, source packages installation) (Linux)

- Oracle GoldenGate encryption (Database)

- MongoDB collection data migration to MySQL database (Database)

- C language files update in real time (Programming)

- ORA-12537: TNS: connection closed error process (Database)

- Linux learning portal: CentOS 6.4 system kernel upgrade (Linux)

- Redhat Close SELinux correct step (Linux)

- QEMU image file used: qcow2 and raw (Linux)

- Hibernate Search and Lucene quick introduction (Linux)

- Command-line based tools for better alternatives (Linux)

- HAproxy let IP recording back-end RS (Server)

- QBit development of micro-services (Server)

- Linux iptables: combat scenes (Linux)

- How to Start a Linux application running in the background using the terminal mode (Linux)

  installation and configuration of the PHP environment (Apache2) under Linux
  Add Date : 2018-11-21      
  Linux environment in the configuration to install the PHP environment (Apache2), refer to some other people's configuration methods, Internet access problems encountered. Here are the installation steps:

First, install Apache2.2.22
1, to the official website to download http://httpd.apache.org/download.cgi
2, extract
   Tar -zxvf httpd-2.2.22.tar.gz
3, the establishment of the target folder (note that all the following operations are carried out under the root user)
   Mkdir / usr / local / apache2
   That is to wait for the installation of apache2 to install to this folder inside
4, configuration
   Back to the original extract after the folder
   ./configure --prefix = / usr / local / apache2 --enable-module = shared
   To add the parameters behind, or can not use php, -enable-module = shared that Apache can dynamically load the module

This step, there have been many problems:

The first error is:

Checking for APR ... no
Configure: error: APR not found. Please read the documentation.
Download the latest versions of both APR and APR-Util from Apache APR, unpack them into ./srclib/apr and ./srclib/apr-util (be sure the domain names do not have version numbers; for example, the APR distribution must Be under ./srclib/apr/)
Then do

./configure --with-included-apr

Another solution is:
Install APR and APR-util, install the method as follows: First download the two files, and then extract, into the directory after decompression, and then APR and APR-util were installed to the / usr / local / folder apr and apr-util Folder. APR specific installation method 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 at ./confiure --prefix = / usr / local / apr-util --with-apr = / usr / local / apr
The other steps are similar.

The second error is: no acceptable C compiler found in $ Path
Directly run yum install gcc, you can install Gcc
The third question is: pcre-config for libpcre not found
The solution is to download the prce installation package, and APR similar to the installation of / usr / local / pcre folder below. PS: Fedora installed under the C + + compiler g ++ order: yum install gcc-c ++.
5, the compiler
6, the installation
    Make install
7, start, restart and stop, first switch to the installation directory is complete / usr / local / apache2 / bin
    ./apachectl -k start
    ./apachectl -k restart
    ./apachectl -k stop
8, the configuration file (to meet the most basic configuration)
     Edit the /usr/local/apache2/conf/httpd.conf file
     turn up:
    AddType application / x-compress .Z
    AddType application / x-gzip .gz .tgz
    Added at the end:
    AddType application / x-httpd-php .php (so Apcche support PHP)
    AddType application / x-httpd-php-source .php5
    turn up:
    < IfModule dir_module>
    DirectoryIndex index.html
    < / IfModule>
    Add to:
    < IfModule dir_module>
    DirectoryIndex index.html index.php
    < / IfModule>
    turn up:
    #ServerName www.example.com:80
    change into:
    ServerName or ServerName localhost: 80
    Remember to remove the front of the "#"
9, the test
    In the browser, type
    If it appears! It is successful.

10, modify the default Web site directory

    The default directory is "/ usr / local / apache2 / htdocs", modify the apache configuration file httpd.conf, such as a new / home / gyw / WebSite directory as apache site directory

    DocumentRoot found to amend this line: DocumentRoot "/ home / gyw / WebSite"

  Change the line to < Directory> / home / gyw / WebSite ">

Test: Modify to folder error:

"You do not have permission to access /index.html on this server."


Change file permissions; chmod 755 index.html

Open the apache configuration file httpd.conf, find such a paragraph:
< Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny, allow
    Deny from all
    Satisfy all
< / Directory>

 Second, install PHP
1, download
2, extract
    Tar -zxvf php-5.3.16.tar.gz
3, the establishment of the target folder
    Mkdir / usr / local / php
    That is to wait for the next installation of php to install to this folder inside
4, configuration
    Back to the original extract the 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 to compile and install extension modules for the Apache HTTP server, The LoadModule directive provided by mod_so is loaded into the Apache server at runtime. I understand that through this tool to dynamically load the PHP module to Apache

An error occurred: configure: error: xml2-config not found. Please check your libxml2 installation.

Run yum install libxml2, and then run yum install libxml2-devel After the installation is complete, re-run the above. / Configure command.

5, the compiler
6, the test compiler
    Make test
7, the installation
    Make install

8, the configuration file

    Cp /usr/local/src/php-5.3.16/php.ini-development/usr/local/php/lib/php.ini
    Copy the original php.ini-development located in the source code to /usr/local/php/lib/php.ini and rename it to php.ini

9. Restart apache
10, the test
    In the htdocs under x to establish a php file test.php, which reads as follows:
    < ? Php
    Phpinfo ();
    Then type in the browser
    If php related configuration, success, if nothing has entered, the failure of the above steps or re-find the reasons

If you decide to change the configuration options after installation, simply repeat the last three steps configure, make, and make install, and then restart Apache to make the new module effective. Apache does not need to be recompiled.

Third, install MySql
1, download
    To the official website to download mysql-5.1.65.tar.gz (note that the source package)
2, extract
    Tar -zxvf mysql-5.1.65.tar.gz
3, the establishment of the target folder
    Mkdir / usr / local / mysql
    In other words, such as the installation of the mysql to install to the folder inside
4, configuration
    ./configure --prefix = / usr / local / mysql /

Error in ./configure: Error: No curses / termcap library found

Download and install the appropriate package

Grep ncurses

Yum -y install ncurses-devel

Yum install ncurses-devel

5, the compiler
6, the installation
    Make install

7, start
    MySQL service does not automatically start, you also need to initialize the MySQL database, the operation is as follows:
    Cd / usr / local / mysql / bin
    Sudo ./mysql_install_db --user = root
    Note that the last root here is the user can operate the database, the current user can also create a new user, and the root user on Linux are two different things, you can take a name of their own
    . / Mysqld_safe --user = root & This command is responsible for starting the mysql service daemon, in addition to the last & must be, because you want the daemon to run in the background
    Here is just the root of that
8. Create a password for the root user
        ./mysqladmin -u root password '123456'
        If the root password has been set, using the following method
        ./mysqladmin -u root password oldpass '123456'
9, the test
    Mysql -u root -p
    Will be prompted to enter a password, just set up with the password
    If there mysql>, indicating a successful connection, the following order to create a database, build a table, add a record for the back of the test preparation

   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');

  Note that each command is followed by a semicolon, if the above are successful, you can use the back of the test.

 Fourth, the PHP and MySql together

 1, re-configure PHP, change the configuration options, simply repeat the PHP installation of the last three steps configure, make, and make install, and then need to restart Apache to make the new module into effect, Apache does not need to recompile.

 2, configuration

./configure --prefix = / usr / local / php --with-apxs2 = / usr / local / apache2 / bin / apxs --with-mysqli = / usr / local / mysql / bin / mysql_config Note the path to mysql_config
3, compile make

4, install make installe

5, test write a page test.php, on the apache web directory, test the above command to create the database

    < ? Php
  $ Mysqli = new mysqli ();
  $ Mysqli-> connect ( 'localhost', 'root', '123456', 'gywtest');
  // Create the query
  $ Sqlstr = 'select * from student';
  // Send the query to MySql
  $ Result = $ mysqli-> query ($ sqlstr);
    While ($ row = $ result-> fetch_object ())
      $ Name = $ row-> stuname;
      Echo $ name;

Fatal error: Class 'mysqli' not found in /home/lufangtao/Project/DB.php on line 3


/ Usr / local / php / bin / phpize Enter here to run


Can not find config.m4.
Make sure that you run './phpize' in the top level source directory of the module


PHP source package folder under the EXT folder is placed on the current version of the available extensions, CD in to see what you need? Mysqli should see the folder

Execute phpize in the current directory

[Root @ localhost mysqli] # / usr / local / php / bin / phpize

Configuring for:

PHP Api Version: 20090626

Zend Modeule Api No: 20090626

Zend Extension Api No: 220090626

Can not find autoconf. Please check your autoconf installation and the
$ PHP_AUTOCONF environment variable. Then, rerun this script.


Yum install autoconf Run the above command again.

[Root @ localhost mysqli] #. / Configure -prefix = / opt / mysqli -with-php-config = / opt / php / bin / php-config -with-mysqli = / opt / mysql / bin / mysql_config

[Root @ localhost mysqli] # make

[Root @ localhost mysqli] #make install

After the completion of the installation will be prompted to expand the directory path, such as:

/ Opt / php / lib / php / extensions / no-debug-zts-20090626php

The required mysqli.so will be in this directory, then modify the / opt / php / etc / under the php.ini file, add mysqli extension, add the following line:

Extension = / opt / php / lib / php / extensions / no-debug-zts-20090626 / mysqli.so

There will still be an error:

Solve the problem of not connecting MySQL extensively.

Eventually did not solve the MySQLi connection problem, but you can use the MySQL database, the following is the test program

< ? Php

$ Link = mysql_connect ( 'localhost', 'root', '123456');

If (! $ Link) echo "F!";

Else echo "S!";

Mysql_select_db ( "students") or die ( "Could not select database");
$ Query = "SELECT * FROM student;";
$ Result = mysql_query ($ query) or die ( "Query failed");
Print "< table> \ n";

 While ($ line = mysql_fetch_array ($ result, MYSQL_ASSOC)) {
Print "\ t < tr> \ n";
  Foreach ($ line as $ col_value) {
        Print "\ t \ t < td> $ col_value < / td> \ n";
 Print "\ t < / tr> \ n";}
 Print "< / table> \ n";

    /* Release resources */

Mysql_free_result ($ result);
Mysql_close ();

- Let Linux boot methods to enter characters interface and set FrameBuffer resolution methods (Linux)
- Circular list of Java programming (Programming)
- In-depth understanding of capture Node.js garbage collection and memory leaks (Programming)
- Linux performance monitoring (Linux)
- Depth understanding of Python character set encoding (Programming)
- Java and C / C ++ data conversion when network communication (Programming)
- Oracle 11g tracking and monitoring system-level triggers to drop misuse (Database)
- Installation and use of Linux Sniffer tool Tcpdump (Linux)
- Linux Systemd-- To start / stop / restart services in RHEL / CentOS 7 (Linux)
- CentOS terminal display Chinese (Linux)
- Oracle first Automated Installation Packages (Database)
- Shell Scripting Basics (Linux)
- Linux System Getting Started Learning: Using yum to download the RPM package without installing (Linux)
- Ubuntu installation 2.10.x version of Scala (Linux)
- Samba public folder permissions (Server)
- Firewall settings oracle remote connection in Linux systems (Linux)
- KVM add virtual disks (Linux)
- Linux common commands MEMO (Linux)
- Processor in protected mode of protection (Linux)
- Ubuntu 14.04 / Linux Mint 17 How to install the MintMenu 5.5.2 menu (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.