Latest Linux + Apache + MySQL + PHP installation notes)

Source: Internet
Author: User
Tags sapi xsl xslt

Server-lamp installation note

Server OS: cent osapache: http-2.2.11PHP: PHP-5.2.9Mysql: 5.1.32 GD: gd-2.0.35 JPEG: jpeg-6blibpng: libpng-1.2.35libxml2: libxml2-2.6.19freetype: freetype-2.3.9:

Zendoptimizer: ZendOptimizer-3.3.0a-linux-glibc21-i386

Do not install the default Apache, MySQL, PHP, and related software when installing Linux. Use rpm-E * to delete installed packages. 1. Install apache2 (Here I put all the software packages under/root) # Cd/root
Enter the directory/root
# Tar-zvxf httpd-2.2.11.tar.gz
Decompress httpd-2.2.11.tar.gz
# Cd httpd-2.2.11
Go to httpd-2.2.11 directory # Mkdir-P/usr/local/apache2
Generate/usr/local/apache2 directory
#./Configure -- prefix =/usr/local/apache2
Or
#./Configure -- prefix =/usr/local/Apache -- enable-modules = so -- enable-Rewrite Whether the configuration supports Rewriting # Make Compile # Make install
Install Apache
# Vi/usr/local/apache2/CONF/httpd. conf
Set the DocumentRoot path Save and exit. Now it's easy to configure Apache.

#/Usr/local/apache2/bin/apachectl-K start
Start apahce
View in a browser Http://www.wengdo.com (Write your own website here, suchHttp: // localhost/) To obtain it works, indicating that Apache has been configured successfully.
#/Usr/local/apache2/bin/apachectl-K stop
Stop Apache
#/Usr/local/Apache/bin/apachectl restart Restart Apache Add httpd to the startup Item of the system # Cp/usr/local/Apache/bin/apachectl/etc/rc. d/init. d/httpd # Chmod 700/etc/rc. d/init. d/httpd # Vi/etc/rc. d/init. d/httpd Add # Comments to support chkconfig on Redhat Linux # Chkconfig: 2345 90 90 # Description: HTTP Server Note: If you do not have these lines, you will be prompted when using chkconfig: Service httpd does not support chkconfig. Chkconfig-add httpd Chkconfig-level 345 httpd on In this way, httpd can be automatically started on runtime level 345.
Ii. MySQL Installation # Cd/root
# Tar-zvxf mysql-5.1.32-linux-i686-glibc23.tar.gz
# Mkdir-P/usr/local/MySQL (omitted)
# Cp-r mysql-5.1.32-linux-i686-glibc23/*/usr/local/MySQL
# Cp/usr/local/MySQL/support-files/my-medium.cnf/etc/My. CNF

Add mysql users and user groups
# groupadd mysql
# useradd-G mysql
modify MySQL directory permissions
# chown-r root/usr/local/MySQL
# chgrp-r MySQL/usr/local/MySQL
# chown-r MySQL/usr/local/MySQL/Data
Generate a MySQL System database
#/usr/local/MySQL/scripts/mysql_install_db -- user = MySQL &
Start MySQL service
#/usr/local/MySQL/bin/mysqld_safe -- user = MySQL &
If starting mysqld daemon with databases from/usr/local/MySQL/data appears,
the MySQL service is started normally, press Ctrl + C to change the MySQL Root Password

#/usr/local/MySQL/bin/mysqladmin-u root-P password "wengdo"
wengdo can change your password here copy a script in your compiled directory

# Cp/usr/local/MySQL/support-files/MySQL. Server/etc/rc. d/init. d/mysqld

# Chkconfig -- add mysqld

Set ntsysv to enable MySQL to run automatically at each startup..

Now that MySQL is installed, you can start your MySQL service.

#/Etc/rc. d/init. d/mysqld start

The following steps are critical,

# Ln-S/usr/local/MySQL/lib/MySQL/usr/lib/MySQL
# Ln-S/usr/local/MySQL/include/MySQL/usr/include/MySQL

You can skip this step. You can customize the myslq library file path when compiling other software, but I still like to link the library file to the default location, so that you are compiling PHP like, when using software such as Vpopmail, you do not need to specify the MySQL library file address.

3. Install the GD library (skip this step if you use the built-in GD library)
    • Install IIS6

Create a directory:
# Mkdir-P/usr/local/limit 6
# Mkdir-P/usr/local/partition 6/bin
# Mkdir-P/usr/local/release 6/lib
# Mkdir-P/usr/local/users 6/include
# Mkdir-P/usr/local/Example 6/man
# Mkdir-P/usr/local/IPv6/Man1
# Mkdir-P/usr/local/users 6/man/Man1

# Cd/root
# Tar-zvxf restart src.v6b.tar.gz
# Cd jpeg-6b
#./Configure -- prefix =/usr/local/defaults 6/-- enable-shared -- enable-static
# Make
# Make install

    • Install libpng
      # Cd/root
      # Tar-zvxf libpng-1.2.35.tar.gz
      # Cd libpng-1.2.35
      # Cp scripts/makefile. STD makefile
      # Make
      # Make install
    • Install FreeType
      # Cd/root
      # Tar-zvxf freetype-2.3.9.tar.gz
      # Cd freetype-2.3.9
      # Mkdir-P/usr/local/FreeType
      #./Configure -- prefix =/usr/local/FreeType
      # Make
      # Make install
    • Install the GD library

# Cd/root
# Tar-zvxf gd-2.0.35.tar.gz
# Mkdir-P/usr/local/GD2
# Cd gd-2.0.35
#. /Configure -- prefix =/usr/local/GD2 -- With-JPEG =/usr/local/defaults 6/-- With-PNG =/usr/local/lib/-- With-zlib = /usr/local/lib/-- With-FreeType =/usr/local/FreeType/-- enable-m4_pattern_allow
# Make
# Make install

4. Install PhP5 PhP5 must support libxml2!
Install libxml2
# Cd/root
# Tar-zxvf libxml2-2.6.19.tar.gz
# Cd libxml2-2.6.19
# Mkdir-P/usr/local/libxml2
#./Configure -- prefix =/usr/local/libxml2
# Make # make install
Install PhP5
# Cd/root
# Tar-zvxf php-5.2.9.tar.gz
# Mkdir-P/usr/local/PHP
# Cd php-5.2.9
#./Configure -- prefix =/usr/local/PHP -- with-apxs2 =/usr/local/apache2/bin/apxs
-- With-mysql =/usr/local/MySQL/
-- With-curl =/usr/local/curl -- enable-FTP
-- With-libxml-Dir =/usr/local/libxml2
-- With-expat-Dir =/usr/lib -- enable-soap
-- With-XSL =/usr/local/libxslt -- enable-XSLT
-- With-Gd =/usr/local/GD2/
-- With-JPEG-Dir =/usr/local/defaults 6/
-- With-zlib-Dir =/usr/local/lib/
-- With-PNG =/usr/local/lib/
-- With-FreeType-Dir =/usr/local/FreeType/
# Make
# Make install
# Cp PHP. ini-Dist/usr/local/PHP/lib/PHP. ini (don't forget)

The./configure
-- Prefix =/usr/local/PHP
-- With-apxs2 =/usr/local/apache2/bin/apxs
-- With-mysql =/usr/local/MySQL/
-- With-libxml-Dir =/usr/local/libxml2
Is a required Option

-- With-Gd =/usr/local/GD2/
-- With-JPEG-Dir =/usr/local/defaults 6/
-- With-PNG =/usr/local/lib
-- With-zlib-Dir =/usr/lib
-- With-FreeType-Dir =/usr/local/FreeType
This is the configuration option for PHP to support the GD library

-- With-curl =/usr/local/curl supports curl Library
-- Enable-FTP support for opening FTP library functions

-- Enable-soap -- With-XSL =/usr/local/libxslt -- enable-XSLT
Let PHP support soap, which is usually used less and can be removed
If the Server comes with the GD library and related libraries, you can use the following method to configure PHP#. /Configure -- prefix =/usr/local/PHP -- With-mysql =/usr/local/MySQL -- With-FreeType-Dir =/usr -- With-PNG-Dir =/usr -- With-Gd -- enable-Gd-native-TTF -- With-gdbm -- With-gettext -- With-iconv -- With-JPEG-Dir =/usr --- PNG -- With-zlib -- With-XML -- enable-calendar -- With-apxs =/usr/local/apache2/bin/apxs

 5. Install zendoptimizer# Cd/root # tar-zxvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz # cd ZendOptimizer-3.3.0a-linux-glibc21-i386 #./install. ShThen the graphic interface appears. Press the prompt "Next ". 6. Configure some information

Configure httpd. conf to make Apache support PHP
# Vi/usr/local/apache2/CONF/httpd. conf
Find addtype application/X-gzip. GZ. tgz and add the following content under it:
Addtype application/X-httpd-PHP. php
Addtype application/X-httpd-PHP-source. PHPs

Restart Apache
#/Usr/local/apache2/bin/apachectl restart
In the directory you set, create the content as <? Phpinfo ();?> PHP file, enter the URL to check whether PHP configuration is correct
 

Possible problems during installation
    • Question 1:
       

Compile the latest GD database 2.0.35 with the default./configure
When making, the following error occurs:

Configure. AC: 64: Error: Possibly undefined macro: am_iconv
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
Make: *** [configure] Error 1

Solution:
The m4_pattern_allow parameter is added for compilation.
#./Configure -- enable-m4_pattern_allow

    • Question 2

This error may occur in the database.
"Can't connect to local MySQL server through socket '/tmp/MySQL. Sock '"
Check whether the socket file exists. You can specify socket =/tmp/MySQL. Sock in/etc/My. CNF.
Use. mysqld_safe -- socket =/tmp/MySQL. Sock & to start the MySQL process,

Sometimes pam_mysql uses/var/lib/MySQL. Sock
Therefore, connect ln-S/tmp/MySQL. Sock/var/lib/MySQL. Sock.
Or modify/etc/My. CNF.

It may be a permission issue. Check the MySQL Error Log and adjust it step by step.

    • Question 3
       

An error occurred while restarting Apache.
The following error is reported when you restart Apache:
Httpd: syntax error on line 53 of/usr/local/apache2/CONF/httpd. conf: cannot load/usr/local/apache2/modules/libphp5.so into server:/usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

Cause: This is caused by a SELinux protection mode in Linux.

Solution:

1. Method for disabling SELinux:
# Vi/etc/SELinux/config
Change SELinux = enforcing to SELinux = disabled and restart the instance.
This method may cause risks to the server.

2. Do not disable SELinux:
# Setenforce 0
# Chcon-C-v-r-u system_u-r object_r-T textrel_shlib_t/usr/local/apache2/modules/libphp5.so
# Service httpd restart
# Setenforce 1

    • Question 4
       

If an error occurs during PHP make or make install, the following error message is returned:
Installing pear environment:/usr/local/lib/PHP/
/Usr/local/php-5.2.5/SAPI/CLI/PHP: Error while loading shared libraries:/usr/local/GD2/lib/libgd. so.2: cannot restore segment prot after reloc: Permission denied
Make [1]: *** [install-pear-installer] Error 127
Make: *** [install-pear] Error 2

Installation Error. Enter tail/var/log/messages to view the error log.
# Tail/var/log/messages

...
Mar 3 06:40:46 localhost setroubleshoot: SELinux is preventing/usr/local/php-5.2.5/SAPI/CLI/PHP from loading/usr/local/GD2/lib/libgd. so.2.0.0 which requires text relocation. for complete SELinux messages. run sealert-l 6e29749f-3908-480d-bcc1-9042f8a9e846

Run sealert-l 6e29749f-3908-480d-bcc1-9042f8a9e846
# Sealert-l 6e29749f-3908-480d-bcc1-9042f8a9e846

...
The following command will allow this access:
Chcon-T textrel_shlib_t/usr/local/GD2/lib/libgd. so.2.0.0
Find the following command chcon-T textrel_shlib_t/usr/local/GD2/lib/libgd. so.2.0.0
# Chcon-T textrel_shlib_t/usr/local/GD2/lib/libgd. so.2.0.0
Run make install or make again

    • Question 5
       

What should I do if I forget the MySQL Root Password?
#/Usr/local/MySQL/support-files/MySQL. server stop
# Mysqld_safe -- skip-grant-tables &
# Mysqladmin-u User Password 'newpassword'
# Mysqladmin flush-Privileges

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.