Pull centos mirror
docker pull centos:7
Boot and enter the mirror
docker run -d --name centos7 --privileged=true centos:7 /usr/sbin/init
Enter the container:
docker exec -it centos7 /bin/bash
Install apache
yum -y install httpd
- Open apache service
systemctl start httpd.service
- Set the apache service to start at boot
systemctl enable httpd.service
Install php
yum -y install php
Restart apache service
systemctl restart httpd
Install MySQL
Because there is no mysql-server on the yum source.
So you must go to the official website to download. Here we use the wget command to get it directly.
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
Restart mysql after installation is complete
systemctl start mysql
The root user does not have a password for the first installation, and you can log in with the following command:
mysql -u root
Press Enter to set the msyql password to 111111 (or other)
mysql> set password for 'root'@'localhost' =password('111111');
Remote connection settings, all remote users connected with root account, set their password to 111111 (or other)
mysql> grant all privileges on *.* to root@'%'identified by '111111';
Update permissions
mysql>flush privileges;
Link PHP and MySQL
yum search php
Choose the installation you need:
yum -y install php-mysql
Install commonly used PHP modules
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
Restart apache service
systemctl restart httpd.service
Install gcc
yum install gcc*
yum -y install make
yum install php-devel
Install redis
yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum --enablerepo=remi install redis
service redis start
After redis is installed, let's check the related files created during redis installation, as follows:
rpm -qa |grep redis
rpm -ql redis
View the redis version:
redis-cli --version
Set to start automatically after booting:
systemctl enable redis.service
Redis opens remote login connection, redis can only be accessed by localhost by default, so remote login needs to be enabled. The solution is as follows:
In redis profile /etc/redis.conf in
We will bind 127.0.0.1 into a bind 0.0.0.0
Change daemonize no to daemonize yes
Add requirepass password
Test password after restarting the container
Upgrade php to 7.2: https://blog.csdn.net/qq_43737121/article/details/104824849
Install redis extension
1. Enter the software directory
cd /software
2. Download redis and unzip it to the current directory
wget http://pecl.php.net/get/redis-3.1.2.tgz
tar -zxvf redis-3.1.2.tgz
3. Enter the decompressed redis directory
cd redis-3.1.2
4. Use phpize to generate configure configuration files (where can you find your own phpize!)
/usr/bin/phpize
5. Configuration
./configure --with-php-config=/usr/bin/php-config
6, compile
make
7. Installation
make install
8. Edit php.ini
vim /etc/php.ini
Add extension = redis.so in php.ini;
3. View php extension results
php -m
10. Restart apache
systemctl restart httpd.service
11.Close MySQL
systemctl stop mysql
Exit the container
carried out
docker commit -a "name" -m "lamp redis" d4e92dc36c1b lamp_redis
The mirror of lamp+redis is ready
Create a container
docker run -itd --privileged -e "container=docker" --name name -v /var/www/html/fly:/var/www/html/fly -p 33306:3306 -p 89:80 -p 6380:6379 lamp_redis /usr/sbin/init /start.sh
The container is built