第二步:打開VMware中的CentOS 7虛擬機,查看共享文件夾并進行掛載 [root@localhost ~]# smbclient -L //192.168.10.13/ //此處輸入自己宿主機的IP地址 Enter SAMBA/root's password: //此處直接回車 OS=[Windows 10 Home China 18362] Server=[Windows 10 Home China 6.3] Sharename Type Comment --------- ---- ------- ADMIN$ Disk 遠程管理 C$ Disk 默認共享 D$ Disk 默認共享 IPC$ IPC 遠程 IPC LAMP-test Disk //此處可以看到共享出來的文件夾 Connection to 192.168.0.103 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND) NetBIOS over TCP disabled -- no workgroup available [root@localhost ~]# ls /mnt/ //此時我們查看掛載是空的 [root@localhost ~]# mount.cifs //192.168.0.103/LAMP-test /mnt/ //把共享的文件掛載到mnt目錄下 Password for root@//192.168.0.103/LAMP-test: //此處直接回車 [root@localhost ~]# cd /mnt/ //進入mnt目錄 [root@localhost mnt]# ls //此時查看詳情就可以看到所有我們需要用到的壓縮包了 apr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11.tar.bz2 第三步:安裝Apache [root@localhost mnt]# yum install -y gcc gcc-c++ make pcre-devel expat-devel perl //安裝必要組件 [root@localhost mnt]# tar zxvf apr-1.6.2.tar.gz -C /opt/ [root@localhost mnt]# tar zxvf apr-util-1.6.0.tar.gz -C /opt/ [root@localhost mnt]# tar jxvf httpd-2.4.29.tar.bz2 -C /opt/ //解壓縮以上文件到opt目錄下 [root@localhost mnt]# cd /opt/ [root@localhost opt]# ls apr-1.6.2 apr-util-1.6.0 dis httpd-2.4.29 rh [root@localhost opt]# mv apr-1.6.2/ httpd-2.4.29/srclib/apr [root@localhost opt]# mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util [root@localhost opt]# cd /opt/httpd-2.4.29/ [root@localhost httpd-2.4.29]# ls ABOUT_APACHE buildconf httpd.dsp libhttpd.mak README.cmake acinclude.m4 CHANGES httpd.mak LICENSE README.platforms Apache-apr2.dsw CMakeLists.txt httpd.spec Makefile.in ROADMAP Apache.dsw config.layout include Makefile.win server apache_probes.d configure INSTALL modules srclib ap.d configure.in InstallBin.dsp NOTICE support build docs LAYOUT NWGNUmakefile test BuildAll.dsp emacs-style libhttpd.dep os VERSIONING BuildBin.dsp httpd.dep libhttpd.dsp README [root@localhost httpd-2.4.29]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi //安裝必要組件 [root@localhost httpd-2.4.29]# make [root@localhost httpd-2.4.29]# make install [root@localhost httpd-2.4.29]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd cp:是否覆蓋"/etc/init.d/httpd"? yes [root@localhost httpd-2.4.29]# vim /etc/init.d/httpd #!/bin/sh # chkconfig: 35 85 21 # description: Apache is a World Wide Web server //在#!/bin/sh下行插入這兩行內容,按Esc退出插入模式,按:wq保存退出 [root@localhost httpd-2.4.29]# chkconfig --add httpd [root@localhost httpd-2.4.29]# vim /usr/local/httpd/conf/httpd.conf 輸入/Server,找到:ServerName www.example.com:80 把前面的#號注釋刪除 輸入/Listen,查找80端口監聽,并開啟監聽本機的80端口:Listen 192.168.56.128: 80 按Esc退出插入模式,按:wq保存退出 [root@localhost httpd-2.4.29]# ln -s /usr/local/httpd/conf/httpd.conf /etc/ [root@localhost httpd-2.4.29]# ln -s /usr/local/httpd/bin/* /usr/local/bin/ //以上操作為創建軟鏈接 [root@localhost httpd-2.4.29]# systemctl stop firewalld.service [root@localhost httpd-2.4.29]# setenforce 0 //關閉防火墻及增強型安全功能 [root@localhost httpd-2.4.29]# httpd -t Syntax OK [root@localhost httpd-2.4.29]# service httpd start [root@localhost httpd-2.4.29]# netstat -ntuap | grep httpd tcp 0 0 192.168.56.128:80 0.0.0.0:* LISTEN 22697/httpd 第四步:安裝MySQL [root@localhost httpd-2.4.29]# cd ~ [root@localhost ~]# yum install -y ncurses-devel autoconf cmake //安裝必須組件 [root@localhost ~]# tar zxvf mysql-5.6.26.tar.gz -C /opt/ [root@localhost ~]# cd /opt/mysql-5.6.26/ [root@localhost mysql-5.6.26]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DSYSCONFDIR=/etc/ -DMYSQL_DATADIR=/home/mysql/ -DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock //安裝必須組件 [root@localhost mysql-5.6.26]# make [root@localhost mysql-5.6.26]# make install [root@localhost mysql-5.6.26]# cp support-files/my-default.cnf /etc/my.cnf cp:是否覆蓋"/etc/my.cnf"? yes [root@localhost mysql-5.6.26]# cp support-files/mysql.server /etc/init.d/mysqld cp:是否覆蓋"/etc/init.d/mysqld"? yes [root@localhost mysql-5.6.26]# cd /etc/init.d [root@localhost init.d]# ls functions httpd mysqld netconsole network README [root@localhost init.d]# chmod 755 mysqld [root@localhost init.d]# ls -ln 總用量 56 -rw-r--r--. 1 0 0 17500 5月 3 2017 functions -rwxr-xr-x. 1 0 0 3502 10月 18 22:45 httpd -rwxr-xr-x. 1 0 0 10870 10月 18 23:20 mysqld -rwxr-xr-x. 1 0 0 4334 5月 3 2017 netconsole -rwxr-xr-x. 1 0 0 7293 5月 3 2017 network -rw-r--r--. 1 0 0 1160 8月 5 2017 README [root@localhost init.d]# chkconfig --add /etc/init.d/mysqld [root@localhost init.d]# chkconfig --level 235 mysqld on [root@localhost init.d]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile [root@localhost init.d]# source /etc/profile [root@localhost init.d]# echo $PATH /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/root/bin:/usr/local/mysql/bin:/root/bin:/usr/local/mysql/bin [root@localhost init.d]# useradd -s /sbin/nologin mysql //創建用戶“mysql” [root@localhost init.d]# chown -R mysql:mysql /usr/local/mysql/ [root@localhost init.d]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --ldata=/var/lib/mysql --basedir=/usr/local/mysql --datadir=/home/mysql //安裝必要組件 [root@localhost init.d]# vim /etc/init.d/mysqld [root@localhost init.d]# service mysqld start Starting MySQL SUCCESS! [root@localhost init.d]# netstat -ntuap | grep mysqld tcp6 0 0 :::3306 :::* LISTEN 1310/mysqld [root@localhost init.d]# mysqladmin -u root -p password "abc123" //給root賬號設置新密碼 第五步:安裝PHP [root@localhost init.d]# cd ~ [root@localhost ~]# yum install -y gd libpng libpng-devel pcre pcre-devel libxml2-devel libjpeg-devel [root@localhost ~]# tar jxvf php-5.6.11.tar.bz2 -C /opt/ [root@localhost ~]# cd /opt/php-5.6.11/ [root@localhost php-5.6.11]# ./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring [root@localhost php-5.6.11]# make [root@localhost php-5.6.11]# make install [root@localhost php-5.6.11]# cp php.ini-development /usr/local/php5/php.ini cp:是否覆蓋"/usr/local/php5/php.ini"? yes [root@localhost php-5.6.11]# ln -s /usr/local/php5/bin/* /usr/local/bin/ [root@localhost php-5.6.11]# vim /etc/httpd.conf AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps //在上兩行下面插入下面兩行內容 DirectoryIndex index.php index.html //在DirectoryIndex和index.html中間添加index.php //按Esc退出插入模式,按:wq保存退出 [root@localhost php-5.6.11]# vim /usr/local/httpd/htdocs/index.php <?php phpinfo(); ?> //寫入以上內容,按Esc退出插入模式,按:wq保存退出 [root@localhost php-5.6.11]# service httpd restart 進入網頁進行測試(此處IP地址填寫的是安裝服務的CentOS 7的IP地址):http://192.168.56.128/index.php,如果配置成功因該出現如下界面:
LAMP架構 —(介紹及實戰)
第六步:安裝論壇組件并使用論壇 [root@localhost php-5.6.11]# cd ~ [root@localhost ~]# unzip Discuz_X2.5_SC_UTF8.zip -d /opt/Discuz [root@localhost ~]#cp -r /opt/Discuz/upload/ /usr/local/httpd/htdocs/bbs [root@localhost ~]#cd /usr/local/httpd/htdocs/bbs/ [root@localhost bbs]# chown -R daemon ./config/ [root@localhost bbs]# chown -R daemon ./data/ [root@localhost bbs]# chown -R daemon ./uc_client/data/cache/ [root@localhost bbs]# chown -R daemon ./uc_server/data/ [root@localhost bbs]# mysql -uroot -pabc123 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 1 Server version: 5.6.26 Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.