Home >Backend Development >PHP Problem >What are the steps to install the php source code package?

What are the steps to install the php source code package?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-08-30 09:30:257470browse

What are the steps to install the php source code package?

Basic commands:

1. Step 1: tar command tar -zxvf source package (.tar.gz The path of the compressed package at the end), (jxvf at the end of .bzip2)

2. Step 2: Enter the decompression directory, cd command

3. Step 3: Configuration, ./configure --prefix=Specify the installation directory

4. Step 4: Compile, make

5. Step 5: Install, make install

Preparation:

First use winscp to connect to the server and place the package in the /php/tools directory.

Installation starts:

1. Install mysql, first install the dependencies required for mysql through yum

yum -y install gcc gcc-c++ cmake ncurses-devel

2. Enter the mysql source code package directory

cd /php/tools/mysql

3. Unzip

tar -zxvf mysql-5.6.35.tar.gz

4. Enter the unzipped directory

cd mysql-5.6.35

5. Configuration

cmake 
-DCMAKE_INSTALL_PREFIX=/php/server/mysql 
-DMYSQL_DATADIR=/php/server/data 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci

6. Compile and install

make && make install

Related recommendations: "PHP Getting Started Tutorial"

7. Configure mysql

1. Copy the MySQL configuration file in the installation directory to /etc/my.cnf.

\cp -r /php/tools/mysql/mysql-5.6.35/support-files/my-default.cnf /etc/my.cnf

2. Modify the MySQL configuration file (declare the MySQL data storage directory)

vi  /etc/my.cnf

Set this line under [mysqld]: datadir = /php/server/data

3. Create a MySQL user group and create a user to join the user group

groupadd mysql
useradd -g mysql -s /sbin/nologin mysql

4. Initialize the database (executing the following command will generate a default database such as mysql/test in the data directory)

/php/server/mysql/scripts/mysql_install_db \
--basedir=/php/server/mysql \
--datadir=/php/server/data \
--user=mysql

Error report:

What are the steps to install the php source code package?

Install autoconf to solve the problem, and execute the above command again

yum -y install autoconf

5. Start the MySQL service (Note: & means background startup)

/php/server/mysql/bin/mysqld_safe --user=mysql &

6. Verify whether the MySQL service starts successfully (equivalent to win to view the process)

ps -A | grep mysql

7. Initialize the database and set the password of the root account (the default password is empty)

/php/server/mysql/bin/mysql -uroot -p
#回车输入密码,然后执行下述SQL语句

Delete test Database&& Delete the empty password account of the local anonymous connection

drop database test;                 
delete from mysql.user where user='';

Change password

update mysql.user set password=password('admin888') where user='root';
flush privileges;

Forgot password, force password change

1. Open the mysql configuration file

vi /etc/my.cnf

2. Add skip-grant-tables in the next line of [mysqld]

3. Restart the mysql service

4. Log in to mysql again (Because of the above operation, the password is empty at this time)

5. Change the password

6. Delete the mysql configuration file: my.cnf: skip-grant-tables

7. Restart the msyql service.

Install apache

1. Install zlib

shell> cd /php/tools/apache #进入tools目录
shell> tar zxvf zlib-1.2.5.tar.gz #解压zlib安装包
shell> cd zlib-1.2.5 #进入解压目录
shell> ./configure #这个配置编译命令不要加目录参数
shell> make && make install

2. Install apache

shell> cd /php/tools/apache #进入tools目录
shell> tar -jxvf httpd-2.2.19.tar.bz2 #解压apache安装包
shell> cd httpd-2.2.19 #进入解压目录
shell> #配置
./configure --prefix=/php/server/apache 
--enable-modules=all 
--enable-mods-shared=all 
--enable-so
shell> make && make install

If the decompression error is as follows, you need to install bzip2

tar (child): lbzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Installation command

yum -y install bzip2

Test

Modify the configuration file

vi /php/server/apache/conf/httpd.conf

Start service

/php/server/apache/bin/apachectl start/stop/restart

View

ps -A | grep httpd

Install PHP

shell> cd /php/tools/php
shell> tar -jxvf php-7.2.6.tar.bz2
shell> cd php-7.2.6
shell> #配置
./configure --prefix=/php/server/php 
--with-apxs2=/php/server/apache/bin/apxs 
--with-pdo-mysql=mysqlnd 
--with-mysqli=mysqlnd 
--with-zlib --enable-mbstring=all 
--enable-mbregex 
--enable-shared
shell>make && make install

Configuration if libxml2 error is reported

yum -y install libxml2 libxml2-devel

Configuration Apache supports PHP

1. Copy the php.ini configuration file to the specified directory

shell>  \cp -r /php/tools/php/php-7.2.6/php.ini-development /php/server/php/lib/php.ini

2. Modify the Apache configuration file (detect files ending in .php and hand them over to the php module for processing )

shell>  vi /php/server/apache/conf/httpd.conf

Add in httpd.conf (Apache main configuration file): AddType application/x-httpd-php .php

3, restart apache

/php/server/apache/bin/apachectl stop
/php/server/apache/bin/apachectl start

4, View the effect

shell>  echo &#39;<?php phpinfo();&#39; > /php/server/apache/htdocs/test.php

Management

1. mysql

[mysql configuration file]

/etc/my.cnf

[Enable mysql service]

/php/server/mysql/bin/mysqld_safe --user=mysql &amp;

【Close mysql service】

ps -A | grep mysql # 查看mysql进程
killall 服务名 #结束进程 关闭mysql服务

【Log in to MySQL database】

/php/server/mysql/bin/mysql -uroot -p

2. apache

/php/server/apache/bin/apachectl start
/php/server/apache/bin/apachectl stop
/php/server/apache/bin/apachectl restart

Configuration file: /php/server/apache/conf /httpd.conf

Optimization: Add apache and mysql as system services

1. Add apache service script

\cp -r /php/server/apache/bin/apachectl /etc/rc.d/init.d/httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd

2. Edit httpd Script, add the following comment information in the second line

vi /etc/rc.d/init.d/httpd

Comments to support chkconfig on RedHat Linux

chkconfig: 2345 90 90

description:http server

! Note the # comment

3. Modify the script to support chkconfig

chkconfig --add httpd
chkconfig --level 2345 httpd on

4. Restart the service

service httpd restart

Add MySQL to the service under CentOS

1. Copy the mysql.server file to the /etc/init.d/ directory and rename it to mysql

\cp -r /php/tools/mysql/mysql-5.6.35/support-files/mysql.server /etc/init.d/mysql

2. Give the mysql file "execution" permission&& Add to Run automatically at boot

chmod 755 /etc/init.d/mysql 
chkconfig --add mysql

3. Restart the service

service mysql restart

The above is the detailed content of What are the steps to install the php source code package?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn