Configure lamp under centos6.8

1. Install Apache2.4.25

1. System environment
System platform: CentOS 6.8 64 bit
Apache version: httpd-2.4.25.tar.gz
MySQL version: mysql-5.7.18.tar.gz
PHP version: php-7.1.4.tar.gz
phpMyAdmin version: phpMyAdmin-4.7.0-all-languages.tar.gz

2. Preparation before installation
Before installing PHP, you should install the latest version of the library files required by PHP, such as libxml2, libmcrypt, and GD2 libraries. The GD2 library is installed to allow PHP to support image formats such as GIF, PNG and JPEG, so before installing the GD2 library, you must install the latest zlib, libpng, freetype, and jpegsrc library files. Moreover, some extensions and software will be interspersed in the construction of the entire environment, which can be installed according to the steps.

1、 Prepare the required library files (some of them are useless after installation, but install them all)
autoconf-2.69.tar.gz
freetype-2.7.1.tar.gz
libgd-2.1.0.tar.gz
jpegsrc.v9.tar.gz
libmcrypt-2.5.8.tar.gz
libpng-1.6.29.tar.gz
libxml2-2.7.8.tar.gz
zlib-1.2.11.tar.gz
apr-1.5.2.tar.gz
apr-util-1.5.4.tar.gz
pcre-8.40.tar.gz
curl-7.54.0.tar.gz

2、 Dependent libraries needed to install the system (because of the lack of dependencies in the subsequent installation process, I have sorted it out now and concentrated on this step to install)
yum -y install gcc gcc-c++ gcc-g77 make cmake bison ncurses-devel autoconf automake zlib* fiex* libxml* libmcrypt* libtool-ltdl-devel* libaio libaio-devel bzr libtool ncurses5-devel imake libxml2-devel expat-devel

**3、 Uninstall the previous version of the environment **
a, use yum remove xxxx command
b. Use the rpm -e xxxx command
c. Delete related files rm -rf xxxx

4、 Upload the prepared .tar.gz software package to the /usr/local/src directory of the server5. Use the tar -zxvf xxxx command to decompress the software packages one by one3. Install the dependent libraries* 1, install libxml2*

cd /usr/local/src/libxml2-2.7.8

. /configure --prefix=/usr/local/libxml2

make && make install

2、 Install libmcrypt

cd /usr/local/src/libmcrypt-2.5.8

. /configure --prefix=/usr/local/libmcrypt

make && make install

3、 Install zlib

cd /usr/local/src/zlib-1.2.11

. /configure --prefix=/usr/local/zlib

make && make install

4、 Install libpng

cd /usr/local/src/libpng-1.6.29

. /configure --prefix=/usr/local/libpng

make && make install

5、 Install jpeg9

The installation of this package is a bit special. If the directory does not exist when other packages are installed, it will be created automatically, but this package needs to be created manually during installation.

mkdir /usr/local/jpeg9

mkdir /usr/local/jpeg9/bin

mkdir /usr/local/jpeg9/lib

mkdir /usr/local/jpeg9/include

mkdir -p /usr/local/jpeg9/man/man1

cd /usr/local/src/jpeg-9

. /configure --prefix=/usr/local/jpeg9/ --enable-shared --enable-static

make && make install

6、 Install freetype

cd /usr/local/src/freetype-2.7.1

. /configure --prefix=/usr/local/freetype

make && make install

7、 Install autoconf

cd /usr/local/src/autoconf-2.69

. /configure

make && make install

8、 Install GD library

cd /usr/local/src/libgd-2.1.0

. /configure -prefix=/usr/local/gd2 \

make && make install

9、 Install xpm

yum -y install libXpm-devel.x86_64

10、 Install apr

cd apr-1.5.2

. /configure --prefix=/usr/local/apr

make && make install

11、 Install apr-util

cd apr-util-1.5.4

. /configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make && make install

12、 Install pcre

cd pcre-8.40

. /configure --prefix=/usr/local/pcre

make && make install

13、 Install curl

cd curl-7.54.0

. /configure --prefix=/usr/local/curl

make && make install

Fourth, install Apache****1, download the source code # cd /usr/local/src

wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.25.tar.gz2, unzip

tar -zxvf httpd-2.4.25.tar.gz

3、 Enter the source code directory and start the installation

cd httpd-2.4.25

. /configure --prefix=/usr/local/apache2 \

make && make install

4、 After installation, configure Apache and find /usr/local/apache2/conf/httpd.cnf
a. Change #ServerName www.example.com:80 in the file to ServerName localhost:80, the path of ServerRoot to "/usr/local/apache2", and the path of DocumentRoot to "/usr/local/apache2/htdocs ".

b. Modify the permissions of all files

< Directory />

Options FollowSymLinks

AllowOverride All

Order deny,allow

Allow from all

Satisfy all

< /Directory>

< Directory "/usr/local/apache2/cgi-bin">

AllowOverride None

Options None

Order allow,deny

Allow from all

< /Directory>

c, modify the root directory permissions

< Directory "/usr/local/apache2/htdocs">

Options Indexes FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

Require all granted

< /Directory>

d. Configure welcome page (home page)

< IfModule dir_module>

DirectoryIndex index.php index.html index.htm

< /IfModule>

e. Load PHP modules and open other extensions

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

Addtype application/x-httpd-php .php .phtml

f. Configure startup script# cp /usr/local/src/httpd-2.4.25/build/rpm/httpd.init /etc/init.d/httpd

Note that there are three main places in the file that need to be modified:
httpd={HTTPD-/usr/local/apache2/bin/httpd} pidfile={PIDFILE-/usr/local/apache2/logs/${prog}.pid}
CONFFILE=/usr/local/apache2/conf/httpd.conf
Please change the corresponding path according to your actual situation!

g, set up the Apache service and start

chmod +x /etc/init.d/httpd

chkconfig --add httpd

chkconfig httpd on

/etc/init.d/httpd start

netstat -lnp |grep httpd

Install mysql related dependencies:

yum -y install gcc gcc-c++ gcc-g77 make cmake bison ncurses-devel autoconf automake zlib* fiex* libxml* libmcrypt* libtool-ltdl-devel* libaio libaio-devel bzr libtool ncurses5-devel imake libxml2-devel expat-devel

Install boost_1_59_0 (must be this version):
1、 Obtain the source code: If downloaded to the /usr/local/src directory, enter the directory cd /usr/local/src, and then obtain the source code package
wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download

2、 Unzip:
tar -xzvf boost_1_59_0.tar.gz

3、 Enter the boost directory:
cd boost_1_59_0

4、 To configure:
. /bootstrap.sh

5、 Compile:
. /b2

6、 installation:
. /b2 install
After compiling and installing, the boost header files will be copied to the /usr/local/include/ directory, and the library files will be in /usr/local/lib/.

Install cmake (the latest version):
1、 Obtain the source code: still download to the /usr/local/src directory, cd /usr/local/src to obtain the software package
wget https://cmake.org/files/v3.8/cmake-3.8.0.tar.gz

2、 Unzip:
tar -xzvf cmake-3.8.0.tar.gz

3、 Enter the cmake directory:
cd cmake-3.8.0

4、. /bootstrap

5、 gmake

6、 gmake install

Install mysql5.7.18:
1、 Add mysql user and group:
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql

2、 Create mysql installation directory and data directory
mkdir /usr/local/mysql
mkdir /usr/local/mysql/data

3、 Modify the owner of the mysql directory
chown -R mysql:mysql /usr/local/mysql

4、 Obtain the mysql source package: still in the /usr/local/src directory
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18.tar.gz

5、 Unzip:
tar -xzvf mysql-5.7.18.tar.gz

6、 Enter the mysql directory:
cd mysql-5.7.18

7、 cmake compilation configuration:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

8、 Compile and install:
make && make install

9、 Go to the mysql installation directory bin and initialize the database
cd /usr/local/mysql/bin
. /mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql --socket=/usr/local/mysql/mysql.sock
After running the last sentence [note], a mysql default password is generated, copied to a place, and saved.

10、 Add mysql service, copy mysql configuration file
Go back to the mysql installation directory cd ..
Enter the support-files directory cd support-files
Copy the startup file cp -a mysql.server /etc/init.d/mysql //-a can copy the original attributes together

11、 The information on the Internet shows that there is still my.cnf to edit, but my.cnf file was not found after I installed it. Check the information and say that if there is no, the default configuration of the running system, so the configuration of my.cnf is omitted here.

12、 Start mysql
service mysql start

13、 Set boot up
chkconfig mysql on

14、 Login to mysql
Go to cd bin under bin of mysql installation directory
. /mysql -uroot -p
Enter password: //Enter the default password saved before

15、 Change root password
SET PASSWORD = PASSWORD('mysql123');

16、 Refresh mysql system permissions related tables
flush privileges;

17、 Exit mysql:
quit;

Note: There are some problems when installing mysql, the above method may be installed by some people, use yum to install

wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm

yum install mysql57-community-release-el6-7.noarch.rpm
yum install mysql-community-server
service mysqld start
mysql -uroot -p

When encountering a password, you can’t enter, modify the password directly

Multiple methods for MySQL to modify the root password

Just execute SET PASSWORD FOR'root'@'localhost' = PASSWORD('newpass'); directly under Navicat for MySQL

Method 1: Use the SET PASSWORD command

mysql -u root

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

Method 2: Use mysqladmin

mysqladmin -u root password "newpass"

If root has set a password, use the following method

mysqladmin -u root password oldpass "newpass"

Method 3: Use UPDATE to directly edit the user table

mysql -u root

mysql> use mysql;

mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';

mysql> FLUSH PRIVILEGES;

When you lose the root password, you can do this

mysqld_safe --skip-grant-tables&

mysql -u root mysql

mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';

mysql> FLUSH PRIVILEGES;

Install php5.6

# wget http://cn2.php.net/distributions/php-5.6.0.tar.xz
# xz -d php-5.6.0.tar.xz
# tar xf php-5.6.0.tar -C /usr/local/src/

Download PHP source package

# wget http://cn2.php.net/distributions/php-5.6.0.tar.xz
# xz -d php-5.6.0.tar.xz
# tar xf php-5.6.0.tar -C /usr/local/src/

Add epel source####

# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Installation dependencies####

# yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel

Note: If you use the source of epel 7, you may not have mcrypt mhash mhash-devel several packages, download them in http://dl.fedoraproject.org/pub/epel/6/x86_64/ , Use yum localinstall xxx.rpm or rpm -Uvh xxx.rpm to install manually.

Create www user####

# groupadd www
# useradd -g www -s /sbin/nologin -M www

Compile and install

# cd /usr/local/src/php-5.6.0/

# . /configure \
- - prefix=/usr/local/php56 \
- - with-config-file-path=/usr/local/php56/etc \
- - enable-inline-optimization \
- - disable-debug \
- - disable-rpath \
- - enable-shared \
- - enable-opcache \
- - enable-fpm \
- - with-fpm-user=www \
- - with-fpm-group=www \
- - with-mysql=mysqlnd \
- - with-mysqli=mysqlnd \
- - with-pdo-mysql=mysqlnd \
- - with-gettext \
- - enable-mbstring \
- - with-iconv \
- - with-mcrypt \
- - with-mhash \
- - with-openssl \
- - enable-bcmath \
- - enable-soap \
- - with-libxml-dir \
- - enable-pcntl \
- - enable-shmop \
- - enable-sysvmsg \
- - enable-sysvsem \
- - enable-sysvshm \
- - enable-sockets \
- - with-curl \
- - with-zlib \
- - enable-zip \
- - with-bz2 \
- - with-readline

Parameter Description:

""" installation path"""--prefix=/usr/local/php56 \
""" php.ini configuration file path"""--with-config-file-path=/usr/local/php56/etc \
""" Optimization options"""--enable-inline-optimization \
- - disable-debug \
- - disable-rpath \
- - enable-shared \
""" Enable opcache, the default is ZendOptimizer+(ZendOpcache) """--enable-opcache \
""" FPM """--enable-fpm \
- - with-fpm-user=www \
- - with-fpm-group=www \
""" MySQL """--with-mysql=mysqlnd \
- - with-mysqli=mysqlnd \
- - with-pdo-mysql=mysqlnd \
""" Internationalization and character encoding support"""--with-gettext \
- - enable-mbstring \
- - with-iconv \
""" Encryption extension"""--with-mcrypt \
- - with-mhash \
- - with-openssl \
""" Math extension"""--enable-bcmath \
""" Web service, soap depends on libxml"""--enable-soap \
- - with-libxml-dir \
""" Process, signal and memory"""--enable-pcntl \
- - enable-shmop \
- - enable-sysvmsg \
- - enable-sysvsem \
- - enable-sysvshm \
""" socket & curl """--enable-sockets \
- - with-curl \
""" Compression and archiving"""--with-zlib \
- - enable-zip \
- - with-bz2 \
""" GNU Readline command line shortcut key binding"""--with-readline

If your Web Server uses Apache, please add parameters like: --with-apxs2=/usr/local/apache-xx/bin/apxs.

For mysqlnd, please refer to What is the MySQL Native driver for PHP? or the official introduction of MySQL: MySQL native driver for PHP, or Installation on Unix.

PHP 5.6 has a built-in phpdbg interactive debugger, which is enabled by --enable-phpdbg, and a phpdbg command will be generated in the PREFIX/bin directory. If you are interested, you can try it.

For more compilation parameters, please use ./configure --help to view.

# make -j8
# make install

If you want to reinstall:

# make clean
# make clean all

# . /configure ...
# make -j8
# make install

Configure PHP

# cp php.ini-development /usr/local/php56/etc/php.ini
# cp /usr/local/php56/etc/php-fpm.conf.default/usr/local/php56/etc/php-fpm.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm56
# chmod +x /etc/init.d/php-fpm56
# service php-fpm56 start
Starting php-fpm  done

php-fpm available parameters start|stop|force-quit|restart|reload|status

Add PHP commands to environment variables

Edit ~/.bash_profile, change:

PATH=$PATH:$HOME/bin
To:
PATH=$PATH:$HOME/bin:/usr/local/php56/bin

Make the PHP environment variable take effect:

# .~ /.bash_profile
# php -v
PHP 5.6.0(cli)(built: Sep 23201403:44:18)Copyright(c)1997-2014 The PHP Group
Zend Engine v2.6.0,Copyright(c)1998-2014 Zend Technologies

These are installed by themselves and refer to different materials. Thank you for these materials on the Internet and friends who have blog records.

Recommended Posts

Configure lamp under centos6.8
Install and configure keepalived under CentOS 5.9
Centos7 configure JDK
centos7 install lamp
Configure iSCSI network storage under CentOS 7.x
Deploy GitBook under CentOS7
Compile Hadoop-2.7.6 under CentOS7.4
Configure Ocserv on CentOS 6
Install mysql5.7 under CentOS7
Install ActiveMQ under Centos7
lamp (centos7) installation lamp environment
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
Deploy JDK+Tomcat8 under CentOS
Install mysql under Centos 7
Centos7 configure IP address
Install Jenkins under Centos 7
Redis3 installation under Centos7
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
Centos7 configure nodejs environment
Configure CentOS7 GPU environment
Install PHP in yum under CentOS, configure php-fpm service
Xen virtualization combat under CentOS 6.6
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Build OpenV** Server under CentOS7
Build OpenLDAP server under CentOS7
Redis cluster installation under CentOS
Install Oracle11gR2 database under CentOS6.9
3 partitioning tools under CentOS Linux
Install MySQL under Linux (CentOS 7)
Redis cluster installation under CentOS
Centos6.5 install and configure mongodb
Centos configure multiple virtual IP
Configure swap space on CentOS7
SELinux security settings under CentOS
Install Java JDK8 under CentOS6
Install MongoDB database under CentOS7
CentOS 6.8 under linux install mongodb
Set static IP under Centos
Centos configure multiple virtual IP
Install Mesos tutorial under CentOS7
CentOS 7 configure Java language development environment
Use Nginx and u under CentOS
Configure rsyslog log client on CentOS
CentOS 8 (2)
CentOS 6/7 configure sendEmail to send mail
[Introduction to redis] Install redis under Centos
RabbitMQ cluster deployment record under Centos6.9
CentOS 7 configure Ruby language development environment
Installation under centos6.9 of jenkins learning
CentOS 7 configure php language development environment
Build a PXC cluster under CentOS8
Elasticsearch cluster deployment record under CentOS7
Upgrade OpenSSL and OpenSSH under CentOS7
Deploy and optimize Tomcat under Centos
CentOS 8 - install and configure NFS service
Install Harbor mirror warehouse under CentOS
Build an FTP server under centos7
Java-JDK installation and configuration under CentOS
Install Python3 and ansible under CentOS8