CentOS/RHEL 7, 64 Bit System:
# rpm -Uvh http://free.nchc.org.tw/fedora-epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
CentOS/RHEL 6, 64/32 Bit System:
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
CentOS/RHEL 5, 64/32 Bit System:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-releas5-4.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
# yum --enablerepo=remi,epel install httpd
# yum --enablerepo=remi,epel install mysql-server
# service mysqld start
# /usr/bin/mysql_secure_installation
# yum --enablerepo=remi,epel install php php-mysql php-intl
# service httpd restart
# curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
# chmod a+x /usr/local/bin/symfony
# cd /var/www/html
# symfony new myproj 2.8
现在切换到新创建的目录,然后检查是否所有要求都正确安装在系统上。如果一切正常,你会得到下面的结果。
# php myproj/bin/symfony_requirements
[OK]
Your system is ready to run Symfony2 projects
# php bin/console server:run
[OK] Server running on http://127.0.0.1:8000
// Quit the server with CONTROL-C.
现在,在浏览器中通过访问http://127.0.0.1:8000或http://localhost:8000进入新的Symfony 2的应用程序。
# vim /etc/http/conf.d/symphony2.example.com.conf
目录,并添加下面的内容。
<VirtualHost *:80>
ServerName symphony2.example.com
DocumentRoot /var/www/html/myproj/web
<Directory /var/www/html/myproj/web>
AllowOverride All
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
ErrorLog /var/log/httpd/myproj_error.log
CustomLog /var/log/httpd/myproj_access.log combined
</VirtualHost>
完成所有更改后,现在重新启动Apache服务器更改生效。
# sudo service httpd restart
现在做一个主机文件条目在你的浏览器来访问新的Symfony 2应用程序,用你的域名如http://symfony2.example.com。更改symfony2.example.com和127.0.0.1根据您的设置。
# echo "127.0.0.1 symphony2.example.com" >> /etc/hosts
关注云架构公众号
Linux入门
QQ交流群:308781113