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?

爱喝马黛茶的安东尼
Release: 2023-02-23 13:40:01
Original
7461 people have browsed it

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
Copy after login

2. Enter the mysql source code package directory

cd /php/tools/mysql
Copy after login

3. Unzip

tar -zxvf mysql-5.6.35.tar.gz
Copy after login

4. Enter the unzipped directory

cd mysql-5.6.35
Copy after login

5. Configuration

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

6. Compile and install

make && make install
Copy after login

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
Copy after login

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

vi  /etc/my.cnf
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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

/php/server/mysql/bin/mysqld_safe --user=mysql &
Copy after login
Copy after login

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

ps -A | grep mysql
Copy after login

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语句
Copy after login

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

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

Change password

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

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
Copy after login

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
Copy after login

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
Copy after login

Installation command

yum -y install bzip2
Copy after login

Test

Modify the configuration file

vi /php/server/apache/conf/httpd.conf
Copy after login

Start service

/php/server/apache/bin/apachectl start/stop/restart
Copy after login

View

ps -A | grep httpd
Copy after login

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
Copy after login

Configuration if libxml2 error is reported

yum -y install libxml2 libxml2-devel
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

4, View the effect

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

Management

1. mysql

[mysql configuration file]

/etc/my.cnf
Copy after login

[Enable mysql service]

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

【Close mysql service】

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

【Log in to MySQL database】

/php/server/mysql/bin/mysql -uroot -p
Copy after login

2. apache

/php/server/apache/bin/apachectl start
/php/server/apache/bin/apachectl stop
/php/server/apache/bin/apachectl restart
Copy after login

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
Copy after login

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

vi /etc/rc.d/init.d/httpd
Copy after login

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
Copy after login

4. Restart the service

service httpd restart
Copy after login

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
Copy after login

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

chmod 755 /etc/init.d/mysql 
chkconfig --add mysql
Copy after login

3. Restart the service

service mysql restart
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template