Linux under the source code compiled installation APACHE2,PHP5,MYSQL5

Source: Internet
Author: User
Tags chmod phpinfo

#apache

  code is as follows copy code
./configure- Prefix=/usr/local/apache--enable-modules=so--enable-rewrite
Make
make install
cp/usr/local/apache/bin/ APACHECTL/ETC/RC.D/INIT.D/HTTPD
Cd/etc/rc.d/init.d
#vi httpd
#在文件首部 #!/bin/bash Line, add the following
# Chkconfig: 2345
# description:this is a Internet www Server
#说明一下, it is not possible to call Chkconfig directly, you must add the above two lines.
#description是描述这个服务用的, be sure to write a description of the service and not in Chinese,
#chkconfig: The first set of numbers is system run level 2345 represents the system run level
#第二个数字是优先级 that will be set to start. 00 Priority is the highest, of course, considering the dependencies, your service priority should not be too high
#如果, higher than the priority of the service you are relying on, then your service will not start properly
#第三组数字就是杀死服务的优先级
Chkconfig--add httpd

#mysql
The code is as follows Copy Code
./configure--prefix=/usr/local/mysql--localstatedir=/mydata/web/mysql--with-charset=utf8--with-extra-charsets= All
Make
Make install
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
#创建mysql用户和用户组
Groupadd MySQL
useradd-g MySQL MySQL
Chown-r Root/usr/local/mysql
Chgrp-r Mysql/usr/local/mysql
Chown-r Mysql/var/mysql
#初始化权限数据库, you don't need to start MySQL
scripts/mysql_install_db--user=mysql
#启动mysql, "&" is running in the background
/usr/local/mysql/bin/mysqld_safe--user=mysql&
#更改root密码
/usr/local/mysql/bin/mysqladmin-u root-p Password "123456"
#设置为开机自启动
Cd/etc/rc.d/init.d
Cp/usr/local/mysql/share/mysql/mysql.server mysqld
chmod +x mysqld
Chkconfig--add mysqld

#PHP
The code is as follows Copy Code
./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/apache/bin/apxs--with-gd--with-zlib--with-png--with-freetype-dir-- With-config-file-path=/usr/local/php/etc--enable-gd-native-ttf--with-ttf--enable-memory-limit-- Enable-zend-multibyte--disable-ipv6--disable-path-info-check--with-iconv--disable-debug--with-mail-- Enable-mbregex--with-curl--enable-mbstring=all--enable-zip--enable-exif--with-jpeg-dir=/usr/lib64/
Make
Make install
#配置apache
The code is as follows Copy Code
# vi/usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps
#开放80端口

The code is as follows Copy Code
#iptables-A input-i eth0-p TCP--dport 80-j ACCEPT

Iv. integrating Apache with PHP

The code is as follows Copy Code
# vi/usr/local/apache2/conf/httpd.conf

On the last line, add:

The code is as follows Copy Code
AddType application/x-httpd-php. php

Find: (set WEB default file)

The code is as follows Copy Code
DirectoryIndex index.html

To be replaced by:

The code is as follows Copy Code
DirectoryIndex index.php index.html index.htm//The default file is not in the WEB directory, httpd executes/var/www/error/noindex.html

Find this paragraph:

The code is as follows Copy Code
# AllowOverride Controls What directives may is placed in. htaccess files.
# It can be ' all ', ' None ', or any combination of the keywords:
# Options FileInfo authconfig Limit
#
allowoverride None

Change to allowoverride all
Allow Apache rewrite

Save Httpd.conf, exit.

The code is as follows Copy Code

#/usr/local/apache2/bin/apachectl Restart//Restart Apache

Five, test

The code is as follows Copy Code
vi/usr/local/apache2/htdocs/test.php

Add a new line below and save it.

The code is as follows Copy Code

<?php phpinfo ();?>

# chmod 755/usr/local/apache2/htdocs/phpinfo.php

Open http://locahost/test.php in Browser

or http://this machine ip/test.php
(if IP is 192.168.4.2 then http://192.168.4.2/test.php)

When you see the PHP page, it means success!

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.