(reprinted) Detailed notes on the installation configuration mysql+apache+php+wordpress under Linux

Source: Internet
Author: User
Tags install php phpinfo install wordpress wordpress database

Linux under Installation configuration mysql+apache+php+wordpress the Detailed notes

Linux under the LMAP environment, it took me several days of time. has not been configured before, the installation of online information is confusing, plus I use the version of the problem, the installation process has some errors, after several installation, turned a lot of information, finally find out where the problem, just to set up the environment, for the master, this may not be what, but for a new beginner, but it is not the same, This article records some of my notes and I hope it will be helpful for those who are just getting started, for reference only.

Installation first we have to obtain mysql,apache,php,wordpress source package, the software's official website is as follows:

MySQL: http://www.mysql.com

Apache: http://www.apache.org

PHP: http://www.php.net

WordPress: http://cn.wordpress.org

There are several ways you can download it from your computer and then upload it to Linux.

On the computer may be some friends do not know how to upload to Linux, I use a remote login software Xshell 4, the transmission tool is xftp 4.

Note: Free software Xshell and xftp are Netsarang produced excellent network management, secure transmission tools. Xshell is a free security terminal emulator that can be used as a terminal emulation for SSH, TELNET or RLOGIN, securely connected to a Linux server from the Windows platform, Xftp is a secure transport client, supports both FTP and SFTP protocols, both of which support tabbed Session window. The two are basically complementary to each other.

You can also download from Linux:

Use the wget URL to download the source package to Linux under the decompression installation, as

sudo wget http://cn.wordpress.org/wordpress-3.5.1-zh_CN.tar.gz

sudo tar zxvf wordpress-3.5.1-zh_cn.tar.gz

Because I use the system is Ubuntu, ordinary users need to have root execution permissions need to add "sudo" in front, this is a feature of the Unbuntu, the other system version can not add.

Start the installation below:

Install MySQL

I installed the version is mysql-5.0.95, on the official website can not find their own version of the friend, from this link to find: ftp://mirror.csclub.uwaterloo.ca/mysql/Downloads/MySQL-5.0

Before installing in order to try to avoid errors, we now install a few things needed, gcc,g++, ncurses

The missing gcc,g++ compiler will appear:

Configure:error:no acceptable C compiler found in $PATH
See ' Config.log ' for more details.

Workaround: sudo apt-get install build-essential or

sudo apt-get install gcc

sudo apt-get install gcc-c++

If the system is Suselinux friend can: Zypper install gcc zypper install gcc-c++

Execution of other versions of the system: Yum install gcc yum install gcc-c++

A library file with missing Ncurses,mysql will appear:

Checking for termcap functions Library ... configure:error:No curses/termcap Library found

Workaround: sudo apt-get install Libncurses5-dev


sudo wget ftp://mirror.csclub.uwaterloo.ca/mysql/Downloads/MySQL-5.0/mysql-5.0.95.tar.gz

sudo tar zxvf mysql-5.0.95.tar.gz

CD mysql-5.0.95

sudo./configure--prefix=/usr/local/mysql--with-extra-charsets=all//detection environment, specifying installation directory

Note: Detects what is missing, installs it, and then recompile

(Here--prefix= is the installation directory of MySQL, the--with-extra-charsets option is to specify the language encoding that can be supported by MySQL, which is set to all support, which encoding to use, can be specified in the program.)

There are also some additional parameters that you can add to your personal needs at compile time:














--with-mysqld-ldflags= "-all-static-ltcmalloc"


sudo make//compile

sudo make install//install

Add users, groups of users, and set permissions:

Groupadd MySQL//If there is a can not execute

useradd-g MySQL MySQL//If there is a can not execute

sudo cp support-files/my-medium.cnf/etc/my.cnf

sudo cp support-files/mysql.server/etc/init.d/mysqld

sudo cd/usr/local/mysql

sudo chown-r root. There's a little behind.

sudo chown-r mysql var

sudo chgrp-r MySQL. There's a little behind.

sudo chmod +x/etc/init.d/mysqld

sudo chkconfig--add mysqld

sudo chkconfig--level 3 mysqld on

sudo bin/mysql_install_db--user=mysql

sudo bin/mysqld_safe--user=mysql &

Start MySQL:

    1. sudo service MySQL start
    2. Enter the MySQL installation directory,/usr/local/mysql

sudo./bin/mysql–u root

Note: The first installation of the default password Passwrod is empty, if there is a password, add the password./bin/mysql–u root–p123456

NETSTAT–LT can see each process to see if MySQL starts

#更换 MYSQL Root User password

Sudo/usr/local/mysql/bin/mysqladmin–u root password ' yourpassword '

It is also necessary to note that the MySQL service only allows local connections from the server, if necessary from a remote connection, you also need to set the appropriate permissions in MySQL, and update the permissions table, the following:

Mysql> GRANT All privileges on * * to [e-mail protected] "%" identified by "123456";

mysql> flush Privileges;

(Note the previous "mysql>", which is connected to the MySQL service, in MySQL, not in the operating system)

(Note: The above example of the change of permissions, so that you can use the root user from any remote terminal to connect to the MySQL server, users should be set according to their actual needs)

Installing Apache

The general procedure of installation is similar to MySQL, I use the source package is httpd-2.2.9.tar.gz

After downloading the source package from the official website:

sudo tar zxvf httpd-2.2.9.tar.gz

CD httpd-2.2.9.tar.gz


(Note: Apache compiles easily, the key is to configure httpd.conf)

sudo make

sudo make install


sudo./bin/apachectl start

After the server is started, you can enter it in the browser: HTTP://IP, if you see "It ' works!" Instructions to install successfully!

Apache Default Web root directory for the Apache installation directory under the Htdocs directory, if you want to specify to another directory, you can modify the APAHCE configuration file implementation, the operation is as follows:
sudo vi httpd.conf
Find "DocumentRoot"/usr/local/apache/htdocs "", Modify the "/usr/local/apache/htdocs" section to the directory you want to use, and you will need to find the "<directory"/usr /local/apache/htdocs ">", also Change "/usr/local/apache/htdocs" to the directory you want to use (e.g./var/www), save exit.

It is important to note that to modify the default Web root, both settings need to be modified, and only one of them is invalid.

If, after you configure both, you visit the browser when it appears: Forbidden you do have permission to access/on the this server.

That means you don't have enough authority.

There are many articles on the Internet that introduce


Options FollowSymLinks

AllowOverride None

Order Deny,allow

Deny from all


It is quite irresponsible to say that between all of the deny from all is modified to allow from all, and if you do so, be more sorry for yourself, it is forbidden to Apache to the root directory "/" All of the following content is forbidden to access the settings, but also the most basic site security settings, Only open the corresponding site root directory permissions, if the entire server root directory is open, but someone tried to upload a piece of executable code in the directory should not appear, the consequences would be unthinkable ....

We can set directory permissions so that your directory tree has execute permissions, you can set 755

sudo chmod 755/var/www

If you still cannot access the

Chcon-r-T Httpd_sys_content_t/var/www

After the modification is complete, the APAHCE service needs to be restarted for the new configuration to take effect, as follows:
sudo./apachectl restart

If a port is occupied and cannot be restarted, you can use Ps-ef | grep httpd View PID

Then Kill–l PID

You can also kill all processes within the same group Killall httpd and then start

Install PHP

Install PHP also need to pay attention to a few, install a few need before installing, Libxml2-dev

sudo apt-get install Libxml2-dev

may need to have







Re-installation according to inspection requirements

Download php-5.2.6.tar.gz

sudo tar zxvf php-5.2.6.tar.gz

CD php-5.2.6

sudo./configure--prefix=/usr/local/php--with-xml--with-apxs2=/usr/local/apache/bin/apxs--with-mysql=/usr/local /mysql/--with-mysql-sock=/tmp/mysql.sock

When you are finished, you will see "Thank for using PHP." Indicates that PHP has been configured successfully.

sudo make

sudo make test//Some say makes test can be used without

sudo make install

After installing PHP, you also need to manually modify the Apache configuration, so that Apache support PHP, the operation is as follows:
sudo vi httpd.conf
Find the "AddType Application" section and add the following:
AddType application/x-httpd-php. php. php3 php5

AddType Application/x-httpd-php-source. Phps
(If you need to add support for the default PHP index file name, you will need to find "DirectoryIndex index.html", modified to "DirectoryIndex index.html index.php"), and save exit after the modification is complete.
In addition, do not forget to copy the PHP installation directory php.ini-recommended files to the compile-time specified PHP configuration file directory/usr/local/php/etc, in the PHP source package directory "php-5.2.6" operation as follows:
sudo cp Php.ini-recommended/opt/php/etc/php.ini

Note: php.ini-recommended is available in version 5.2, and if it is 5.3 or later, these files have a new name due to the version update:
Php.ini-production corresponds to php.ini-recommended
Php.ini-development corresponds to Php.ini-dist
After all the configuration is complete, do not forget to restart Apache for the new configuration to take effect.

To confirm that the PHP installation was successful, you can create a index.php file in the root directory of the Web (documentroot path)

sudo vi index.php




Phpinfo ();



Save exit, enter in the browser: http://ip/index.php, if configured correctly, you can see the information about the server just configured, including Apache, MySQL and PHP version, installation path, configuration and so on. If you see just "phpinfo ();" The word, stating that Apache does not support PHP correctly, please check that the above configuration process has been completed correctly

Install WordPress

WordPress download unzip as long as the WordPress files under the copy to the solution DocumentRoot, and then configure some information can (not copy the WordPress directory, is the following all things)

Before configuring, set up a database,


sudo./bin/mysql–u Root p123456

Build a WordPress database

mysql> CREATE DATABASE WordPress;

Build a wordpress user with a password of 123

Mysql> Grant all on wordpress.* to [e-mail protected] '% ' identified by ' 123 ';

Mysql>flush privileges;

sudo wget http://cn.wordpress.org/wordpress-3.5.1-zh_CN.tar.gz

sudo tar zxvf wordpress-3.5.1-zh_cn.tar.gz

CD WordPress

sudo mv wp-config-sample.php wp-config.php

sudo vi wp-config.php

Enter database information:

Define (' db_name ', ' WordPress '); Database name

Define (' Db_user ', ' WordPress '); User name

Define (' Db_password ', ' 123 '); User password

Define (' db_host ', ' localhost '); Address IP, depending on your server IP

Save exit, then test, enter the IP address of the server in the browser to access.

About mysql+apache+php+wordpress Environment configuration has basically been completed, the installation process may be due to the different version and the environment, there are differences between the point of reference data should be no problem.

Related Article

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.