Brief introduction
Linux+apache+mysql/mariadb+perl/php/python a group of open-source software that is often used to build dynamic Web sites or servers is itself a separate program, but because it is often used together, it has a higher degree of compatibility, Together make up a powerful Web application platform. With the booming of the open source, the three pillars has been developed with the development of Java EE and. NET commercial software, and the software-developed project has a low cost of investment in software and is therefore of concern to the entire IT community. From the website traffic, more than 70% of the traffic is lamp to provide, lamp is the most powerful website solution.
Experimental environment
- System Environment: centos6.5
- Host IP Address: 192.168.100.20
- Yum Mount directory:/mnt/sr0
- Related source package: Baidu Cloud download?? Password: x32f
Build Step one, install APACHE1, prepare for work, turn off firewalls and SELinux
[Email protected] ~]# chkconfig iptables off #随开机关闭iptables
[Email protected] ~]# Vim/etc/sysconfig/selinux
[email protected] ~]# reboot #重启Linux生效
2. Install GCC, gcc-c++, make, ARP, Arp-util, Pcre and other toolkits
[Email protected] ~]# yum-y install gcc gcc-c++ make #安装C语言编译器以及make
[Email protected] ~]# TAR-ZXVF apr-1.4.6.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/apr-1.4.6/
[[email protected] apr-1.4.6]#./configure prefix=/usr/local/apr && make && make install
[Email protected] ~]# TAR-ZXVF apr-util-1.4.1.tar.gz-c/usr/src/
[R[email protected] ~]# CD/USR/SRC/APR-UTIL-1.4.1/
[Email protected] apr-util-1.4.1]#/configure prefix=/usr/local/apr-util--with-apr=/usr/local/apr && Make & amp;& make Install
[Email protected] ~]# TAR-ZXVF pcre-8.10.tar.gz-c/usr/src
[Email protected] ~]# cd/usr/src/pcre-8.10/
[[email protected] pcre-8.10]#./configure prefix=/usr/local/pcre && make && make install
3. Configuring and installing Apache
[Email protected] ~]# tar xvfz httpd-2.4.2.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/httpd-2.4.2/
[Email protected] httpd-2.4.2]#/configure \
--PREFIX=/USR/LOCAL/HTTPD \
--WITH-APR=/USR/LOCAL/APR \
--with-pcre=/usr/local/pcre \
--ENABLE-SO \
--enable-rewrite \
--enable-mods-shared=most \
--with-mpm=worker \
--disable-cgid \
--disable-cgi
parameter resolution:
Prefix: Specifying the installation directory
installation directory for WITH-APR:APR
With-pcre: Using the extended pcre regular expression Library
ENABLE-SO: Enable dynamic load module support, what functions are required to dynamically load
Enable-rewrite: Enable Web address rewriting to implement pseudo-static
Enable-mods-shared: Enabled shared DSO module
WITH-MPM: Select the processing module that Apache uses
Disable-cgid: Disable Cgid
DISABLE-CGI: Enable CGI script support (Universal Gateway Interface)
[[email protected] httpd-2.4.2]# make && make install# compile and compile installation
4. Adding system Services
[Email protected] ~]# cp/usr/local/httpd/bin/apachectl/etc/init.d/httpd #将启动脚本拷贝服务程序目录下
[Email protected] ~]# vim/etc/init.d/httpd #修改启动脚本
lines 2nd, 32 add the following parameters:
# chkconfig:2345 85 15
# Description:apache is a world Wide Web server.
[Email protected] init.d]# chmod +x/etc/init.d/httpd #添加执行权限
[Email protected] init.d]# chkconfig--add httpd #将apache添加至服务程序中
5, the establishment of soft links, easy to manage
[Email protected] ~]# mkdir-p/etc/httpd
[Email protected] ~]# ln-s/usr/local/httpd/conf//etc/httpd/#优化配置文件路径
[Email protected] ~]# ln-s/usr/local/httpd/bin/*/usr/local/bin/#优化命令路径
6. Modify the configuration file
[Email protected] ~]# vim/etc/httpd/conf/httpd.conf
Modify the following parameters:
ServerName www.bt.com:80 #填写完全主机名
Listen 192.168.100.103:80 #监听本地IP
7. Restart Service, test
[[Email protected] ~]# service httpd start
Second, the installation of MYSQL1, the mysql-server of the way to unload the PRM, MySQL
[Email protected] ~]# Rpm-qa | grep MySQL
2, install Ncurses-devel, bison, Libaio-devel, cmake Kit
[Email protected] ~]# yum-y install ncurses-devel bison libaio-devel CMake
3. Create process user MySQL
[[email protected] ~]# useradd-s/sbin/nologin MySQL
4, unzip, configure the installation of MySQL
[Email protected] ~]# mkdir-p/usr/local/mysql #创建mysql目录
[Email protected] ~]# tar zxvf mysql-5.5.24.tar.gz-c/usr/src
[Email protected] ~]# cd/usr/src/mysql-5.5.24/
[Email protected] mysql-5.5.24]# cmake-dcmake_install_prefix=/usr/local/mysql \
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
-dwith_extra_charsets=all \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_readline=1 \
-denabled_local_infile=1 \
-dmysql_datadir=/home/mysql \
-dmysql_user=mysql \
-dmysql_tcp_port=3306
parsing:
Dcmake_install_prefix:mysql Software Installation Location
Ddefault_charset: Default Character Set
Ddefault_collation: Default character check
Dwith_extra_charsets: Additional encoding, use all to compile
Dwith_myisam_storage_engine: Installing the MYISAM storage engine
Dwith_innobase_storage_engine: Installing the InnoDB storage engine
Dwith_memory_storage_engine: Installing the memory storage engine
Dwith_readline: Supports READLINE library, supports reading data in one row
Denabled_local_infile: Enable local load data
Dmysql_datadir: Data Catalog
Dmysql_user: Specify the running user for MySQL
The Dmysql_tcp_port=3306:mysql port number is 3306 by default
[[email protected] mysql-5.5.24]# make && make install #编译及编译安装
5. Modify the MySQL installation directory owner, the owning group
[Email protected] mysql-5.5.24]# chown-r mysql:mysql/usr/local/mysql/
6. Create and modify MY.CNF configuration files
[email protected] mysql-5.5.24]# CP support-files/my-medium.cnf/etc/my.cnf
7. Adding system Services
[Email protected] mysql-5.5.24]# Vim/etc/profile #修改系统环境变量
The last line is added:
Export path= $PATH:/usr/local/mysql/bin/
[Email protected] mysql-5.5.24]# Source/etc/profile #重新读取系统环境变量
[email protected] mysql-5.5.24]# CP support-files/mysql.server/etc/init.d/mysqld #添加系统服务
[Email protected] mysql-5.5.24]# chmod +x/etc/init.d/mysqld #添加执行权限
[Email protected] mysql-5.5.24]# chkconfig--add mysqld #将mysqld添加为系统服务
8. Initialize the database
[Email protected] mysql-5.5.24]#/usr/local/mysql/scripts/mysql_install_db
--user=mysql
--ldata=/var/lib/mysql
--basedir=/usr/local/mysql
--datadir=/home/mysql
Analytical:
User: Specify the database administrator, which is who manages the database
Basedir: Specify the MySQL Software installation location
DataDir: Specify the MySQL data installation location
[Email protected] mysql-5.5.24]# Vim/etc/init.d/mysqld
Locate Basedir, DataDir to assign the value:
Basedir=/usr/local/mysql #约46行数据库安装目录
Datadir=/home/mysql #约47行数据存放目录
9. Restart the database
[[Email protected] mysql-5.5.24]# service mysqld start
[Email protected] mysql-5.5.24]# NETSTAT-ANPT | grep 3306 #查看端口
10. Access MySQL
[Email protected] ~]# mysqladmin-u root password ' 123 ' #设置新密码
[Email protected] ~]# mysql-uroot-p123 #登录mysql
Third, install PHP1, install GD Library Association Program
[[email protected] ~]# Yum install \
Libjpeg-devel \
Libpng-devel \
Freetype-devel \
Zlib-devel \
Gettext-devel \
Libxpm-devel \
Libxml2-devel \
Fontconfig-devel \
Openssl-devel \
Bzip2-devel
2, decompression, configuration installation GD (used to process and generate pictures)
[Email protected] ~]# tar xzvf gd-2.0.35.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/gd/2.0.35/
[Email protected] 2.0.35]#/configure--PREFIX=/USR/LOCAL/GD
[[email protected] 2.0.35]# make && make install
3. Unzip the configuration to install PHP
[Email protected] ~]# tar xjvf php-5.4.5.tar.bz2-c/usr/src
[Email protected] ~]# cd/usr/src/php-5.4.5/
[Email protected] php-5.4.5]#/configure \
--prefix=/usr/local/php \
--WITH-APXS2=/USR/LOCAL/HTTPD/BIN/APXS \
--WITH-GD \
--with-mysql=/usr/local/mysql \
--WITH-CONFIG-FILE-PATH=/ETC \
--enable-sqlite-utf8 \
--with-zlib-dir \
--with-libxml-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--WITH-TTF \
--with-iconv \
--WITH-OPENSSL \
--with-gettext \
--enable-mbstring \
--ENABLE-GD-NATIVE-TTF \
--enable-gd-jis-conv \
--enable-static \
--enable-zend-multibyte \
--enable-inline-optimization \
--enable-sockets \
--ENABLE-SOAP \
--ENABLE-FTP \
--disable-ipv6
[[email protected] php-5.4.5]# make && make install
4. Create a PHP configuration file
[email protected] ~]# CP Php.ini-production/etc/php.ini
5. Modify Apache configuration file
[Email protected] ~]# vim/usr/local/httpd/conf/httpd.conf
about 143 Lines check if the following statement exists, and if it does not, you will need to reinstall MySQL, if not already, to reload Apache directly:
LoadModule Php5_module modules/libphp5.so
About 242 lines add PHP home page recognition:
<ifmodule dir_module>
DirectoryIndex index.php index.html
</IfModule>
About 348 add support PHP suffix:
<ifmodule mime_module>
AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps
<ifmodule mime_module>
6. Restart Apache
[Email protected] php-5.4.5]#/etc/init.d/httpd restart
7. Test whether PHP Web page is displayed correctly
[Email protected] ~]# cd/usr/local/httpd/htdocs/#进入站点目录
[Email protected] php-5.4.5]# vim test1.php #建立测试页
Add PHP Test content:
<?php
Phpinfo ();
?>
8. Test PHP Web page to access MySQL server
[Email protected] ~]# vim/usr/local/httpd/htdocs/test2.php
Add PHP Test content:
<?php
$link =mysql_connect (' localhost ', ' root ', ' 123 ');
if ($link) echo "Welcome to Mysql";
Mysql_close ();
?>
Iv. Forum installation 1, create related databases
[[email protected] ~]# mysql-uroot-p123# login MySQL
Mysql> CREATE DATABASE bbs; #创建一个数据库
Mysql> GRANT all on bbs.* to ' bbsuser ' @ ' percent ' identified by ' admin123 '; #把bbs数据库里面所有表的权限授予给bbsuser, and set the password
Mysql>flush privileges; #刷新数据库
2, Decompression Forum source package
[Email protected] ~]# Unzip discuz_x2.5_sc_utf8.zip-d/usr/src #解压
[Email protected] ~]# cp-r/usr/src/upload//usr/local/httpd/htdocs/bbs #将源码拷贝到站点目录下
3. Modify the permissions of the forum file
[Email protected] ~]# Cd/usr/local/httpd/htdocs/bbs
[Email protected] bbs]# chown-r daemon./config/#递归修改所有者权限
[Email protected] bbs]# chown-r daemon./data/
[Email protected] bbs]# chown-r daemon./uc_client/
[Email protected] bbs]# chown-r daemon./uc_server/data/
[Email protected] ~]# Vim/etc/php.ini
about 919 Lines, remove the comment, assign the value to UTC, or use the URL to install the error
Date.timezone = UTC
4. Installation Forum
Source code manually compiled lamp architecture Discuz Forum (containing source package)