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:
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 '<?php phpinfo();' > /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 &
【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!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1
Easy-to-use and free code editor