目錄php
課程目標html
請耐心閱讀,細心操做,你也會成功!node
思考:yum工具搭建lamp環境和源碼包搭建的區別mysql
rpm版本web
安裝方便,升級、卸載都很靈活,很難或者沒法定製主要組件的功能,適合批量部署sql
源碼包編譯shell
根據業務需求定製,前提是必須對平臺的功能須要很是瞭解:卸載、升級、安裝並非很方便靈活數據庫
生產環境如何作apache
共享文件夾/LAMP下 apr-1.5.2.tar.bz2 apr-util-1.5.4.tar.bz2 httpd-2.4.12.tar.bz2 php-5.6.11.tar.xz mysql-5.6.25.tar.gz http://archive.apache.org/dist/ https://www.php.net/releases/
清空環境,安裝相應的軟件包 yum -y groupinstall "Development tools" yum -y groupinstall "Desktop Platform Development" 桌面開發工具包(圖形化相關包) yum install cmake yum install ncurses-devel
Apache-->MySQL-->php 或者 MySQL-->Apache-->php 說明: 1.apache必需要先於PHP安裝,由於PHP是做爲apache的模塊libphp.so,被apache加載調用 2.apache和MySQL之間並無直接前後順序的依賴,誰先誰後無所謂 3.在PHP-5.3版本前,MySQL必須先於php的編譯,由於PHP須要實現鏈接數據庫的功能,它經過MySQL的接口才能編譯出該功能 4.在PHP-5.3版本或者以後,PHP已經集成了一套鏈接MySQL數據的代碼,並不依賴MySQL的接口,這時,MySQL和PHP的編譯順序也就無所謂了
版本:mysql-5.6.25.tar.gz 需求: 1.安裝目錄:/mysql25/mysql_basedir 2.數據目錄:/mysql25/data 3.端口:3307(默認3306) 4.socket:/mysql25/mysql_basedir 安裝: 1.官方網站下載相應軟件包 2.解壓 3.安裝 1)建立相應的目錄和用戶並受權 [root@lamp ~]# cd /LAMP/ [root@lamp LAMP]# ll total 32428 -rwxr-xr-x 1 root root 33203321 Apr 29 18:06 mysql-5.6.25.tar.gz [root@lamp LAMP]# tar -xf mysql-5.6.25.tar.gz -C /usr/src/ [root@lamp LAMP]# ls /usr/src debug kernels mysql-5.6.25 [root@lamp LAMP]# mkdir -p /mysql25/mysql_basedir [root@lamp LAMP]# mkdir /mysql25/data [root@lamp LAMP]# id mysql id: mysql: No such user //-r建立一個系統用戶,-s指定默認的shell /sbin/nologin 不能像其餘用戶同樣登陸操做系統 [root@lamp LAMP]# useradd -r mysql -s /sbin/nologin [root@lamp LAMP]# su - mysql su: warning: cannot change directory to /home/mysql: No such file or directory This account is currently not available. [root@lamp LAMP]# id mysql uid=496(mysql) gid=493(mysql) groups=493(mysql) [root@lamp LAMP]# ll -d /mysql25/ drwxr-xr-x 4 root root 4096 Apr 29 18:32 /mysql25/ [root@lamp LAMP]# chown -R mysql.mysql /mysql25/ 更改屬主和屬組爲mysql [root@lamp LAMP]# ll -d /mysql25/ drwxr-xr-x 4 mysql mysql 4096 Apr 29 18:32 /mysql25/ [root@lamp LAMP]# ll /mysql25/ total 8 drwxr-xr-x 2 mysql mysql 4096 Apr 29 18:32 data drwxr-xr-x 2 mysql mysql 4096 Apr 29 18:32 mysql_basedir 2)進入到解壓後的路徑進行安裝 [root@lamp ~]# cd /usr/src/mysql-5.6.25/ [root@lamp mysql-5.6.25]# pwd /usr/src/mysql-5.6.25 根據需求配置: 查看官方文檔 https://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html vim /usr/src/mysql-5.6.25 cmake . \ -DCMAKE_INSTALL_PREFIX=/mysql25/mysql_basedir/ \ -DMYSQL_DATADIR=/mysql25/data \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DSYSCONFDIR=/mysql25/mysql_basedir/etc \ -DMYSQL_TCP_PORT=3307 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS=all \ -DMYSQL_USER=mysql 編譯: make 安裝: make install 總結: 1.配置的時候,指定安裝的路徑,該路徑能夠存在也能夠不存在,建議事先建立而且更改權限chown 2.系統默認自動建立,權限是root,須要本身更改 後續配置:(官方文檔。。。2.2) shell> scripts/mysql_install_db --user=mysql 默認初始化數據庫到/var/lib/mysql shell> bin/mysqld_safe --user=mysql & 啓動mysql,&放在後臺執行 # Next command is optional shell> cp support-files/mysql.server /etc/init.d/mysql.server [root@lamp mysql_basedir]# scripts/mysql_install_db --user=mysql --basedir=/mysql25/mysql_basedir/ --datadir=/mysql25/data/ [root@lamp mysql_basedir]# ll /mysql25/data/ total 110604 -rw-rw---- 1 mysql mysql 12582912 Apr 30 14:30 ibdata1 -rw-rw---- 1 mysql mysql 50331648 Apr 30 14:30 ib_logfile0 -rw-rw---- 1 mysql mysql 50331648 Apr 30 14:30 ib_logfile1 drwx------ 2 mysql mysql 4096 Apr 30 14:30 mysql drwx------ 2 mysql mysql 4096 Apr 30 14:30 performance_schema drwx------ 2 mysql mysql 4096 Apr 30 14:30 test 初始化成功 嘗試啓動 [root@lamp mysql_basedir]# bin/mysqld_safe --user=mysql 190430 14:34:18 mysqld_safe Logging to '/var/log/mysqld.log'. 190430 14:34:18 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 190430 14:34:21 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 發現問題,查看日誌解決 [root@lamp ~]# tail -f /var/log/mysqld.log 2019-04-30 14:35:04 2798 [ERROR] /mysql25/mysql_basedir/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory) 2019-04-30 14:35:04 2798 [ERROR] Can't start server: can't create PID file: No such file or directory 190430 14:35:04 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended [root@lamp mysql_basedir]# ll /var/lib/mysql/ total 110596 -rw-rw---- 1 mysql mysql 56 Apr 30 14:34 auto.cnf -rw-rw---- 1 mysql mysql 12582912 Apr 30 14:34 ibdata1 -rw-rw---- 1 mysql mysql 50331648 Apr 30 14:35 ib_logfile0 -rw-rw---- 1 mysql mysql 50331648 Apr 30 14:34 ib_logfile1 srwxrwxrwx 1 mysql mysql 0 Apr 30 14:35 mysql.sock 發現mysql.sock又寫入到/var/lib/mysql/裏了,那麼問題應該是環境沒有清理乾淨 [root@lamp mysql_basedir]# ls /etc/my.cnf /etc/my.cnf [root@lamp mysql_basedir]# rpm -qf /etc/my.cnf 果真發現5.1版本存在 mysql-libs-5.1.71-1.el6.x86_64 [root@lamp mysql_basedir]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [root@lamp mysql_basedir]# bin/mysql --help Default options are read from the following files in the given order: 讀取順序 /etc/my.cnf /etc/mysql/my.cnf /mysql25/mysql_basedir/etc/my.cnf ~/.my.cnf 發現/etc/my.cnf優先讀取 總結: 在啓動數據庫時,默認會到/var/lib/mysql裏去找相應文件,系統有一個默認的配置文件/etc/my.cnf,在該文件中定義了數據目錄/var/lib/mysql 解決: 1.刪除/etc/my.cnf 2.修改/etc/my.cnf 清空/var/lib/mysql/* 再次啓動,進行驗證 [root@lamp ~]# ps -ef|grep mysql root 2883 2329 0 14:49 pts/0 00:00:00 /bin/sh bin/mysqld_safe --user=mysql mysql 2973 2883 1 14:49 pts/0 00:00:00 /mysql25/mysql_basedir/bin/mysqld --basedir=/mysql25/mysql_basedir --datadir=/mysql25/data --plugin-dir=/mysql25/mysql_basedir/lib/plugin --user=mysql --log-error=/mysql25/data/lamp.err --pid-file=/mysql25/data/lamp.pid root 2999 2827 0 14:50 pts/1 00:00:00 grep mysql [root@lamp ~]# netstat -nltp|grep 3307 tcp 0 0 :::3307 :::* LISTEN 2973/mysqld 順利啓動 [root@lamp ~]# pkill -9 mysqld 結束mysqld 若是但願使用service方式啓動mysql,能夠作以下配置 [root@lamp mysql_basedir]# cp support-files/mysql.server /etc/init.d/mysql25 [root@lamp mysql_basedir]# vim /etc/init.d/mysql25 此處無需修改 [root@lamp mysql_basedir]# netstat -nltp|grep 3307 [root@lamp mysql_basedir]# service mysql25 start Starting MySQL [ OK ] [root@lamp mysql_basedir]# netstat -nltp|grep 3307 tcp 0 0 :::3307 :::* LISTEN 3133/mysqld 登陸驗證: [root@lamp mysql_basedir]# bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.25 Source distribution 更改環境變量,以便用mysql直接登陸 臨時更改: [root@lamp mysql_basedir]# echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin [root@lamp mysql_basedir]# export PATH=/mysql25/mysql_basedir/bin:$PATH [root@lamp mysql_basedir]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.25 Source distribution 永久更改: [root@lamp ~]# vim /etc/profile 。。。在文件最後增長如下 export PATH=/mysql25/mysql_basedir/bin:$PATH [root@lamp ~]# source /etc/profile 從新讀取配置文件 設置密碼: [root@lamp ~]# mysqladmin -uroot password '123' Warning: Using a password on the command line interface can be insecure. [root@lamp ~]# mysql -uroot -p123
https://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html 官方文檔vim
https://dev.mysql.com/doc/refman/5.6/en/binary-installation.html通用二進制命令安裝(後續配置參照)
rpm -q httpd rpm -e httpd --nodeps 先清空環境(卸載2.2版本)
說明:
在RHEL6.5下直接編譯apache的2.4版本,會報下面的錯誤:
checking for APR... configure: WARNING: APR version 1.4.0 or later is required,found 1.3.9 configure: WARNING: skipped APR at apr-1-config, version not acceptable 緣由:表示系統自帶的apr軟件版本爲1.3.9,但須要1.4.0以上的版本 解決方法: 第一種:把apache降爲2.2系列 第二種:去下載新版本apr先編譯,再編譯apache調用它(選擇第二種)
安裝apr軟件 [root@lamp LAMP]# ll total 50156 -rwxr-xr-x 1 root root 826885 Apr 30 16:57 apr-1.5.2.tar.bz2 -rwxr-xr-x 1 root root 694427 Apr 30 16:57 apr-util-1.5.4.tar.bz2 -rwxr-xr-x 1 root root 5054838 Apr 30 16:57 httpd-2.4.12.tar.bz2 -rwxr-xr-x 1 root root 33203321 Apr 29 18:06 mysql-5.6.25.tar.gz -rwxr-xr-x 1 root root 11569588 Apr 30 16:57 php-5.6.11.tar.xz [root@lamp LAMP]# cd [root@lamp ~]# [root@lamp ~]# cd /LAMP/ [root@lamp LAMP]# ll total 50156 -rwxr-xr-x 1 root root 826885 Apr 30 16:57 apr-1.5.2.tar.bz2 -rwxr-xr-x 1 root root 694427 Apr 30 16:57 apr-util-1.5.4.tar.bz2 -rwxr-xr-x 1 root root 5054838 Apr 30 16:57 httpd-2.4.12.tar.bz2 -rwxr-xr-x 1 root root 33203321 Apr 29 18:06 mysql-5.6.25.tar.gz -rwxr-xr-x 1 root root 11569588 Apr 30 16:57 php-5.6.11.tar.xz [root@lamp LAMP]# tar -xf apr-1.5.2.tar.bz2 -C /usr/src/ [root@lamp LAMP]# tar -xf apr-util-1.5.4.tar.bz2 -C /usr/src/ [root@lamp LAMP]# cd /usr/src/ [root@lamp src]# ll total 20 drwxr-xr-x 27 1000 1000 4096 Apr 25 2015 apr-1.5.2 drwxr-xr-x 19 1000 1000 4096 Sep 17 2014 apr-util-1.5.4 drwxr-xr-x. 2 root root 4096 Sep 23 2011 debug drwxr-xr-x. 3 root root 4096 Apr 18 21:18 kernels drwxr-xr-x 35 7161 wheel 4096 Apr 29 22:14 mysql-5.6.25 [root@lamp src]# cd apr-1.5.2/ [root@lamp apr-1.5.2]# ls apr-config.in build-outputs.mk helpers misc strings apr.dep CHANGES include mmap support apr.dsp CMakeLists.txt libapr.dep network_io tables apr.dsw config.layout libapr.dsp NOTICE test apr.mak configure libapr.mak NWGNUmakefile threadproc apr.pc.in configure.in libapr.rc passwd time apr.spec docs LICENSE poll tools atomic dso locks random user build emacs-mode Makefile.in README buildconf encoding Makefile.win README.cmake build.conf file_io memory shmem [root@lamp apr-1.5.2]# ./configure [root@lamp apr-1.5.2]# make [root@lamp apr-1.5.2]# make install 默認安裝到/usr/local /usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config 配置apr-util-1.5.4 [root@lamp apr-1.5.2]# cd .. [root@lamp src]# ls apr-1.5.2 apr-util-1.5.4 debug kernels mysql-5.6.25 [root@lamp src]# cd apr-util-1.5.4/ [root@lamp apr-util-1.5.4]# ./configure --with-apr=/usr/local/apr/bin/apr-1-config [root@lamp apr-util-1.5.4]# make [root@lamp apr-util-1.5.4]# make install Libraries have been installed in: /usr/local/apr/lib /usr/bin/install -c -m 755 apu-config.out /usr/local/apr/bin/apu-1-config 如下操做配置庫文件的默認檢索路徑 [root@lamp apr-util-1.5.4]# cat /etc/ld.so.conf include ld.so.conf.d/*.conf [root@lamp apr-util-1.5.4]# ll /etc/ld.so.conf.d/ total 20 -r--r--r--. 1 root root 324 Nov 22 2013 kernel-2.6.32-431.el6.x86_64.conf -rw-r--r--. 1 root root 17 Nov 23 2013 mysql-x86_64.conf -rw-r--r--. 1 root root 22 Sep 24 2011 qt-x86_64.conf -rw-r--r-- 1 root root 276 Apr 29 17:37 vmware-tools-libraries.conf -rw-r--r--. 1 root root 21 Oct 30 2013 xulrunner-64.conf [root@lamp apr-util-1.5.4]# cat /etc/ld.so.conf.d/mysql-x86_64.conf /usr/lib64/mysql [root@lamp apr-util-1.5.4]# echo /usr/local/apr/lib/ > /etc/ld.so.conf.d/lamp.conf [root@lamp apr-util-1.5.4]# ldconfig [root@lamp apr-util-1.5.4]# cat /etc/ld.so.conf.d/lamp.conf /usr/local/apr/lib/
思考:一個軟件的庫文件是有可能被其餘軟件所調用,那麼其餘軟件可否找到你的庫文件呢?
通常來講,庫文件安裝到/lib,/lib64,/usr/lib/,/usr/lib64等,均可以找到:可是若是一個軟件A把庫文件安裝到/usr/local/A/lib下,就要把這個路徑添加到 ldconfig 命令能夠找到的路徑列表裏去,別人才能找到。
ldconfig是一個動態連接庫管理命令:主要用途是在默認搜索目錄(/lib,/lib64,/usr/lib/,/usr/lib64/)
一級動態庫配置文件/etc/ld.so.conf中所列的目錄中搜索出可共享的動態連接庫。
問題:怎樣將庫文件的指定安裝路徑加入到 ldconfig命令的搜索列表中?
方法1:在/etc/ld.so.conf這個主配置文件裏面加上一行,寫上讓別人要查找庫文件的路徑 方法2:在/etc/ld.so.conf.d/目錄下建立一個*.conf結尾的文件,裏面加入該路徑便可 echo /usr/local/apr/lib/ > /etc/ld.so.conf.d/lamp.conf ldconfig 加入該路徑後,使用此命令讓其生效
版本:httpd-2.4.12.tar.bz2 1.下載 http://archive.apache.org/dist/ 2.解壓 3.安裝(解壓的目錄裏) [root@lamp ~]# cd /LAMP/ [root@lamp LAMP]# ls apr-1.5.2.tar.bz2 httpd-2.4.12.tar.bz2 php-5.6.11.tar.xz apr-util-1.5.4.tar.bz2 mysql-5.6.25.tar.gz [root@lamp LAMP]# tar -xf httpd-2.4.12.tar.bz2 -C /usr/src/ [root@lamp LAMP]# cd /usr/src/ [root@lamp src]# ls apr-1.5.2 apr-util-1.5.4 debug httpd-2.4.12 kernels mysql-5.6.25 [root@lamp src]# cd httpd-2.4.12/ [root@lamp httpd-2.4.12]# ls ABOUT_APACHE CHANGES INSTALL os acinclude.m4 CMakeLists.txt InstallBin.dsp README Apache-apr2.dsw config.layout LAYOUT README.cmake Apache.dsw configure libhttpd.dsp README.platforms apache_probes.d configure.in LICENSE ROADMAP ap.d docs Makefile.in server build emacs-style Makefile.win srclib BuildAll.dsp httpd.dsp modules support BuildBin.dsp httpd.spec NOTICE test buildconf include NWGNUmakefile VERSIONING [root@lamp httpd-2.4.12]# 配置: ./configure \ --enable-modules=all \ --enable-mods-shared=all \ --enable-so \ --enable-rewrite \ --with-mpm=prefork \ --with-apr=/usr/local/apr/bin/apr-1-config \ --with-apr-util=/usr/local/apr/bin/apu-1-config [root@lamp httpd-2.4.12]# vim apache.sh [root@lamp httpd-2.4.12]# chmod +x apache.sh [root@lamp httpd-2.4.12]# cat apache.sh ./configure \ --enable-modules=all \ --enable-mods-shared=all \ --enable-so \ --enable-rewrite \ --with-mpm=prefork \ --with-apr=/usr/local/apr/bin/apr-1-config \ --with-apr-util=/usr/local/apr/bin/apu-1-config [root@lamp httpd-2.4.12]# ./apache.sh 報錯 checking for pcre-config... false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ [root@lamp httpd-2.4.12]# yum list|grep pcre 檢查有沒有pcre pcre.x86_64 7.8-6.el6 @anaconda-CentOS-201311272149.x86_64/6.5 已安裝 mingw32-pcre.noarch 8.10-2.el6.5 local-yum pcre.i686 7.8-6.el6 local-yum pcre-devel.i686 7.8-6.el6 local-yum pcre-devel.x86_64 7.8-6.el6 local-yum pcre-static.x86_64 7.8-6.el6 local-yum 發現已安裝,那麼問題是pcre-devel沒有安裝 [root@lamp httpd-2.4.12]# yum -y install pcre-devel 安裝以後再次執行配置腳本apache.sh [root@lamp httpd-2.4.12]# ./apache.sh [root@lamp httpd-2.4.12]# make [root@lamp httpd-2.4.12]# make install [root@lamp httpd-2.4.12]# ls /usr/local/apache2/ bin cgi-bin error icons logs manual build conf htdocs include man modules
配置說明:
# ./configure \ --enable-modules=all \ 加載全部支持模塊 --enable-mods-shared=all \ 共享方式加載大部分經常使用模塊 --enable-so \ 啓用動態模塊加載功能 --enable-rewrite \ 啓用地址重寫功能 --with-mpm=prefork \ 插入式並行處理模塊,稱爲多路處理模塊,Prefork是類UNIX平臺上默認的MPM --with-apr=/usr/local/apr/bin/apr-1-config \ 指定依賴軟件apr路徑 --with-apr-util=/usr/local/apr/bin/apu-1-config # make # make install # ls /usr/local/apache2/ 確認這個目錄產生後,說明編譯安裝成功
版本:php-5.6.11.tar.xz 1.下載 https://www.php.net/releases/ 2.解壓 [root@lamp httpd-2.4.12]# cd /LAMP/ [root@lamp LAMP]# ls apr-1.5.2.tar.bz2 httpd-2.4.12.tar.bz2 php-5.6.11.tar.xz apr-util-1.5.4.tar.bz2 mysql-5.6.25.tar.gz [root@lamp LAMP]# tar -xf php-5.6.11.tar.xz -C /usr/src/ [root@lamp LAMP]# cd /usr/src [root@lamp src]# ls apr-1.5.2 debug kernels php-5.6.11 apr-util-1.5.4 httpd-2.4.12 mysql-5.6.25 [root@lamp src]# cd php-5.6.11/ [root@lamp php-5.6.11]# pwd /usr/src/php-5.6.11 3.安裝(在解壓目錄裏) 1)配置 [root@lamp php-5.6.11]# vim php.sh [root@lamp php-5.6.11]# chmod +x php.sh [root@lamp php-5.6.11]# ./php.sh ./php.sh: line 5: --with-mysqli=/mysql25/mysql_basedir/bin/mysql_config: No such file or directory ./php.sh: line 7: --with-zlib: command not found ./php.sh: line 26: --enable-calender: command not found 檢查腳本文件的書寫是否有誤,通常都是由於 轉義換行的\沒加,致使下面的錯誤 Thank you for using PHP. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands 2)編譯 [root@lamp php-5.6.11]# make Build complete. Don't forget to run 'make test' 3)安裝 [root@lamp php-5.6.11]# make install [root@lamp php-5.6.11]# ls /usr/local/apache2/modules/libphp5.so /usr/local/apache2/modules/libphp5.so
配置說明:
# ./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=/usr/local/mysql/ \ 要改爲自定義的目錄 /mysql25/mysql_basedir --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-pdo-mysql=/usr/local/mysql \ 連接mysql模塊 --with-zlib \ --with-zlib-dir=/usr/local/mysql/zlib \ 數據壓縮用的函數庫 --with-curl \ --enable-zip \ --with-gd \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --enable-opcache \ --enable-mbstring \ --enable-mbregex \ --enable-pcntl \ --enable-shmop \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm --enable-calendar \ --enable-bcmath \ with-apxs2 調用apache加載模塊支持PHP gd 畫圖庫 libiconv 字符變換轉換 libmcrypt 字符加密 mcrypt 字符加密 mhash 哈希運算 make //make成功後,會顯示讓你make test,不用作 make install ls /usr/local/apache2/modules/libphp5.so 確認有這個.so模塊文件,就表示編譯PHP成功
# ./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=/mysql25/mysql_basedir \ --with-mysqli=/mysql25/mysql_basedir/bin/mysql_config \ --with-pdo-mysql=/mysql25/mysql_basedir \ --with-zlib \ --with-zlib-dir=/mysql25/mysql_basedir/zlib \ --with-curl \ --enable-zip \ --with-gd \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --enable-opcache \ --enable-mbstring \ --enable-mbregex \ --enable-pcntl \ --enable-shmop \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-calendar \ --enable-bcmath \
參考https://www.jianshu.com/p/0a79847c8151
https://www.cnblogs.com/fps2tao/p/7884011.html
1.修改apache配置文件 # vim /usr/local/apache2/conf/httpd.conf 1>配置優先支持中文 LoadModule negotiation_modules/mod_negotiation.so 此模塊打開註釋 Include conf/extra/httpd-languages.conf 打開此選項,擴展配置文件就生效了 # vim /usr/local/apache2/conf/extra/httpd-languages.conf 修改子配置文件 DefaultLanguage zh-CN 打開註釋,默認語言集改成中文 (可無) LanguagePriority zh-CN en ca ...語言及優先集,把zh-CN寫到前面 2>配置apache對php支持 也就是apache和php的聯繫 # vim /usr/local/apache2/conf/httpd.conf LoadeModule php5_module modules/libphp5.so 找這一句,在這句下面加上兩句 AddHandler php5-script .php 添加兩行,告訴httpd把.php文件交給模塊去編譯 AddType text/html .php 這兩句的意思是以.php結尾的文件都認爲是php程序文件,注意這兩句的.php前面都是有一個空格的 3>默認主頁加上index.php,並放在index.html前,支持php的首頁文件 <IfModule dir_module> DirectoryIndex index.php index.html </IfModule> 4>配置網站家目錄 (此處暫不配置) DocumentRoot "/web" 默認:/usr/local/apache2/htdocs/index.php 到第九節配置虛擬主機 [root@lamp ~]# vim /usr/local/apache2/conf/httpd.conf # Virtual hosts Include conf/extra/httpd-vhosts.conf
說明:
本地數據庫通常是經過socket文件連接,而本地數據庫的socket文件若是不在默認路徑,就必須告訴php從哪裏讀取socket文件。
# cp /usr/src/php-5.6.11/php.ini-production /usr/local/lib/php.ini vim /usr/local/lib/php.ini ... [MySQL] mysql.default_port=3307 mysql.default_socket = /mysql25/mysql_basedir [MySQLi] mysql.default_port=3307 mysql.default_socket = /mysql25/mysql_basedir
要跟隨環境 DocumentRoot "/usr/local/apache2/htdocs" [root@lamp ~]# cd /usr/local/apache2/htdocs [root@lamp htdocs]# ls index.html [root@lamp htdocs]# mv index.html index.php [root@lamp htdocs]# vim index.php <?php phpinfo(); ?>
啓動數據庫 啓動apache [root@lamp htdocs]# /usr/local/apache2/bin/apachectl start AH00557: httpd: apr_sockaddr_info_get() failed for lamp AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message [root@lamp htdocs]# netstat -nltp|grep 80 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1803/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1380/cupsd tcp 0 0 :::80 :::* LISTEN 3492/httpd 看到下圖就表示lamp的編譯安裝和基本配置成功。
假設有一個軟件aaa,安裝到/usr/local和安裝到/usr/local/aaa之間的區別?
搭建Discuz論壇 Discuz_X3.2_SC_UTF8.zip Discuz論壇 phpwind_v9.0.1_utf8.zip wind論壇 phpMyAdmin-4.4.11-all-language.zip php寫的mysql的管理工具(相似oracle的OEM) wordpress-4.7.3-zh_CN.tar.gz 博客 需求: 搭建2個網站,一個我的博客,一個是web界面管理mysql數據庫的應用 步驟: 1.建立兩個目錄來分別存放不一樣的網站 apache2.4版本用戶爲 User daemon Group daemon mkdir /webserver/{admin,myblog} -p 2.拷貝網站相關的數據到網站目錄裏 unzip phpMyAdmin-4.4.11-all-languages.zip -d /usr/src/ tar xf wordpress-4.7.3-zh_CN.tar.gz -C /usr/src cd phpMyAdmin-4.4.11-all-languages/ ls cp -a ./* /webserver/admin/ cd .. cp -a wordpress/* /webserver/myblog/ 修改權限 chown -R daemon. /webserver 3.經過虛擬主機將網站發佈出去 虛擬主機: # vim /usr/local/apache2/conf/extra/httpd-vhosts.conf <VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/webserver/admin" ServerName www.mysqladmin.cc # ServerAlias www.dummy-host.example.com ErrorLog "logs/dummy-host.example.com-error_log" CustomLog "logs/dummy-host.example.com-access_log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/webserver/myblog" ServerName www.myblog.net ErrorLog "logs/dummy-host2.example.com-error_log" CustomLog "logs/dummy-host2.example.com-access_log" common </VirtualHost> 打開主配置文件裏面的模塊 [root@lamp ~]# vim /usr/local/apache2/conf/httpd.conf # Virtual hosts Include conf/extra/httpd-vhosts.conf 去掉註釋 4.重啓服務 /usr/local/apache2/bin/apachectl start 5.測試驗證 出現403錯誤,首先查看目錄權限都是daemon,接着查看主配置文件,修改以下 <Directory /> AllowOverride none #Require all denied 版本緣由,2.4的apache目錄拒絕全部人訪問 Require all granted </Directory> 重啓服務後從新測試 phpwind論壇: # cp -a phpMyAdmin-4.0.2-all-language/* /webserver/bbswind # cd /webserver/bbswind # mv config.sample.inc.php config.inc.php $cfg['blowfish_secret']='a8sfdfkjsafaf';隨便修改 。。。 $cfg['Servers'][$i]['host'] = 'localhost'; 若是登陸不成功嘗試修改成127.0.0.1
第一個緣由:數據庫用戶名密碼不對
第二個緣由:本機不容許鏈接
[root@lamp admin]# cp config.sample.inc.php config.inc.php [root@lamp admin]# vim config.inc.php #$cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['host'] = '127.0.0.1'; 修改以後重啓服務果真可以登錄成功
先在本機數據庫創建一個myblog的database
而後進入本機瀏覽器www.myblog.net,點擊 如今就開始 ,而後依次輸入myblog--->root--->123,點擊提交,出現下圖錯誤。
[root@lamp myblog]# cp wp-config-sample.php wp-config.php [root@lamp myblog]# vim wp-config.php /** WordPress數據庫的名稱 */ define('DB_NAME', 'myblog'); /** MySQL數據庫用戶名 */ define('DB_USER', 'root'); /** MySQL數據庫密碼 */ define('DB_PASSWORD', '123');
點擊重試以後提交,又出錯
如今進入到mysql裏面刪除myblog數據庫,再次重建,而後進入網頁刷新,清空緩存,出現下面的錯誤,這個時候只能是思考配置文件的問題
檢查一下/myblog下面的文件權限
再次測試,仍是錯誤
[root@lamp myblog]# chown daemon. wp-config.php [root@lamp myblog]# vim wp-config.php // ** MySQL 設置 - 具體信息來自您正在使用的主機 ** // /** WordPress數據庫的名稱 */ define('DB_NAME', 'myblog'); /** MySQL數據庫用戶名 */ define('DB_USER', 'root'); /** MySQL數據庫密碼 */ define('DB_PASSWORD', '123'); /** MySQL主機 */ define('DB_HOST', '127.0.0.1'); 修改成127.0.0.1 [root@lamp myblog]# /usr/local/apache2/bin/apachectl restart AH00557: httpd: apr_sockaddr_info_get() failed for lamp AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
測試