Compile and install LAMP under Centos 5.2

First use Virtualbox to install a CentOS 5.2 virtual machine, and the network connection uses Host-only Adapter, so that the host and guest machines can access each other, but the guest machines cannot be connected to the WAN.

0、 Initial system configuration

Source file location /root/software
Compile and install location /usr/local/{software_name}
Data storage /data1/

Apache operating account www:www
mysql running account mysql:mysql

Close Selinux

Selinux often has some strange effects on the operation of the system. If you are not particularly familiar with it, it is recommended to turn off Selinux.
The configuration file of Selinux is located in /etc/selinux/config, the part we need to modify is:
        SELINUX=enforcing
Modify it to SELINUX=disabled, then restart the server, and the SELINUX configuration will take effect.

Configure iptables

Install the necessary software

If you can connect to the network, you can install these necessary tools through yum; if you can't connect to the network, you need to use the local installation source or installation files.

Some necessary tools are listed below:
gcc
        wget
        make
        ntp
        patch
        autoconf
        automake
        bzip2-devel

To install from a local source, first load the installed image file in Devices -> Mount CD/DVD-Rom -> CD/DVD-Rom image of Virtualbox.
The planned software and its version:
apache 1.3.41cronolog 1.6.2gd 2.0.35libiconv 1.13.1libmcrypt 2.5.8mcrypt 2.6.7openssl 0.9.8kopenssh    5.2p1pecre 7.9nginx 0.7.62mysql 5.0.51php 5.2.9/4.4.9memcached 1.4.1memcache 2.2.5xcache 1.2.2zend optimizer 3.3.9imapbind 9.4.2

1、 Install other software

Install OpenSSL:
        ./config --prefix=/usr/local/openssl/
        make
        make test
        make install
Install GD2
        ar jxvf gd-2.0.35.tar.bz2
        cd gd-2.0.35
        ./configure --prefix=/usr/local/gd2
        make &&make install
        cd ..

Install libiconv
        tar zxvf libiconv-1.12.tar.gz
        cd libiconv-1.12
        ./configure --prefix=/usr &&make &&make install
        cd ..

Install libmcrypt
        tar jxvf libmcrypt-2.5.8.tar.bz2
        cd libmcrypt-2.5.8
        ./configure --prefix=/usr/local/libmcrypt &&make &&make install
        cd ..

Install cronolog
        ./configure --prefix=/usr/local/cronolog
        make && make install

2、 Install mysql
This article uses a binary installation method. The basic sequence is similar to the official mysql sequence, except for some explanations.
    shell> groupadd mysql
    shell> useradd -g mysql mysql
    shell> cd /usr/local
    shell> tar -xvzf /path/to/mysql-VERSION-OS.tar.gz
    shell> mkdir /usr/local/mysql
    shell> cp -rf /path/to/mysql-VERSION-OS /usr/local/mysql
    shell> cd /usr/local/mysql
    shell> chown -R mysql .
    shell> chgrp -R mysql .
    shell> scripts/mysql_install_db --user=mysql
    shell> chown -R root .
    shell> chown -R mysql data
    shell> bin/mysqld_safe --user=mysql &
The first few steps are generally not a problem, but when the last step is executed bin/mysqld_safe --user=mysql &, the system fails:
    Starting mysqld daemon with databases from /var/lib/mysql
    STOPPING server from pid file /var/run/mysqld/mysqld.pid
    090930 12:19:32  mysqld ended
Then it's over. The reason for this problem can be seen in the log file /var/log/mysqld.log
    090930 12:19:31  mysqld started
    090930 12:19:31 [Warning] option 'thread_stack': unsigned value 126976 adjusted to 131072
        090930 12:19:32  InnoDB: Started; log sequence number 0 43655
        090930 12:19:32 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
        090930 12:19:32 [ERROR] Can't start server: can't create PID file: No such file or directory
        090930 12:19:32  mysqld ended

That is, the permissions are not enough. There are two solutions. One is to create a /var/run/mysqld/ folder with mysql permission to read and write; the other method, we can use /usr/local/mysql/support-files/ mysql.server to start the service.

After mysql is installed, the file storage structure is in accordance with the default settings, such as some common ones:
Configuration file /etc/my.cnf
        basedir    /usr/local/mysql
Finally, you need to configure mysql to start the service with the system, copy /usr/local/mysql/support-files/mysql.server -> /etc/rc.d/init.d/mysql, and then add chkconfig --add mysql
In this way, you can start the mysql service through service mysql start

3、 Install Apache

In this article, Apache chooses the classic version 1.3.41.

There is more than one way to install apache. No matter which one, we must first confirm that there is no httpd service running in the current system: ps -aux | grep httpd. If we find any in the result, we should kill him.
Then go to the apache installation directory, here is /root/software/source_lamp/apache_1.3.41, the structure and files in the entire directory are introduced as follows:
cgi-bin/-Script for testing CGI. Subsequently, the installation process will copy these files to the server's /cgi-bin directory. If the CGI function of Apache is enabled, these scripts can be used to test those functions.
conf/-configuration file. The configuration at the time of publication should not be edited. During the installation process, these files are copied to the server configuration directory, and these copied files will be extended and edited.
htdocs/-the first Web site. The installation process copies these files to the document root directory of the server. These pages will be displayed when the browser first tests the server.
icons/-Directory index icon. These image files will become icons used by the Web server to provide a special path indexing function.
logs/-Log tool. This directory is empty. The installation process will create a log directory for the installed server.
src/-source code. This directory (and its subdirectories) contains C language source code files, you compile them to create an Apache web server.

First execute configure, where bin/data/log, three directories are customized:
    ./configure --prefix=/usr/local/lampsrv/apache/ --datadir=/data1/www/data/htdocs/ --logfiledir=/data1/www/applogs/ --enable-shared=max --enable-module=most
    make
    make install
4、 Install PHP
Unzip the downloaded installation package, and then perform the configuration.
    ./configure --prefix=/usr/local/lampsrv/php --with-apxs=/usr/local/lampsrv/apache/bin/apxs  --with-config-file-path=/usr/local/lampsrv/etc/php/ --enable-track-vars --with-xml --with-mysql
    make && make install

After the installation is complete, add the analysis of the php suffix in the apache configuration file.
    AddType application/x-httpd-php .php .php3 .inc
    AddType application/x-httpd-php-source .phps

Then restart the apache service: /usr/local/lampsrv/apache/bin/apachectl restart
When starting, you may encounter this error: Cannot load /usr/local/apache2/modules/libphp4.so into server: /usr/local/apache2/modules/libphp4.so: cannot restore segment prot after reloc: Permission Denied

This situation is generally caused by the security settings of selinux. You can consider turning off selinux and set it in /etc/selinux/config.

5、 Installation summary

So far, we have configured the basic Linux + Apache + Mysql + PHP operating environment, but there are still many configuration files scattered everywhere, such as mysql configuration files and data files. How to put these configuration files and data files in a unified location, such as /data1/www/etc, is still a problem that needs to be summarized and accumulated. Another is how to form a quick installation and configuration mode by writing scripts It is a problem that needs experience to realize the rapid configuration of multiple machines by building a yum source. In these two aspects, we will continue to summarize in the future.

Reference materials:
1、 CentOS 5.2 Compile and Install
2、 Apache httpd project
3、 Cronolog
4、 GD Library
5、 GNU libiconv
6、 OPEN SSL
7、 OPEN SSH
8、 PCRE
9、 nginx
10、 mysql
11、 php
12、 Memcached
13、 XCache
14、 IMAP
15、 Mysql Install
16、 Linux self-start detailed settings
17、 Apache 1.3.x installation configuration notes
18、 Apache Installation Guide

Recommended Posts

Compile and install LAMP under Centos 5.2
Compile and install libmodbus library under CentOS7
CentOs7.3 compile and install Nginx 1.9.9
Centos compile and install Git
Centos7 compile and install ntp-4.2.8p11
CentOS 6.9 compile and install python
CentOS 6 compile and install python 3
Install and configure keepalived under CentOS 5.9
CentOS Yum compile and install MySQL 5.6
CentOS 6.x compile and install Nginx
CentOS7 compile and install L(A|N)MP environment
Centos compile and install LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8) + Redis
Install Python3 and ansible under CentOS8
Install and use docker under CentOS 6.8
Compile and install Lnmp shell script under Linux centos
Install Python3 and Py under CentOS7
Linux CentOS6 compile and install Pyt
Compile and install QEMU under Ubuntu
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
centos7 install lamp
CentOS7.5 source code compile and install mysql5.7.29
Centos7 compile and install MySQL8 problem record
Install Mono 2.10.8 and Jexus 5.0 under 32- and 64-bit CentOS 6.0
Compile and install nodejs and yum in Centos8
CentOS7.4 source code compile and install MySQL8.0
Install centos7 and connect
Compile Hadoop-2.7.6 under CentOS7.4
Install mysql5.7 under CentOS7
Install ActiveMQ under Centos7
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
Install mysql under Centos 7
Configure lamp under centos6.8
Install Jenkins under Centos 7
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
Install svn and configuration through yum under CentOS
Centos6.5 compile and install LNMP architecture web environment
Centos7.2 compile and install way to build phpMyAdmin
centos7 install python3 and ipython
Know Linux and install CentOS
CentOS 7 install Mono and MonoDevelop
Ubuntu 16.04 compile and install PHP 7.2
ubuntu18.04 compile and install python3.8
CentOS6.5 install Java 8 and Tomcat8
Install Oracle11gR2 database under CentOS6.9
Install MySQL under Linux (CentOS 7)
Centos6.5 install and configure mongodb
CentOS7 install python3 and pip3
Install Java JDK8 under CentOS6
CentOS7 install OracleJDK and JRE
CentOS6.5 install Java 8 and Tomcat8
CentOS6 install and crack Jira 7
CentOS6.5 install Java 8 and Tomcat8
CentOS6 install and crack confluence
Install MongoDB database under CentOS7
CentOS6 install and crack Jira 7
CentOS 6.8 under linux install mongodb
Install Mesos tutorial under CentOS7
Compile and install OpenJDK8 from source code under Ubuntu 18.04.1
Centos 7 install jdk and package service service