快速開始,絕無廢話我的linux服務器系統是CentOS 6.51,安裝apache: yum install httpd
apache的文件目錄 /var/www/htmlapache啟動,停止,查看狀態的命令:service httpd startservice httpd stopservice httpd status配置文件 /etc/httpd/conf/httpd.conf修改端口(默認是80) Listen 8082修改ServerName ServerName localhost:8082測試,能出來頁面OK瞭2,安裝phpyum install php php-devel安裝好後,php -v 查看一下能出來版本說明ok再重啟一下apacheservice httpd restart
寫個php頁面測試在apache的文件目錄 /var/www/html下,創建一個test.php<?php echo “Hello world!”; ?>
<?php phpinfo(); ?>
保存後,回到瀏覽器測試完成,3,連接mysqlmysql的安裝,略。公司有DBA,呵呵。先安裝php的擴展yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
安裝完擴展之後需要再次重啟apacheservice httpd restart
測試mysql是否鏈接成功的php代碼<?php
$servername = “localhost”;
$username = “username”;
$password = “password”;
$dbname = “數據庫名”;
$port = “端口”;
// 創建連接
$conn = new mysqli($servername, $username, $password, $dbname, $port);
// 檢測連接
if ($conn->connect_error) {
die(“連接失敗: ” . $conn->connect_error);
}
echo “連接成功”;
?>
完成。開始擼代碼。