目錄php
上一篇文章講述瞭如何搭建LNMP開發環境,此次將講述如何搭建LAMP
開發環境。搭建環境的過程當中須要下載一些安裝包,咱們能夠經過CentOS的yum命令下載,也能夠經過FileZilla工具提早下載好,而後傳輸到CentOS中,這裏咱們假定咱們把下載好的安裝包都放到了/usr/src目錄下,放到這裏的目的是統一便於管理,你也能夠放到你喜歡的目錄中。html
sudo yum install gcc gcc-c++ perl perl-devel expat expat-devel autoconf libtool openssl openssl-devel
下載地址:https://apr.apache.org,這裏統一把安裝包都下載到/usr/src目錄下,便於管理 cd /usr/src tar -zxvf apr-1.6.3.tar.gz cd apr-1.6.3 ./configure --prefix=/usr/local/apr make && make install
下載地址:https://apr.apache.org/ cd /usr/src tar -zxvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install
下載地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ cd /usr/src tar zxvf pcre-8.42.tar.gz cd pcre-8.42 ./configure --prefix=/usr/local/pcre make && make install
tar zxvf httpd-2.4.33.tar.gz cd httpd-2.4.33 ./configure \ --prefix=/usr/local/apache \ --enable-ssl \ --enable-so \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --with-pcre=/usr/local/pcre make && make install
vi /etc/profile export PATH="$PATH:/usr/local/apache/bin" source /etc/profile
vim /etc/rc.d/rc.local /usr/local/apache/bin/apachectl start
sr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak cp /usr/local/apache/conf/extra/httpd-vhosts.conf /usr/local/apache/conf/extra/httpd-vhosts.conf.bak vi /usr/local/apache/conf/httpd.conf 去掉152行前面的#號,開啓重寫模塊 去掉194行前面的#號,去除錯誤信息 239行容許重寫 AllowOverride All 開啓Apache: apachectl -k start
CentOS6: service iptables stop 臨時關閉 chkconfig --level 2345 iptables off 永久關閉 CentOS7: systemctl stop firewalld.service #令關閉防火牆 systemctl disable firewalld.service #關閉防火牆開機自啓動 經過瀏覽器輸入IP測試成功
(1)cmake是新版MySQL的編譯工具,必須安裝mysql
sudo yum install gcc gcc-c++ cmake ncurses-devel
若是你的系統是CentOS7,你還須要安裝以下依賴c++
sudo yum install perl perl-devel autoconf
useradd -s /sbin/nologin -M mysql # 添加MySQL用戶 wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.41.tar.gz tar zxvf mysql-5.6.41.tar.gz cd mysql-5.6.41 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.41 \ -DMYSQL_UNIX_ADDR=/usr/local/mysql-5.6.41/tmp/mysql.sock \ -DMYSQL_DATADIR=/usr/local/mysql-5.6.41/data \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS=all \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DWITH_INNODB_MEMCACHED=1 \ -DWITH_DEBUG=OFF \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DENABLED_PROFILING=ON \ -DMYSQL_MAINTAINER_MODE=OFF \ -DMYSQL_TCP_PORT=3306 make && make install
cd /usr/local/mysql-5.6.41 chown mysql.mysql /usr/local/mysql-5.6.41/data mkdir tmp chown mysql.mysql /usr/local/mysql-5.6.41/tmp rm -f /etc/my.cnf cp support-files/my-default.cnf /etc/my.cnf scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
cd /usr/local ln -s mysql-5.6.41 mysql cd /usr/local/mysql cp support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld
vim /etc/profile export PATH="/usr/local/mysql/bin" source /etc/profile
service mysqld start mysql -u root -p #第一次登錄不須要密碼,回車便可 set password for root@localhost = password('root'); #修改密碼
sudo yum install gcc gcc-c++ libxml2 libxml2-devel curl-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel
tar zxvf php-7.2.3.tar.gz cd php-7.2.3 ./configure \ --prefix=/usr/local/php \ --enable-mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock \ --with-apxs2=/usr/local/apache/bin/apxs \ --with-zlib \ --with-gd \ --with-png-dir \ --with-jpeg-dir \ --with-freetype-dir \ --with-openssl \ --enable-mbstring \ --enable-xml \ --enable-zip \ --enable-sockets \ --with-curl make && make install
vi /usr/local/apache/conf/httpd.conf # 加入 在 加載了PHP模塊以後 <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> # 保存,退出,重啓
vi /etc/profile export PATH="$PATH:/usr/local/php/bin" source /etc/profile cp /usr/src/php-7.2.3/php.ini-development /usr/local/php/lib/php.ini vi /usr/local/php/lib/php.ini date.timezone = PRC (大約在932行)
vi /usr/local/apache/conf/httpd.conf # 258行,默認首頁加入index.php # 483行,開啓虛擬主機支持 vi /usr/local/apache/conf/extra/httpd-vhosts.conf vi /usr/local/apache/conf/extra/httpd-vhosts.conf <VirtualHost *:80> ServerAdmin www.huiwan.com DocumentRoot "/mnt/hgfs/web/huiwan" ServerName www.huiwan.com #ErrorLog "logs/dummy-host2.example.com-error_log" #CustomLog "logs/dummy-host2.example.com-access_log" common <Directory "/mnt/hgfs/web/huiwan"> Options indexes Multiviews AllowOverride All Require all granted </Directory> </VirtualHost>