Linux: LAMP construction (full source package installation)

LAMP is    Linux A pache    M ysql    P HP    / P ython

Table of contents

Linux installation

 Apache installation

Mysql installation

Install PHP

Install the PHP extension package 

Compile and install PHP

PHP add optimization module

Test web pages working together


Linux installation

virtual machine installation

(1 message) VMware: install centos7_Bao Haichao-GNUBHCkalitarro's Blog-CSDN Blog

Real machine installation

(1 message) linux: install centos linux on the real machine (emergency: solve the problem of getting stuck on the installation interface) {Look for mirror image--uqi production--boot disk--solve the problem of getting stuck in the installation interface--installation configuration}_Installation centos7 stuck in the installation interface_Bao Haichao-GNUBHCkalitarro's Blog-CSDN Blog


 Apache installation

(1 message) Linux: http service (Apache 2.4.57) source code compilation——configure website  ||

 Just need to access the website through ip, the following control access and virtual host are not needed


Mysql installation

Prepare two source packages of cmake and mysql 

Install an operating environment first

 yum -y install ncurses-devel gcc-c++ perl*

Unzip cmake and configure the installation 

tar zxvf /root/cmake-2.8.6.tar.gz -C /usr/src/

cd /usr/src/cmake-2.8.6

./configure && gmake && gmake install

After configuring cmake, unzip mysql

tar zxvf /root/mysql-5.6.36.tar.gz -C /usr/src/

cd /usr/src/mysql-5.6.36/

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc/

make &&make install

# The last step is very long and will take a while, wait patiently, if you finish it soon, could it be that you used a supercomputer? If it’s not a super calculation, then check the above configuration to see which step is wrong

rm -rf /etc/my.cnf

cp /usr/src/mysql-5.6.36/support-files/my-default.cnf /etc/my.cnf

cp /usr/src/mysql-5.6.36/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

echo "export PATH=$PATH:/usr/local/mysql/bin"  >>/etc/profile

#Optimize the PATH path, it is convenient to execute the command, single quotes and double quotes are fine

source /etc/profile

#executable file

#Initialize mysql, create users, empower 

useradd -M -s /sbin/nologin mysql

chown -R mysql:mysql /usr/local/mysql

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

/etc/init.d/mysqld start

chkconfig mysqld on

 Open successfully 

mysql -u root

There is no password to enter the mysql database by default

mysqladmin -u root password '123'

# Set password for root

mysql -u root -p

# Enter password to log in


Install PHP

Install the operating environment

yum install -y libxml2 libxml2-devel zlib-devel  


Install the PHP extension package 

In the actual environment, you need to install data encryption tools libmcrypt, mhash, mcrypt

tar zxf libmcrypt-2.5.8.tar.gz 

cd libmcrypt-2.5.8/

./configure && make && make install

cd

ln -s /usr/local/lib/libmcrypt.* /usr/lib/

tar zxf mhash-0.9.9.9.tar.gz 

cd mash-0.9.9.9/

./configure 

make && make install

ln -s /usr/local/lib/libmhash.* /usr/lib/

cd

tar zxf mcrypt-2.6.8.tar.gz 

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

cd mcrypt-2.6.8/

./configure

make && make install

cd


Compile and install PHP

 Prepare a php source package

 tar zxf php-5.5.38.tar.gz -C /usr/src/

cd /usr/src/php-5.5.38/

./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring

make && make install

cd /usr/src/php-5.5.38/

cp php.ini-development /usr/local/php5/php.ini

vim /usr/local/php5/php.ini 

The content inside is the number of lines on the top and the statement of the control parameters below. 

Lines 680 and 873 must be changed, others are free

189
engine = On

202
short_open_tag = On [Allow recognition of PHP short syntax tags] [Lowercase cannot be read,]

206
asp_tags = Off

660
post_max_size = 8M [number submitted through the form]

680
default_charset = "utf-8" [default character set]

783
file_uploads = On [PHP web page upload file]

792
upload_max_filesize = 2M 【upload file size】
max_file_uploads = 20 【upload file quantity】

873
extension=php_mysqli.dll add mysql support

take the front; remove


PHP add optimization module

The zend-loader module can speed up web page access, if you don't need it, you can skip it here

 tar zxf zend-loader-php5.5-linux-x86_64_update1.tar.gz -C /usr/src

cd /usr/src/zend-loader-php5.5-linux-x86_64/

cp ZendGuardLoader.so /usr/local/php5/lib/php/

vim /usr/local/php5/php.ini

# Add at the bottom

zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1

 vim /usr/local/httpd/conf/httpd.conf

# Load PHP program module line 159

LoadModule php5_module   modules/libphp5.so

#[This line must already exist, otherwise PHP needs to be reinstalled]
 

Add index support

261 <IfModule dir_module>
262     DirectoryIndex index.html index.php
263 </IfModule>

Support .php webpage files [this line is manually added]
266 AddType application/x-httpd-php .php

 /usr/local/httpd/bin/apachectl   restart


Test web pages working together

 cd /usr/local/httpd/htdocs/

vim qqq.php

Edit content:

<?php
phpinfo();
?>

vim www.php

edit content

<?php
$link=mysqli_connect('localhost','root','123');                
if($link) echo "Congratulations, the database connection is successful!";                   
mysqli_close($link);                                                   
?>

 /usr/local/httpd/bin/apachectl   restart

Guess you like

Origin blog.csdn.net/w14768855/article/details/131353176