centos安裝apachephp
⑴ linux CentOS下編譯安裝php5.3.x卡在Generating phar.php
解壓縮
a) 下載的php壓縮包,並進入解壓後目錄內運行如下命令:
b) ./configure--prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs--with-config-file-path=/usr/local/lib --enable-track-vars --with-xml
c) make
d) make install
一共就這么四個步驟,要不你重新來吧
看你那屏幕截圖,貌似是亂碼的趕腳,是不是環境比那輛沒有設置正確
⑵ 如何搭建lamp(CentOS7+Apache+Mysql+PHP)環境
在網上搜資料,自己在本地虛擬機上嘗試搭建,弄了整整一天一夜,終於弄好了.網上的資料,雖然很多,但大多都是重復的,拿去試了之後,又很多都不能得到正確的結果.最終找到了適合我的linux環境的搭建方式;在這里貼出來:度娘真不給力啊,沒搜出來靠譜的方法。最後用喜樂搜找到的靠譜的教程。
這里還是要總結一下我的LAMP環境的搭建步驟。我先在電腦里裝了虛擬機,在虛擬機中測試了數次之後,再在伺服器上搭建的。說說我的環境:虛擬機是:VMware® Workstation 12.1.1 Pro;Linux系統用的是:CentOS-7-x86_64-DVD-1511.iso;(阿里雲上也是用的CentOS7-64bit)准備好這兩個之後,就開始一步一步搭建我們的LAMP環境了。
一、安裝虛擬機
二、安裝CentOS7
注意:以下安裝,我都是用的root許可權。
三、安裝Apache1.安裝yum -y install httpd2.開啟apache服務systemctl start httpd.service3.設置apache服務開機啟動systemctl enable httpd.service4.驗證apache服務是否安裝成功在本機瀏覽器中輸入虛擬機的ip地址,CentOS7查看ip地址的方式為:ip addr(阿里雲不需要用這種方式查看,外網ip已經在你主機列表那裡給你寫出來了的;)這里是訪問不成功的(阿里雲用外網訪問,能成功,不需要做以下步驟)查了資料,說法是,CentOS7用的是Firewall-cmd,CentOS7之前用的是iptables防火牆;要想讓外網能訪問到apache主目錄,就需要做以下的操作:firewall-cmd --permanent --zone=public --add-service=httpfirewall-cmd --permanent --zone=public --add-service=httpsfirewall-cmd --reload然後再訪問外網ip,如果看到apache默認的頁面--有Testing 123...字樣,便是成功安裝了apache服務了;
四、安裝PHP1.安裝yum -y install php2.重啟apache服務systemctl restart httpd或者systemctl restart httpd.service然後,你可以寫一個php文件在瀏覽器中運行一下了;eg:vi /var/www/html/info.phpi<?php phpinfo(); ?>Esc:wq然後,在自己電腦瀏覽器輸入 192.168.1.1/info.php運行,會出現php的一些信息
五、安裝MySQL我這里根據所學的那個教程,也安裝了MariaDB1.安裝
yum -y install mariadb*
2.開啟MySQL服務systemctl start mariadb.service3.設置開機啟動MySQL服務systemctl enable mariadb.service4.設置root帳戶的密碼mysql_secure_installation然後會出現一串東西,可以仔細讀一下,如果你懶得讀,就在提示出來的時候,按Enter就好了,讓你設置密碼的時候,你就輸入你想要的密碼就行,然後繼續在讓你選擇y/n是,Enter就好了;當一切結束的時候,你可以輸入mysql -uroot -p的方式,驗證一下;
六、將PHP和MySQL關聯起來yum search php,選擇你需要的安裝:yum -y install php-mysql
七、安裝常用的PHP模塊例如,GD庫,curl,mbstring,...1.安裝:yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel2.重啟apache服務systemctl restart httpd.service然後,再次在瀏覽器中運行info.php,你會看到安裝的模塊的信息;
至此,LAMP環境就搭建好了。
如何搭建lamp(CentOS7+Apache+MySQL+PHP)環境
標簽:
⑶ 如何在CentOS6下實現Apache+PHP+MySQL的快速安裝
LAMP是一個免費、開源的解決方案,代表了Linux、Apache、MySQL、PHP,主要用作建立可行的通用的web伺服器。那麼如何在CentOS6下實現安裝Apache+php+Mysql的快速安裝?其具體安裝配置步驟可以如下進行:
1.准備工作
使用yum進行安裝,為了提高速度,最好先是修改為中國CentOS鏡像伺服器。目前國內有三個鏡像可以選擇,分別是:中國科學技術大學、163和Sohu的鏡像,建議教育網用戶選擇中科大,電信用戶選擇163
下面命令是備份CentOS-Base.repo文件,並修改使用163鏡像作為yum源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.save
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS6-Base-163.repo /etc/yum.repos.d/CentOS-Base.repo
2.更新系統內核
yum -y update
3.安裝Apahce、Mysql、PHP
yum -y install httpd php mysql mysql-server
默認情況下,mysql數據目錄位於/var/lib/mysql
4.安裝相關組件:
yum install php-mysql php-gd php-imap php-ldap php-odbc
php-pear php-xml php-xmlrpc
5.安裝MySQL管理工具phpMyAdmin
yum -y install phpMyAdmin
6.配置Apache隨系統啟動
chkconfig --levels 235 httpd on
/etc/init.d/httpd start
7.配置MySQL隨系統啟動
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
8.設置資料庫root密碼
/usr/bin/mysqladmin -u root password 'New+Password#www.yupengyan.com'
9.測試PHP是否安裝成功
在 CentOS 中 Apache 的默認根目錄是 /var/www/html,配置文件 /etc/httpd/conf/httpd.conf。其他配置存儲在 /etc/httpd/conf.d/ 目錄。
⑷ CentOS70安裝配置LAMP伺服器方法ApachePHPMariaDB
准備篇:CentOS 7.0系統安裝配置圖解教程
一、配置防火牆,開啟80埠、3306埠
CentOS 7.0默認使用的是firewall作為防火牆,這里改為iptables防火牆。
1、關閉firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
2、安裝iptables防火牆
yum install iptables-services #安裝
vi /etc/sysconfig/iptables #編輯防火牆配置文件
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出
systemctl restart iptables.service #最後重啟防火牆使配置生效
systemctl enable iptables.service #設置防火牆開機啟動
二、關閉SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注釋掉
#SELINUXTYPE=targeted #注釋掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
安裝篇:
一、安裝Apache
系統運維 www.osyunwei.com 溫馨提醒:qihang01原創內容©版權所有,轉載請註明出處及原文鏈
yum install httpd #根據提示,輸入Y安裝即可成功安裝
systemctl start httpd.service #啟動apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重啟apache
systemctl enable httpd.service #設置apache開機啟動
在客戶端瀏覽器中打開伺服器IP地址,會出現下面的界面,說明apache安裝成功
系統運維 www.osyunwei.com 溫馨提醒:qihang01原創內容©版權所有,轉載請註明出處及原文鏈
二、安裝MariaDB
CentOS 7.0中,已經使用MariaDB替代了MySQL資料庫
1、安裝MariaDB
yum install mariadb mariadb-server #詢問是否要安裝,輸入Y即可自動安裝,直到安裝完成
systemctl start mariadb.service #啟動MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重啟MariaDB
systemctl enable mariadb.service #設置開機啟動
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #拷貝配置文件(注意:如果/etc目錄下面默認有一個my.cnf,直接覆蓋即可)
2、為root賬戶設置密碼
mysql_secure_installation
回車,根據提示輸入Y
輸入2次密碼,回車
根據提示一路輸入Y
最後出現:Thanks for using MySQL!
MySql密碼設置完成,重新啟動 MySQL:
systemctl restart mariadb.service #重啟MariaDB
三、安裝PHP
1、安裝PHP
yum install php #根據提示輸入Y直到安裝完成
2、安裝PHP組件,使PHP支持 MariaDB
yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#這里選擇以上安裝包進行安裝,根據提示輸入Y回車
systemctl restart mariadb.service #重啟MariaDB
systemctl restart httpd.service #重啟apache
配置篇
一、Apache配置
vi /etc/httpd/conf/httpd.conf #編輯文件
ServerSignature On #添加,在錯誤頁中顯示Apache的版本,Off為不顯示
Options Indexes FollowSymLinks #修改為:Options Includes ExecCGI FollowSymLinks(允許伺服器執行CGI及SSI,禁止列出目錄)
#AddHandler cgi-script .cgi#修改為:AddHandler cgi-script .cgi .pl (允許擴展名為.pl的CGI腳本運行)
AllowOverride None #修改為:AllowOverride All (允許.htaccess)
AddDefaultCharset UTF-8#修改為:AddDefaultCharset GB2312(添加GB2312為默認編碼)
#Options Indexes FollowSymLinks #修改為 Options FollowSymLinks(不在瀏覽器上顯示樹狀目錄結構)
DirectoryIndex index.html #修改為:DirectoryIndex index.html index.htm Default.html Default.htm index.php(設置默認首頁文件,增加index.php)
MaxKeepAliveRequests 500 #添加MaxKeepAliveRequests 500 (增加同時連接數)
:wq! #保存退出
systemctl restart httpd.service #重啟apache
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #刪除默認測試頁
二、php配置
vi /etc/php.ini #編輯
date.timezone = PRC #把前面的分號去掉,改為date.timezone = PRC
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可以禁用的函數,如果某些程序需要用到這個函數,可以刪除,取消禁用。
expose_php = Off #禁止顯示php版本的信息
short_open_tag = ON #支持php短標簽
open_basedir = .:/tmp/ #設置表示允許訪問當前目錄(即PHP腳本文件所在之目錄)和/tmp/目錄,可以防止php木馬跨站,如果改了之後安裝程序有問題(例如:織夢內容管理系統),可以注銷此行,或者直接寫上程序的目錄/data/www.osyunwei.com/:/tmp/
:wq! #保存退出
systemctl restart mariadb.service #重啟MariaDB
systemctl restart httpd.service #重啟apache
測試篇
cd /var/www/html
vi index.php #輸入下面內容
<?php
phpinfo();
?>
:wq! #保存退出
在客戶端瀏覽器輸入伺服器IP地址,可以看到如下圖所示相關的配置信息!
注意:apache默認的程序目錄是/var/www/html
許可權設置:chown apache.apache -R /var/www/html
至此,CentOS 7.0安裝配置LAMP伺服器(Apache+PHP+MariaDB)教程完成!