1. 安裝Mysql-5.6.40 軟體包存放目錄: /usr/local/src/ 1.切換到軟體包目錄操作 cd /usr/local/src/ 使用wget命令下載所需的編譯包 2.解壓操作 tar zxvf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz ...
1. 安裝Mysql-5.6.40
軟體包存放目錄:
/usr/local/src/
1.切換到軟體包目錄操作
cd /usr/local/src/
使用wget命令下載所需的編譯包
2.解壓操作
tar zxvf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
mkdir /usr/local/mysql #創建
- 註:查看是否有 /usr/local/mysql這個文件夾,
- 如果沒有請創建這個文件夾 mkdir /usr/local/mysql
cd mysql-5.6.43-linux-glibc2.12-x86_64
mv * /usr/local/mysql
將解壓出來的文件移到/usr/local/mysql文件夾內
mkdir -p /data/mysql
創建資料庫存放位置的文件夾
useradd -s /sbin/nologin mysql
3.創建mysql用戶,更改文件夾許可權
useradd mysql
groupadd mysql
chown -R mysql:mysql /data/mysql #更換所有者操作
4.安裝依賴操作
yum -y install perl-Module-Install
5.開始安裝mysql操作
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql #如果成功/data/mysql目錄下將會有文件和目錄
1.2 配置mysql
1.將mysql源碼包內的預設配置文件放入並命名 /etc/my.cnf
cd /usr/local/mysql cp support-files/my-default.cnf /etc/my.cnf
2.進入並修改/etc/my.cnf文件
vim /etc/my.cnf basedir = /usr/local/mysql # 源碼存放目錄 datadir = /data/mysql # 上文資料庫存放目錄 port = 3306 # 埠 server_id = 128 # 服務id socket = /tmp/mysql.sock # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M
3.複製文件,修改許可權,修改配置
cp support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld vim /etc/init.d/mysqld
修改:
datadir=/data/mysql
4.設置開機自啟和啟動服務
chkconfig --add mysqld
chkconfig mysqld on
service mysqld on
2. Apache-2.4.54
軟體包存放目錄:
/usr/local/src/
1.獲取並解壓源碼包
cd /usr/local/src wget http://....httpd-2.4.54.tar.gz wget http://....apr-1.7.0.tar.gz wget http://....apr-util-1.6.1.tar.gz tar zxvf httpd-2.4.54.tar.gz tar zxvf apr-1.7.0.tar.gz tar zxvf apr-util-1.6.1.tar.gz
2.安裝依賴包
yum -y install expat-devel libxml2-devel pcre pcre-devel
3.編譯並安裝apr
cd /usr/local/src/apr-1.7.0 ./configure --prefix=/usr/local/apr make && make install
4.編譯並安裝apr-util
cd /usr/local/src/apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install
5.編譯並安裝apache,如果安裝成功那麼/usr/local/apache2.4目錄下將會有文件和目錄
cd /usr/local/src/httpd-2.4.54 ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most make && make install
- 註:如果需要重新編譯,需要使用
- make clean
- 清除之前的緩存
3.PHP-5.6.40
軟體包存放目錄:
/usr/local/src/
1.獲取並解壓php源碼包
cd /usr/local/src wget http://...php-5.6.40.tar.gz tar zxvf php-5.6.40.tar.gz
獲取下麵的依賴包
yum -y install libxml2 openssl openssl-devel bzip2 bzip2-devel yum -y install libjpeg libjpeg-devel libpng libpng-devel
2.安裝依賴包
rpm -ivh freetype-2.8-14.el7_9.1.x86_64.rpm rpm -ivh freetype-devel-2.8-14.el7_9.1.x86_64.rpm rpm -ivh libmcrypt-2.5.8-13.el7.x86_64.rpm rpm -ivh libmcrypt-devel-2.5.8-13.el7.x86_64.rpm
3. 編譯並安裝
./configure -prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysq1=/usr/1ocal/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif make && make install
複製配置文件
cd /usr/local/src/php-5.6.40 cp php.ini-production /usr/local/php/etc/php.ini
4.進行結合
配置httpd支持php
修改
vim /usr/local/apache2.4/conf/httpd.conf
修改
#ServerName www.example.com:80 -> ServerName www.example.com:80 #去除註釋
進行刪除、添加、修改操作,並開啟apache
#添加 <Directory /> AllowOverride none Require all denied </Directory> -> <Directory /> AllowOverride none Require all granted </Directory> #修改 (在AddType application/x-gzip .gz .tgz 下) AddType application/x-httpd-php .php # 1.進入apache的配置文件並修改 <IfModule dir_module> DirectoryIndex index.html </IfModule> -> <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> # 2.檢驗apache配置文件是否正確,正確會顯示Syntax OK /usr/local/apache2.4/bin/apachectl -t # 3.開啟apache /usr/local/apache2.4/bin/apachectl start
檢測LAMP環境是否正確
1.檢查apache是否正確
curl localhost
2.檢查php是否正確
vim /usr/local/apache2.4/htdocs/test.php <?php echo"php 123";?>
輸出結果應為 123
curl localhost/test.php
3.檢查mysql是否正確
cd /usr/local/mysql/bin/
./mysql
lamp部署完畢
什麼才是真正的Think Different?