CentOS 6.x 使用包管理器安装配置Apache+PHP+MySql
Apache:
? ? 安裝:
???????? yum install httpd ????#根據提示,輸入Y安裝即可成功安裝????配置:??
vi /etc/httpd/conf/httpd.conf? ? ? ? ????#AddHandler cgi-script .cgi????→????AddHandler cgi-script .cgi .pl (允許擴展名為.pl的CGI腳本運行)
????????????Options Indexes MultiViews FollowSymLinks????→????Options MultiViews FollowSymLinks(不在瀏覽器上顯示樹狀目錄結構)
????????????ServerSignature On? ? →????ServerSignature Off (在錯誤頁中不顯示Apache的版本)
????????????DirectoryIndex index.html index.html.var? ? →????DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var (設置默認首頁文件,增加index.php)
????????? ? (338行左右)AllowOverride None????→????AllowOverride All (允許.htaccess)
????????????Options Indexes FollowSymLinks? ? →????Options Includes ExecCGI FollowSymLinks(允許服務器執行CGI及SSI,禁止列出目錄)
????????????MaxKeepAliveRequests 100? ? →????MaxKeepAliveRequests 1000 (增加同時連接數)
????????????KeepAlive Off? ? →????KeepAlive On (允許程序性聯機)
????????????ServerTokens OS? ? →????ServerTokens Prod (在出現錯誤頁的時候不顯示服務器操作系統的名稱)
????????????#ServerName www.example.com:80? ? →????ServerName localhost:80 #這里設置為你自己的域名,如果沒有域名,可以設置為localhost
????????????
????????????<VirtualHost *:80>? ? #虛擬主機
? ? ????????????ServerAdmin webmaster@dummy-host.example.com
? ? ????????????DocumentRoot /var/www/html/www.sample.com
? ? ????????????ServerName www.sample.com
? ? ????????????ErrorLog logs/www.sample.com-error_log
? ? ????????????CustomLog logs/www.sample.com-access_log common
????????????</VirtualHost>
????????:wq! #保存退出? ??? ??
????????chkconfig httpd on?#設為開機啟動,查看chkconfig --list httpd
????????service httpd start? ?? ??
? ? ? ??rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html ?#刪除默認測試頁
? ? 基本信息:
Apache目錄:/etc/httpdweb根目錄:/var/www/html
PHP:
? ? 安裝:
????????yum install php????#根據提示,輸入Y安裝即可成功安裝
????????yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt ?#安裝PHP組件,使 PHP5 支持 MySQL
? ? 配置:
????????vi /etc/php.ini
????????????;date.timezone =? ? →????date.timezone = PRC
????????????magic_quotes_gpc = Off? ? →????magic_quotes_gpc = On?#在745行 打開magic_quotes_gpc來防止SQL注入
????????????display_errors = Off? ? #調試開啟,生產關閉
????????????expose_php = On????#是否禁止顯示php版本的信息
????????????disable_functions =? ? →????disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname????#列出PHP可以禁用的函數,如果某些程序需要用到這個函數,可以刪除,取消禁用。
????????????open_basedir = .:/var/www/html/:/tmp/? #設置表示允許訪問當前目錄(即PHP腳本文件所在之目錄)和/tmp/目錄,可以防止php木馬跨站,如果改了之后安裝程序有問題,可以注銷此行,或者直接寫上程序的目錄/data/www.osyunwei.com/:/tmp/。/etc/httpd/conf.d/vhost.conf中設置了open_basedir之后, 虛擬用戶就不會再自動繼承php.ini中的open_basedir設置值了,這就難以達到靈活的配置措施, 所以建議您不要在/etc/httpd/conf.d/vhost.conf中設置此項限制。可以在php.ini中設置open_basedir = .:/tmp/
?????????????short_open_tag = Off? ? →????short_open_tag = ON #支持php短標簽
MySql:
? ??????安裝:
???????????? yum install mysql mysql-server????配置:
????????????mysql_secure_installation????為root賬戶設置密碼
????????? ??chkconfig mysqld on????#設為開機啟動?
????????????
????????? ? service mysql start? ? #啟動
????????? ? service mysql restart? ? #重啟
????????? ? service mysql stop? ? #停止
總結
以上是生活随笔為你收集整理的CentOS 6.x 使用包管理器安装配置Apache+PHP+MySql的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 逆势获投1亿,火眼金睛下的云适配BRaa
- 下一篇: java语言相比于c,【多选题】Java