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*
2、 Install libmcrypt
3、 Install zlib
4、 Install libpng
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.
6、 Install freetype
7、 Install autoconf
8、 Install GD library
9、 Install xpm
10、 Install apr
11、 Install apr-util
12、 Install pcre
13、 Install curl
Fourth, install Apache****1, download the source code # cd /usr/local/src
3、 Enter the source code directory and start the installation
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=
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
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 \
DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
DMYSQL_DATADIR=/usr/local/mysql/mydata \
DSYSCONFDIR=/etc \
DEXTRA_CHARSETS=all \
DDEFAULT_CHARSET=utf8 \
DDEFAULT_COLLATION=utf8_general_ci \
DWITH_MYISAM_STORAGE_ENGINE=1 \
DWITH_INNOBASE_STORAGE_ENGINE=1 \
DWITH_MEMORY_STORAGE_ENGINE=1 \
DWITH_READLINE=1 \
DMYSQL_TCP_PORT=3306 \
DENABLED_LOCAL_INFILE=1 \
DWITH_PARTITION_STORAGE_ENGINE=1 \
DWITH_SSL=yes \
DWITH_BOOST=/usr/local/src/boost_1_59_0 \
DMYSQL_USER=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/
# 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/
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# 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.
# groupadd www
# useradd -g www -s /sbin/nologin -M www
# 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
# 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
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